Skip to content

Commit 20b2c07

Browse files
committed
[skip changelog] Change documentation theme to customized one
1 parent ef4a389 commit 20b2c07

File tree

8 files changed

+139
-3
lines changed

8 files changed

+139
-3
lines changed

.github/workflows/publish-docs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ jobs:
8282
python3 -m pip install --upgrade pip
8383
python3 -m pip install -r ./requirements_docs.txt
8484
85+
- name: Build docs theme
86+
run: task docs:build-theme
87+
8588
- name: Publish docs
8689
# Determine docs version for the commit pushed and publish accordingly using Mike.
8790
# Publishing implies creating a git commit on the gh-pages branch, we let

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ venv
2727
/docsgen/arduino-cli
2828
/docs/rpc/*.md
2929
/docs/commands/*.md
30+
/mkdocs-material

Taskfile.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,31 @@ tasks:
2828
- task: docs:gen:commands
2929
- task: docs:gen:protobuf
3030

31+
docs:patch-theme:
32+
desc: Downloads documentation theme and patch it with custom header and footer
33+
cmds:
34+
- |
35+
[[ -d mkdocs-material ]] && git clone https://github.com/squidfunk/mkdocs-material.git -b 5.5.14 --depth 1
36+
# Ugly hack so that this doesn't fail if patch is already applied
37+
git apply --check mkdocs-material-patches/*.patch && git apply mkdocs-material-patches/*.patch; echo
38+
39+
docs:build-theme:
40+
decs: Builds documentation theme
41+
dir: ./mkdocs-material
42+
cmds:
43+
- task: docs:patch-theme
44+
- ignore_error: true
45+
- npm install
46+
- npm run-script build
47+
3148
docs:build:
3249
desc: Build documentation website contents
3350
deps:
3451
- docs:gen:commands
3552
- docs:gen:protobuf
3653
cmds:
54+
- task: docs:build-theme
55+
- ignore_error: true
3756
- mkdocs build -s
3857

3958
docs:publish:
@@ -62,7 +81,7 @@ tasks:
6281
- |
6382
npx -p markdown-link-check -c '
6483
STATUS=0
65-
for file in $(find -name "*.md"); do
84+
for file in $(find -path ./mkdocs-material -prune -o -name "*.md" -print); do
6685
markdown-link-check -c markdown-link-check-config.json -q "$file"
6786
STATUS=$(( $STATUS + $? ))
6887
done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/mkdocs-material/src/assets/stylesheets/main/layout/_base.scss b/mkdocs-material/src/assets/stylesheets/main/layout/_base.scss
2+
index 10245844..bc91241a 100644
3+
--- a/mkdocs-material/src/assets/stylesheets/main/layout/_base.scss
4+
+++ b/mkdocs-material/src/assets/stylesheets/main/layout/_base.scss
5+
@@ -108,6 +108,7 @@ hr {
6+
display: flex;
7+
flex-direction: column;
8+
flex-grow: 1;
9+
+ margin-top: 8em;
10+
11+
// Hack: we must not use flex, or Firefox will only print the first page
12+
// see https://mzl.la/39DgR3m
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
diff --git a/mkdocs-material/src/base.html b/mkdocs-material/src/base.html
2+
index 9cb7ebf9..ebdcb325 100644
3+
--- a/mkdocs-material/src/base.html
4+
+++ b/mkdocs-material/src/base.html
5+
@@ -236,7 +236,9 @@
6+
7+
<!-- Application header -->
8+
{% block header %}
9+
- {% include "partials/header.html" %}
10+
+ <div id="arduino-header" class="temporary">
11+
+ </div>
12+
+ <!-- {% include "partials/header.html" %} -->
13+
{% endblock %}
14+
15+
<!-- Container, necessary for web-application context -->
16+
@@ -378,20 +380,35 @@
17+
{{- translations | tojson -}}
18+
</script>
19+
20+
- <!-- Application configuration -->
21+
- {% block config %}{% endblock %}
22+
+ <!-- Custom Arduino header-footer -->
23+
+ <link rel="stylesheet" type="text/css" href="https://cdn.arduino.cc/header-footer/prod/index.v2.css">
24+
+ <script src="https://cdn.arduino.cc/header-footer/prod/index.v2.js"></script>
25+
26+
- <!-- Application initialization -->
27+
- <script>
28+
- app = initialize({
29+
- base: "{{ base_url }}",
30+
- features: {{ config.theme.features or [] | tojson }},
31+
- search: Object.assign({
32+
- worker: "{{ 'assets/javascripts/worker/search.js' | url }}"
33+
- }, typeof search !== "undefined" && search)
34+
+ <script type="text/javascript">
35+
+ window.auth = new arduinoHF.CustomAuth({
36+
+ no_auth: true
37+
+ });
38+
+ </script>
39+
+
40+
+ <script type="text/javascript">
41+
+ // Init header
42+
+ window.arduinoHeader = new window.arduinoHF.Header(document.getElementById('arduino-header'), window.auth, {
43+
+ env: 'prod',
44+
+ style: 'arduino',
45+
+ search: {
46+
+ tab: 'reference'
47+
+ }
48+
})
49+
+
50+
+ window.arduinoFooter = new window.arduinoHF.Footer(document.getElementById('arduino-footer'), {
51+
+ env: 'prod',
52+
+ style: 'arduino'
53+
+ });
54+
</script>
55+
56+
+ <!-- Application configuration -->
57+
+ {% block config %}{% endblock %}
58+
+
59+
<!-- Custom JavaScript -->
60+
{% for path in config["extra_javascript"] %}
61+
<script src="{{ path | url }}"></script>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
diff --git a/mkdocs-material/src/partials/footer.html b/mkdocs-material/src/partials/footer.html
2+
index 21924c41..31acf71b 100644
3+
--- a/mkdocs-material/src/partials/footer.html
4+
+++ b/mkdocs-material/src/partials/footer.html
5+
@@ -81,27 +81,5 @@
6+
{% endif %}
7+
8+
<!-- Further information -->
9+
- <div class="md-footer-meta md-typeset">
10+
- <div class="md-footer-meta__inner md-grid">
11+
-
12+
- <!-- Copyright and theme information -->
13+
- <div class="md-footer-copyright">
14+
- {% if config.copyright %}
15+
- <div class="md-footer-copyright__highlight">
16+
- {{ config.copyright }}
17+
- </div>
18+
- {% endif %}
19+
- Made with
20+
- <a
21+
- href="https://squidfunk.github.io/mkdocs-material/"
22+
- target="_blank" rel="noopener"
23+
- >
24+
- Material for MkDocs
25+
- </a>
26+
- </div>
27+
-
28+
- <!-- Social links -->
29+
- {% include "partials/social.html" %}
30+
- </div>
31+
- </div>
32+
+ <div id="arduino-footer"></div>
33+
</footer>

mkdocs.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,18 @@ copyright: Copyright 2020 ARDUINO SA (http://www.arduino.cc/)
1313

1414
# Theme
1515
theme:
16-
name: material
16+
name: null
17+
custom_dir: mkdocs-material/material
1718
logo: img/icon_mac_light.png
1819
palette:
1920
primary: teal
2021
accent: orange
22+
language: en
23+
font:
24+
text: Roboto
25+
code: Roboto Mono
26+
icon:
27+
logo: logo
2128

2229
# Extensions
2330
markdown_extensions:

requirements_docs.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
mkdocs<1.2
2-
mkdocs-material<5
32
mike==0.5.1
43
gitpython
54
click<7.2
65
mdx_truly_sane_lists==1.2
6+
pymdown-extensions>=7.0

0 commit comments

Comments
 (0)