Skip to content

Commit 4876e16

Browse files
committed
Add mkdocs GDS theme
Add PDF generation support and styling for mkdocs documentation, resolves #11
1 parent f74fe79 commit 4876e16

File tree

9 files changed

+1581
-134
lines changed

9 files changed

+1581
-134
lines changed

.github/workflows/publish-guidelines.yml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,42 @@ jobs:
4040
- uses: actions/cache@v4
4141
with:
4242
key: mkdocs-material-${{ env.cache_id }}
43-
path: .cache
43+
path: ~/.cache
4444
restore-keys: |
4545
mkdocs-material-
4646
47-
- run: |
47+
- name: install mkdocs and plugins
48+
run: |
4849
pip install mkdocs-material
4950
pip install markdown-callouts
5051
pip install mkdocs-git-revision-date-localized-plugin
5152
pip install mkdocs-git-committers-plugin-2
52-
pip install mkdocs-exporter
53+
pip install pytest-playwright
54+
pip install mkdocs-print-site-plugin
55+
pip install mkdocs-tech-docs-template
5356
pip install mkdocs-redirects
5457
pip install mkdocs-awesome-pages-plugin
5558
56-
- run: |
59+
- name: install playwright
60+
run: |
5761
playwright install --with-deps
5862
playwright install chrome --with-deps
5963
64+
- name: generate site pdf
65+
run: |
66+
mkdocs serve --no-livereload -c -q &
67+
echo "waiting for mkdocs dev server to start..."
68+
until curl --output /dev/null --silent --head --fail http://localhost:8000; do
69+
printf '.'
70+
sleep 1
71+
done
72+
playwright pdf --wait-for-selector=#print-site-page localhost:8000/print_page/ docs/ukhsa-api-guidelines.pdf
73+
killall -9 mkdocs
74+
env:
75+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
76+
MKDOCS_GIT_PROVENANCE_ENABLED: true
77+
MKDOCS_EXPORTER_PDF_ENABLED: true
78+
6079
- name: Publish docs
6180
run: mkdocs build
6281
env:

docs/assets/images/favicon-new.svg

Lines changed: 13 additions & 0 deletions
Loading

docs/assets/images/logo-ukhsa-landscape-new.svg

Lines changed: 1120 additions & 0 deletions
Loading

docs/stylesheets/pdf.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/* print styles for mkdocs material theme
2+
https://github.com/squidfunk/mkdocs-material */
3+
4+
/* Table of Contents styling */
5+
#print-site-page ul.toc-section-line-border {
6+
border-left: 5px solid var(--md-default-fg-color--lightest);
7+
}
8+
9+
10+
/* Box shadows don't do well in PDFs */
11+
#print-site-page table {
12+
border: 1px solid hsla(200, 18%, 26%, 1); /* #EFEFEF */
13+
box-shadow: none !important;
14+
}
15+
16+
@media print {
17+
#print-site-page td {
18+
word-wrap: break-word;
19+
}
20+
21+
}
22+
23+
@page {
24+
25+
size: A4 portrait;
26+
margin: 4em 1.5em 4em 1.5em;
27+
padding: 0em 0em 0em 0em;
28+
counter-increment: page;
29+
30+
@bottom-center {
31+
content: string(chapter);
32+
}
33+
@bottom-right {
34+
font-size: 0.65rem;
35+
padding-right: 1.0rem;
36+
content: "Page " counter(page) " of " counter(pages);
37+
}
38+
39+
}

docs/stylesheets/pdf.scss

Lines changed: 0 additions & 98 deletions
This file was deleted.

mkdocs.yml

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
site_name: API Guidelines
2-
site_description: 'Home of UKHSA API Guidelines'
2+
site_description: 'UKHSA API Guidelines'
33
site_author: 'UKSHA'
44
docs_dir: docs/
55
repo_name: 'UKHSA-Internal/api-guidelines'
@@ -19,8 +19,6 @@ nav:
1919
- api-design-guidelines/pagination-filtering-sorting.md
2020
- api-design-guidelines/testing.md
2121
- Performance, Reliability & Monitoring:
22-
#- api-design-guidelines/performance-reliability-monitoring.md
23-
#- api-design-guidelines/performance-reliability-monitoring-new.md
2422
- api-design-guidelines/caching.md
2523
- api-design-guidelines/governance.md
2624
- api-design-guidelines/data-standards.md
@@ -36,13 +34,15 @@ nav:
3634
- ... | flat | spectral-rules/should/*.md
3735

3836
theme:
39-
name: material
40-
logo: assets/images/logo-ukhsa-landscape.svg
41-
favicon: assets/images/favicon.svg
37+
name: tech_docs_template
38+
custom_dir: overrides
39+
logo: assets/images/logo-ukhsa-landscape-new.svg
40+
favicon: assets/images/favicon-new.svg
4241
palette:
43-
- primary: white
42+
# - primary: black
43+
# accent: teal
44+
- scheme: default
4445
accent: teal
45-
scheme: default
4646

4747
features:
4848
- navigation.instant
@@ -58,9 +58,11 @@ theme:
5858
- content.code.select
5959
- content.action.edit
6060
- content.action.view
61+
#- toc.integrate
6162

6263
extra_css:
6364
- stylesheets/extra.css
65+
- stylesheets/pdf.css
6466

6567
markdown_extensions:
6668
- github-callouts
@@ -79,7 +81,8 @@ markdown_extensions:
7981
case: lower
8082

8183
plugins:
82-
- search
84+
- material/search
85+
#- search
8386
- awesome-pages
8487
- redirects:
8588
redirect_maps:
@@ -93,26 +96,9 @@ plugins:
9396
repository: UKHSA-Internal/api-guidelines
9497
token: !ENV [GITHUB_TOKEN]
9598
branch: main
96-
- exporter:
97-
buttons:
98-
- title: View as PDF
99-
icon: material-file-move-outline
100-
enabled: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.enabled
101-
attributes:
102-
target: _blank
103-
href: /ukhsa-api-guidelines.pdf
104-
- title: Download as PDF
105-
icon: material-file-download-outline
106-
enabled: !!python/name:mkdocs_exporter.formats.pdf.buttons.download.enabled
107-
attributes:
108-
download: ukhsa-api-guidelines.pdf
109-
href: /ukhsa-api-guidelines.pdf
110-
formats:
111-
pdf:
112-
enabled: !ENV [MKDOCS_EXPORTER_PDF_ENABLED, false]
113-
stylesheets:
114-
- docs/stylesheets/pdf.scss
115-
aggregator:
116-
enabled: true
117-
output: ukhsa-api-guidelines.pdf
118-
covers: none
99+
- print-site:
100+
add_to_navigation: false
101+
add_cover_page: true
102+
include_css: true
103+
path_to_pdf: "ukhsa-api-guidelines.pdf"
104+
enabled: !ENV [MKDOCS_EXPORTER_PDF_ENABLED, false]

overrides/assets/images/govuk-crest.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)