Skip to content

Instantly share code, notes, and snippets.

@xenophonf
Created August 11, 2025 01:39
Show Gist options
  • Select an option

  • Save xenophonf/785f9ae4b9377c0eefb6c6b02e4f634b to your computer and use it in GitHub Desktop.

Select an option

Save xenophonf/785f9ae4b9377c0eefb6c6b02e4f634b to your computer and use it in GitHub Desktop.
An unfinished idea I had to generate documentation for tagged releases and extant feature branches
# This was inspired by https://www.codingwiththomas.com/blog/my-sphinx-best-practice-for-a-multiversion-documentation-in-different-languages.
# However, I'm taking a different approach.
# Generate documentation for tagged releases and extant feature
# branches. Take care to handle remote branches, too, not just local
# branches or local remote-tracking branches. However, do not alter
# the working directory in any way.
docs: $(LOCALES) | $(PYPACKAGE_NAME).egg-info
# Create missing remote-tracking branches.
LOCAL_BRANCHES=$$(git branch \
| grep -E -v '^..(HEAD|gh-pages|main|master|releases?(/.*)?)$$' \
| cut -c 3-); \
REMOTE_BRANCHES=$$(git branch -r \
| grep -E -v '^.*/(HEAD|gh-pages|main|master|releases?(/.*)?)$$' \
| cut -c 3-); \
for rb in $$REMOTE_BRANCHES; do \
lb=`echo $$rb | sed -e 's|[^/]*/||'`; \
echo $$LOCAL_BRANCHES | grep ^$$lb\$$ > /dev/null \
|| git branch $$lb $$rb; \
done
# Copy the repository to a temporary directory. Stash the Sphinx
# configuration from the current working directory for use later.
$(eval TMP := $(shell mktemp -d))
echo The temporary directory: $(TMP)
git clone --mirror . $(TMP)/.git
cp docs/conf.py $(TMP)/.git
# For each version and translation...
cd $(TMP); \
VERSIONS=$$(git tag | sort -r; git branch \
| grep -E -v '^..(HEAD|gh-pages|main|master|releases?(/.*)?)$$' \
| cut -c 3-); \
for v in $$VERSIONS; do \
env GIT_WORK_TREE=. git checkout $$v; \
i=0; \
for l in $(TRANSLATIONS); do \
((i++)); \
if [ $$i -gt 1 -a -f docs/_locale/$$l ]; then \
echo "{
# Clean up.
rm -rf $(TMP)
# $(foreach l,$(TRANSLATIONS), \
# $(SPHINXMULTI) -D language="$(l)" docs build/html/$(l))
# env LATEST_VERSION=`git describe --tag --abbrev=0` \
# envsubst < docs/.index.html > build/html/index.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment