Skip to content

Commit 7b73fde

Browse files
authored
Build and publish docs per version (#158)
* Remove unused files * Add publishing step * Allow manual trigger, and fetch full depth * Refactor actual docs build code into fluent.docs * Add versions to the project docs. * Freeze dependencies of the docs build process * Update Sphinx to 3.5.1 Use classes for builders, use subclassing instead of code-flow ifs to distinguish the top-level builder from the project builders.
1 parent ae416d0 commit 7b73fde

File tree

21 files changed

+541
-334
lines changed

21 files changed

+541
-334
lines changed

.github/workflows/documentation.yml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: documentation
22

33
on:
4+
workflow_dispatch:
45
# Trigger the workflow on push or pull request,
56
# but only for the master branch
67
push:
@@ -26,17 +27,41 @@ jobs:
2627
runs-on: ubuntu-latest
2728
steps:
2829
- uses: actions/checkout@v2
30+
with:
31+
fetch-depth: 0
2932
- uses: actions/setup-python@v2
3033
with:
3134
python-version: 3.7
3235
- name: Install dependencies
3336
run: |
34-
pip install Sphinx fluent.pygments
37+
pip install -r docs/requirements.txt
38+
pip install ./fluent.docs
3539
- name: sphinx-build
3640
run: |
37-
./scripts/build-docs --to-publish python-fluent
41+
./scripts/build-docs python-fluent
3842
- name: artifact
3943
uses: actions/upload-artifact@v2
4044
with:
4145
name: html
42-
path: _build/python-fluent
46+
path: |
47+
_build/python-fluent
48+
!_build/**/.buildinfo
49+
50+
publish:
51+
name: publish
52+
needs: [build]
53+
runs-on: ubuntu-latest
54+
steps:
55+
- uses: actions/checkout@v2
56+
- name: Download artifact
57+
uses: actions/download-artifact@v2
58+
with:
59+
name: html
60+
path: _build
61+
- name: Deploy 🚀
62+
uses: JamesIves/github-pages-deploy-action@4.0.0
63+
with:
64+
branch: gh-pages # The branch the action should deploy to.
65+
folder: _build # The folder the action should deploy.
66+
clean: true # Automatically remove deleted files from the deploy branch
67+
dry-run: ${{ github.event_name == 'pull_request' }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
_build
77
build
88
dist
9+
/fluent.*/docs/_templates/versions.html

docs/Makefile

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

docs/_static/project-fluent.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
11
div.related {
22
background-color: #356eb7;
33
}
4+
5+
#versions {
6+
position: relative;
7+
color: #444;
8+
}
9+
10+
#versions > span.version {
11+
cursor: pointer;
12+
}
13+
14+
#versions > span.version::after {
15+
content: " ⮞";
16+
}
17+
18+
#versions.opened > span.version {
19+
display: none;
20+
}
21+
22+
#versions:not(.opened) > span.links {
23+
display: none;
24+
}

docs/_static/versions.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Show/hide versions when clicking on the versions paragraph
3+
*/
4+
5+
$(function() {
6+
let versions = document.getElementById('versions');
7+
if (versions) {
8+
versions.onclick = function(ev) {
9+
this.classList.toggle('opened');
10+
}
11+
}
12+
})

docs/_templates/versions.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{#
2+
Intentionally left blank.
3+
Project documtations fill in a sidebar control as part of the build process.
4+
#}

docs/conf.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
# Add any paths that contain templates here, relative to this directory.
3535
templates_path = ['_templates']
3636

37+
# Add src_dir/docs/_templates in a hook as we only have the src_dir then.
38+
def setup(app):
39+
app.connect('config-inited', add_templates)
40+
41+
def add_templates(app, config):
42+
config.templates_path.insert(0, f'{app.srcdir}/_templates')
43+
3744
# List of patterns, relative to source directory, that match files and
3845
# directories to ignore when looking for source files.
3946
# This pattern also affects html_static_path and html_extra_path.
@@ -52,9 +59,10 @@
5259
# so a file named "default.css" will overwrite the builtin "default.css".
5360
html_static_path = ['_static']
5461
html_css_files = ['project-fluent.css']
62+
html_js_files = ['versions.js']
5563

5664
html_sidebars = {
57-
'**': ['globaltoc.html', 'searchbox.html'],
65+
'**': ['globaltoc.html', 'versions.html', 'searchbox.html'],
5866
}
5967
html_theme_options = {
6068
}

docs/requirements.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Sphinx==3.5.1
2+
fluent.pygments==1.0
3+
wheel

docs/requirements.txt

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
#
2+
# This file is autogenerated by pip-compile
3+
# To update, run:
4+
#
5+
# pip-compile --generate-hashes docs/requirements.in
6+
#
7+
alabaster==0.7.12 \
8+
--hash=sha256:446438bdcca0e05bd45ea2de1668c1d9b032e1a9154c2c259092d77031ddd359 \
9+
--hash=sha256:a661d72d58e6ea8a57f7a86e37d86716863ee5e92788398526d58b26a4e4dc02 \
10+
# via sphinx
11+
babel==2.9.0 \
12+
--hash=sha256:9d35c22fcc79893c3ecc85ac4a56cde1ecf3f19c540bba0922308a6c06ca6fa5 \
13+
--hash=sha256:da031ab54472314f210b0adcff1588ee5d1d1d0ba4dbd07b94dba82bde791e05 \
14+
# via sphinx
15+
certifi==2020.12.5 \
16+
--hash=sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c \
17+
--hash=sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830 \
18+
# via requests
19+
chardet==4.0.0 \
20+
--hash=sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa \
21+
--hash=sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5 \
22+
# via requests
23+
docutils==0.16 \
24+
--hash=sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af \
25+
--hash=sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc \
26+
# via sphinx
27+
fluent.pygments==1.0 \
28+
--hash=sha256:625c87a8a2362ef304146b161d359dcf652bed2a1ae4869b5607b8e06d117d97 \
29+
--hash=sha256:b44758f74f87e1aa9d78d8f53363962639c5bf99d88cf3e407d046b5249ec27f \
30+
# via -r docs/requirements.in
31+
fluent.syntax==0.18.1 \
32+
--hash=sha256:0e63679fa4f1b3042565220a5127b4bab842424f07d6a13c12299e3b3835486a \
33+
--hash=sha256:3a55f5e605d1b029a65cc8b6492c86ec4608e15447e73db1495de11fd46c104f \
34+
# via fluent.pygments
35+
idna==2.10 \
36+
--hash=sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6 \
37+
--hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0 \
38+
# via requests
39+
imagesize==1.2.0 \
40+
--hash=sha256:6965f19a6a2039c7d48bca7dba2473069ff854c36ae6f19d2cde309d998228a1 \
41+
--hash=sha256:b1f6b5a4eab1f73479a50fb79fcf729514a900c341d8503d62a62dbc4127a2b1 \
42+
# via sphinx
43+
jinja2==2.11.3 \
44+
--hash=sha256:03e47ad063331dd6a3f04a43eddca8a966a26ba0c5b7207a9a9e4e08f1b29419 \
45+
--hash=sha256:a6d58433de0ae800347cab1fa3043cebbabe8baa9d29e668f1c768cb87a333c6 \
46+
# via sphinx
47+
markupsafe==1.1.1 \
48+
--hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \
49+
--hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \
50+
--hash=sha256:09c4b7f37d6c648cb13f9230d847adf22f8171b1ccc4d5682398e77f40309235 \
51+
--hash=sha256:1027c282dad077d0bae18be6794e6b6b8c91d58ed8a8d89a89d59693b9131db5 \
52+
--hash=sha256:13d3144e1e340870b25e7b10b98d779608c02016d5184cfb9927a9f10c689f42 \
53+
--hash=sha256:195d7d2c4fbb0ee8139a6cf67194f3973a6b3042d742ebe0a9ed36d8b6f0c07f \
54+
--hash=sha256:22c178a091fc6630d0d045bdb5992d2dfe14e3259760e713c490da5323866c39 \
55+
--hash=sha256:24982cc2533820871eba85ba648cd53d8623687ff11cbb805be4ff7b4c971aff \
56+
--hash=sha256:29872e92839765e546828bb7754a68c418d927cd064fd4708fab9fe9c8bb116b \
57+
--hash=sha256:2beec1e0de6924ea551859edb9e7679da6e4870d32cb766240ce17e0a0ba2014 \
58+
--hash=sha256:3b8a6499709d29c2e2399569d96719a1b21dcd94410a586a18526b143ec8470f \
59+
--hash=sha256:43a55c2930bbc139570ac2452adf3d70cdbb3cfe5912c71cdce1c2c6bbd9c5d1 \
60+
--hash=sha256:46c99d2de99945ec5cb54f23c8cd5689f6d7177305ebff350a58ce5f8de1669e \
61+
--hash=sha256:500d4957e52ddc3351cabf489e79c91c17f6e0899158447047588650b5e69183 \
62+
--hash=sha256:535f6fc4d397c1563d08b88e485c3496cf5784e927af890fb3c3aac7f933ec66 \
63+
--hash=sha256:596510de112c685489095da617b5bcbbac7dd6384aeebeda4df6025d0256a81b \
64+
--hash=sha256:62fe6c95e3ec8a7fad637b7f3d372c15ec1caa01ab47926cfdf7a75b40e0eac1 \
65+
--hash=sha256:6788b695d50a51edb699cb55e35487e430fa21f1ed838122d722e0ff0ac5ba15 \
66+
--hash=sha256:6dd73240d2af64df90aa7c4e7481e23825ea70af4b4922f8ede5b9e35f78a3b1 \
67+
--hash=sha256:6f1e273a344928347c1290119b493a1f0303c52f5a5eae5f16d74f48c15d4a85 \
68+
--hash=sha256:6fffc775d90dcc9aed1b89219549b329a9250d918fd0b8fa8d93d154918422e1 \
69+
--hash=sha256:717ba8fe3ae9cc0006d7c451f0bb265ee07739daf76355d06366154ee68d221e \
70+
--hash=sha256:79855e1c5b8da654cf486b830bd42c06e8780cea587384cf6545b7d9ac013a0b \
71+
--hash=sha256:7c1699dfe0cf8ff607dbdcc1e9b9af1755371f92a68f706051cc8c37d447c905 \
72+
--hash=sha256:7fed13866cf14bba33e7176717346713881f56d9d2bcebab207f7a036f41b850 \
73+
--hash=sha256:84dee80c15f1b560d55bcfe6d47b27d070b4681c699c572af2e3c7cc90a3b8e0 \
74+
--hash=sha256:88e5fcfb52ee7b911e8bb6d6aa2fd21fbecc674eadd44118a9cc3863f938e735 \
75+
--hash=sha256:8defac2f2ccd6805ebf65f5eeb132adcf2ab57aa11fdf4c0dd5169a004710e7d \
76+
--hash=sha256:98bae9582248d6cf62321dcb52aaf5d9adf0bad3b40582925ef7c7f0ed85fceb \
77+
--hash=sha256:98c7086708b163d425c67c7a91bad6e466bb99d797aa64f965e9d25c12111a5e \
78+
--hash=sha256:9add70b36c5666a2ed02b43b335fe19002ee5235efd4b8a89bfcf9005bebac0d \
79+
--hash=sha256:9bf40443012702a1d2070043cb6291650a0841ece432556f784f004937f0f32c \
80+
--hash=sha256:a6a744282b7718a2a62d2ed9d993cad6f5f585605ad352c11de459f4108df0a1 \
81+
--hash=sha256:acf08ac40292838b3cbbb06cfe9b2cb9ec78fce8baca31ddb87aaac2e2dc3bc2 \
82+
--hash=sha256:ade5e387d2ad0d7ebf59146cc00c8044acbd863725f887353a10df825fc8ae21 \
83+
--hash=sha256:b00c1de48212e4cc9603895652c5c410df699856a2853135b3967591e4beebc2 \
84+
--hash=sha256:b1282f8c00509d99fef04d8ba936b156d419be841854fe901d8ae224c59f0be5 \
85+
--hash=sha256:b1dba4527182c95a0db8b6060cc98ac49b9e2f5e64320e2b56e47cb2831978c7 \
86+
--hash=sha256:b2051432115498d3562c084a49bba65d97cf251f5a331c64a12ee7e04dacc51b \
87+
--hash=sha256:b7d644ddb4dbd407d31ffb699f1d140bc35478da613b441c582aeb7c43838dd8 \
88+
--hash=sha256:ba59edeaa2fc6114428f1637ffff42da1e311e29382d81b339c1817d37ec93c6 \
89+
--hash=sha256:bf5aa3cbcfdf57fa2ee9cd1822c862ef23037f5c832ad09cfea57fa846dec193 \
90+
--hash=sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f \
91+
--hash=sha256:caabedc8323f1e93231b52fc32bdcde6db817623d33e100708d9a68e1f53b26b \
92+
--hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \
93+
--hash=sha256:cdb132fc825c38e1aeec2c8aa9338310d29d337bebbd7baa06889d09a60a1fa2 \
94+
--hash=sha256:d53bc011414228441014aa71dbec320c66468c1030aae3a6e29778a3382d96e5 \
95+
--hash=sha256:d73a845f227b0bfe8a7455ee623525ee656a9e2e749e4742706d80a6065d5e2c \
96+
--hash=sha256:d9be0ba6c527163cbed5e0857c451fcd092ce83947944d6c14bc95441203f032 \
97+
--hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \
98+
--hash=sha256:e8313f01ba26fbbe36c7be1966a7b7424942f670f38e666995b88d012765b9be \
99+
--hash=sha256:feb7b34d6325451ef96bc0e36e1a6c0c1c64bc1fbec4b854f4529e51887b1621 \
100+
# via jinja2
101+
packaging==20.9 \
102+
--hash=sha256:5b327ac1320dc863dca72f4514ecc086f31186744b84a230374cc1fd776feae5 \
103+
--hash=sha256:67714da7f7bc052e064859c05c595155bd1ee9f69f76557e21f051443c20947a \
104+
# via sphinx
105+
pygments==2.8.0 \
106+
--hash=sha256:37a13ba168a02ac54cc5891a42b1caec333e59b66addb7fa633ea8a6d73445c0 \
107+
--hash=sha256:b21b072d0ccdf29297a82a2363359d99623597b8a265b8081760e4d0f7153c88 \
108+
# via fluent.pygments, sphinx
109+
pyparsing==2.4.7 \
110+
--hash=sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1 \
111+
--hash=sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b \
112+
# via packaging
113+
pytz==2021.1 \
114+
--hash=sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da \
115+
--hash=sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798 \
116+
# via babel
117+
requests==2.25.1 \
118+
--hash=sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804 \
119+
--hash=sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e \
120+
# via sphinx
121+
six==1.15.0 \
122+
--hash=sha256:30639c035cdb23534cd4aa2dd52c3bf48f06e5f4a941509c8bafd8ce11080259 \
123+
--hash=sha256:8b74bedcbbbaca38ff6d7491d76f2b06b3592611af620f8426e82dddb04a5ced \
124+
# via fluent.pygments
125+
snowballstemmer==2.1.0 \
126+
--hash=sha256:b51b447bea85f9968c13b650126a888aabd4cb4463fca868ec596826325dedc2 \
127+
--hash=sha256:e997baa4f2e9139951b6f4c631bad912dfd3c792467e2f03d7239464af90e914 \
128+
# via sphinx
129+
sphinx==3.5.1 \
130+
--hash=sha256:11d521e787d9372c289472513d807277caafb1684b33eb4f08f7574c405893a9 \
131+
--hash=sha256:e90161222e4d80ce5fc811ace7c6787a226b4f5951545f7f42acf97277bfc35c \
132+
# via -r docs/requirements.in
133+
sphinxcontrib-applehelp==1.0.2 \
134+
--hash=sha256:806111e5e962be97c29ec4c1e7fe277bfd19e9652fb1a4392105b43e01af885a \
135+
--hash=sha256:a072735ec80e7675e3f432fcae8610ecf509c5f1869d17e2eecff44389cdbc58 \
136+
# via sphinx
137+
sphinxcontrib-devhelp==1.0.2 \
138+
--hash=sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e \
139+
--hash=sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4 \
140+
# via sphinx
141+
sphinxcontrib-htmlhelp==1.0.3 \
142+
--hash=sha256:3c0bc24a2c41e340ac37c85ced6dafc879ab485c095b1d65d2461ac2f7cca86f \
143+
--hash=sha256:e8f5bb7e31b2dbb25b9cc435c8ab7a79787ebf7f906155729338f3156d93659b \
144+
# via sphinx
145+
sphinxcontrib-jsmath==1.0.1 \
146+
--hash=sha256:2ec2eaebfb78f3f2078e73666b1415417a116cc848b72e5172e596c871103178 \
147+
--hash=sha256:a9925e4a4587247ed2191a22df5f6970656cb8ca2bd6284309578f2153e0c4b8 \
148+
# via sphinx
149+
sphinxcontrib-qthelp==1.0.3 \
150+
--hash=sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72 \
151+
--hash=sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6 \
152+
# via sphinx
153+
sphinxcontrib-serializinghtml==1.1.4 \
154+
--hash=sha256:eaa0eccc86e982a9b939b2b82d12cc5d013385ba5eadcc7e4fed23f4405f77bc \
155+
--hash=sha256:f242a81d423f59617a8e5cf16f5d4d74e28ee9a66f9e5b637a18082991db5a9a \
156+
# via sphinx
157+
urllib3==1.26.3 \
158+
--hash=sha256:1b465e494e3e0d8939b50680403e3aedaa2bc434b7d5af64dfd3c958d7f5ae80 \
159+
--hash=sha256:de3eedaad74a2683334e282005cd8d7f22f4d55fa690a2a1020a416cb0a47e73 \
160+
# via requests
161+
wheel==0.36.2 \
162+
--hash=sha256:78b5b185f0e5763c26ca1e324373aadd49182ca90e825f7853f4b2509215dc0e \
163+
--hash=sha256:e11eefd162658ea59a60a0f6c7d493a7190ea4b9a85e335b33489d9f17e0245e \
164+
# via -r docs/requirements.in
165+
166+
# WARNING: The following packages were not pinned, but pip requires them to be
167+
# pinned when the requirements file includes hashes. Consider using the --allow-unsafe flag.
168+
# setuptools

fluent.docs/README.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
``fluent.docs``
2+
===============
3+
4+
Python utilities used by the ``python-fluent`` documentation build
5+
process. The entry point is ``scripts/build-docs``.
6+
7+
The generated documentation is in ``_build/python-fluent``, and you
8+
can surf it locally via ``python3 -m http.server `` in ``_build``.
9+
10+
The documentation is created for each tagged version after May 2020,
11+
at which point we had good docs. The current branch (PR tips or
12+
master) is versioned as *dev*, and *stable* is a symlink to the latest
13+
release. The releases are in a dir with their corresponding version number.
14+
15+
When cutting a new release, manually run the documentation workflow
16+
to pick that up.
17+
18+
The rationale for regenerating all historic documentation releases is
19+
to provide an easy process to change style and renderering across
20+
the full documentation. For that, the build setup is taken from
21+
the current checkout, and release docs are generated from sources in
22+
a git worktree.

fluent.docs/fluent/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__('pkgutil').extend_path(__path__, __name__)

fluent.docs/fluent/docs/__init__.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from pathlib import Path
2+
from .build import DocBuilder
3+
4+
5+
def finalize_builddir(repo_name):
6+
'Bookkeeping on the docs build directory'
7+
root = Path('_build') / repo_name
8+
with open(root / '.nojekyll', 'w') as fh:
9+
fh.write('')
10+
11+
12+
def build_root(repo_name):
13+
'''Build the top-level documentation.
14+
15+
See :py:mod:`.build` on building sub-projects.
16+
'''
17+
with DocBuilder(repo_name, '.') as builder:
18+
builder.build()

0 commit comments

Comments
 (0)