Skip to content

Commit ce96e8d

Browse files
committed
use again sphinx-multiversion
1 parent c00781b commit ce96e8d

File tree

4 files changed

+25
-68
lines changed

4 files changed

+25
-68
lines changed

.github/workflows/build-docs.yaml

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -48,44 +48,15 @@ jobs:
4848
poetry install --with docs
4949
5050
- name: Test documentation build
51-
if: github.event_name == 'pull_request' && github.base_ref == 'dev'
51+
# if: github.event_name == 'pull_request' && github.base_ref == 'dev'
5252
run: |
5353
echo "Testing documentation build for PR..."
54-
poetry run sphinx-build docs/source docs/build/html
54+
make test-docs
5555
56-
- name: Generate missing tags list
57-
# if: github.event_name == 'push' || github.event_name == 'release'
58-
id: missing_tags
56+
- name: build multiversion documentation
57+
# if: ${{ github.ref == 'refs/heads/dev' }}
5958
run: |
60-
# Fetch existing documentation versions from gh-pages
61-
mkdir -p existing_versions
62-
git fetch origin gh-pages --depth=1
63-
git checkout origin/gh-pages -- versions || true
64-
65-
# List existing tags and built versions
66-
EXISTING_VERSIONS=$(ls versions | tr '\n' ' ')
67-
ALL_TAGS=$(git tag --list "v*" | tr '\n' ' ')
68-
69-
# Find missing tags
70-
MISSING_TAGS=""
71-
for TAG in $ALL_TAGS; do
72-
if [[ ! " $EXISTING_VERSIONS " =~ " $TAG " ]]; then
73-
MISSING_TAGS+="$TAG "
74-
fi
75-
done
76-
77-
echo "Missing tags: $MISSING_TAGS"
78-
echo "missing_tags=${MISSING_TAGS}" >> $GITHUB_ENV
79-
80-
- name: Build documentation for missing tags
81-
if: env.missing_tags != ''
82-
run: |
83-
for TAG in ${{ env.missing_tags }}; do
84-
echo "Building docs for $TAG..."
85-
git checkout $TAG
86-
mkdir -p docs/build/versions/$TAG
87-
poetry run sphinx-build docs/source docs/build/versions/$TAG
88-
done
59+
make multi-version-docs
8960
9061
- name: Build documentation for dev branch
9162
# if: github.ref == 'refs/heads/dev'
@@ -101,36 +72,3 @@ jobs:
10172
publish_dir: docs/build/versions
10273
destination_dir: versions
10374
keep_files: true
104-
105-
update-static:
106-
name: Update Static Files in Old Releases
107-
runs-on: ubuntu-latest
108-
needs: build-docs
109-
110-
steps:
111-
- name: Checkout gh-pages branch
112-
uses: actions/checkout@v4
113-
with:
114-
ref: gh-pages
115-
fetch-depth: 0
116-
117-
- name: Update _static in all versions
118-
run: |
119-
# Define path to the updated _static directory
120-
UPDATED_STATIC_DIR=versions/dev/_static
121-
TARGET_STATIC_DIRS=$(find versions/ -type d -name "_static")
122-
123-
# Copy updated _static to all versions
124-
for DIR in $TARGET_STATIC_DIRS; do
125-
echo "Updating $DIR..."
126-
cp -r ${UPDATED_STATIC_DIR}/* ${DIR}/ || true
127-
done
128-
129-
- name: Commit and push changes
130-
run: |
131-
git add .
132-
git commit -m "Update _static files in all documentation versions" || echo "No changes to commit"
133-
git push
134-
# with:
135-
# github_token: ${{ github.token }}
136-

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,17 @@ docs:
3131
$(poetry) python -m sphinx build -b html docs/source docs/build/html
3232

3333
.PHONY: test-docs
34-
test-docs: docs
34+
test-docs:
3535
$(poetry) python -m sphinx build -b doctest docs/source docs/build/html
3636

3737
.PHONY: serve-docs
3838
serve-docs: docs
3939
$(poetry) python -m http.server -d docs/build/html 8333
4040

41+
.PHONY: multi-version-docs
42+
multi-version-docs:
43+
$(poetry) sphinx-multiversion docs/source docs/build/html
44+
4145
.PHONY: clean-docs
4246
clean-docs:
4347
rm -rf docs/build

docs/source/conf.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"sphinx_copybutton",
4747
"nbsphinx",
4848
"sphinx.ext.intersphinx",
49+
"sphinx_multiversion",
4950
]
5051

5152
templates_path = ["_templates"]
@@ -144,6 +145,19 @@
144145

145146
mathjax_path = "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"
146147

148+
# sphinx_multiversion
149+
# Whitelist for tags matching v1.0.0, v2.1.0 format
150+
smv_tag_whitelist = r'^v\d+\.\d+\.\d+$'
151+
152+
# Whitelist for the dev branch
153+
smv_branch_whitelist = r'^dev$'
154+
155+
# Output format (keeping your current format)
156+
smv_outputdir_format = 'versions/{config.version}'
157+
158+
# Include both tags and dev branch as released
159+
smv_released_pattern = r'^(refs/tags/.*|refs/heads/dev)$'
160+
147161
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', "..")) # if conf.py is in docs/
148162
def setup(app) -> None: # noqa: ANN001
149163
generate_versions_json(app, repo_root, BASE_URL)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ sphinx-autodoc-typehints = "^2.5.0"
9595
sphinx-copybutton = "^0.5.2"
9696
sphinx-autoapi = "^3.3.3"
9797
ipykernel = "^6.29.5"
98+
sphinx-multiversion = "^0.2.4"
9899

99100
[tool.poetry.scripts]
100101
"autointent" = "autointent._pipeline._cli_endpoint:optimize"

0 commit comments

Comments
 (0)