Skip to content

Commit 6a3de78

Browse files
author
William Roberts
committed
sphinx: add post build script
scripts/docs.sh was running sphinx build and then a custom post-process command. Move this post-process command into a seperate script that is invoked through the API extensions built into sphinx. This way servers like ReadTheDocs can get the invocation. This approach was discussed here: - readthedocs/readthedocs.org#2276 Then modified for our purposes. Signed-off-by: William Roberts <[email protected]>
1 parent 648697a commit 6a3de78

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.readthedocs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
33

44
version: 2
5+
6+
# stable is ubuntu-18.04 image
7+
# - https://hub.docker.com/r/readthedocs/build/
8+
build:
9+
image: stable
10+
511
sphinx:
612
builder: html
713
configuration: docs/conf.py

docs/conf.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import os
1414
import sys
1515
import datetime
16+
import subprocess
1617

1718
from setuptools_scm import get_version
1819

@@ -86,3 +87,14 @@
8687
# directories to ignore when looking for source files.
8788
# This pattern also affects html_static_path and html_extra_path.
8889
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
90+
91+
def builder_finished_handler(app, exception):
92+
if exception is None:
93+
subprocess.check_call('docs/sphinx-finished.sh', shell=True)
94+
95+
#
96+
# Hook the setup of readthedocs so we can hook into events as defined in:
97+
# - https://www.sphinx-doc.org/en/master/extdev/appapi.html
98+
#
99+
def setup(app):
100+
app.connect('build-finished', builder_finished_handler)

docs/sphinx-finished.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# SPDX-License-Identifier: BSD-3
3+
4+
#
5+
# This script is configured to run as part of the sphinx build
6+
# through API events registered in conf.py.
7+
# This script runs on event build-finished.
8+
#
9+
# This would be better served by handling the events
10+
# html-collect-page --> for add .nojekyll
11+
# html-page-context --> for fixing the span's done with sed.
12+
#
13+
# For the case of time, we just left this script as is and run it as a
14+
# post sphinx build command event :-p
15+
#
16+
17+
set -eo pipefail
18+
19+
find pages/ -name \*.html -exec \
20+
sed -i 's/<span class="gp">\&gt;\&gt;\&gt; <\/span>//g' {} \;
21+
touch pages/.nojekyll
22+
23+
exit 0

scripts/docs.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
#!/usr/bin/env sh
2+
# SPDX-License-Identifier: BSD-3
23
set -e
34

4-
rm -rf pages
55
sphinx-build -W -b html docs pages
6-
find pages/ -name \*.html -exec \
7-
sed -i 's/<span class="gp">\&gt;\&gt;\&gt; <\/span>//g' {} \;
8-
touch pages/.nojekyll

0 commit comments

Comments
 (0)