Skip to content

Commit 852e930

Browse files
committed
Fix documentation build system branch handling
This commit fixes how the documentation build system handles different branch types during sphinx-versioned multi-version builds. Changes: 1. conf.py: Fixed branch detection logic to properly distinguish between release branches (which have committed JSON snapshots) and all other branches (which use downloaded master JSON files). Also removed unused 'release' variable. 2. python_sphinx_docs.yml: Added comprehensive documentation explaining why JSON files are downloaded to master-tmp/ directory and how this supports multi-version documentation builds. The previous logic incorrectly assumed only the master branch should use downloaded files, causing development branches to fail when looking for non-existent committed files. Now all non-release branches correctly use the downloaded master JSON files.
1 parent 38fb045 commit 852e930

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

.github/workflows/python_sphinx_docs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ jobs:
2222
- name: Create tmp directories for master
2323
run: |
2424
mkdir python/master-tmp
25+
# Download master JSON files to master-tmp/ directory
26+
# This supports sphinx-versioned multi-version documentation builds:
27+
# - sphinx-versioned builds docs for multiple branches (master, release-*, current branch)
28+
# - Each branch version looks for JSON files in different locations (see conf.py)
29+
# - master-tmp/ provides a shared location for current master JSON files that doesn't
30+
# interfere with committed release snapshots in python/ directory
2531
- name: Get docstrings_common.json from master branch of opm-common
2632
run: |
2733
curl -L -o python/master-tmp/docstrings_common.json https://raw.githubusercontent.com/OPM/opm-common/master/python/docstrings_common.json

python/sphinx_docs/docs/conf.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,21 @@ def extract_opm_simulators_release(version_file_path):
2424
except Exception:
2525
return "unknown" # Fallback version
2626

27+
# Determine JSON file location based on branch type
28+
# This prefix is used to set opm_simulators_docstrings_path and opm_common_docstrings_path below,
29+
# which are passed through Sphinx's config system to the sphinx_ext_docstrings extension.
30+
# The extension reads these paths to load JSON files and generate documentation.
31+
#
32+
# Branch handling for sphinx-versioned multi-version builds:
33+
# - Release branches (release-*): Use committed JSON snapshots in python/
34+
# - All other branches: Use downloaded master JSON files in python/master-tmp/
35+
# This includes master itself and development branches, ensuring they all use
36+
# the latest master JSON files without interfering with release snapshots.
2737
branch = get_git_branch()
28-
print(branch)
29-
if branch == "master":
30-
prefix = "../../master-tmp"
31-
else:
38+
if branch.startswith("release-"):
3239
prefix = "../../"
33-
release = extract_opm_simulators_release(os.path.join(prefix, "dune.module"))
40+
else:
41+
prefix = "../../master-tmp"
3442

3543
# -- General configuration ---------------------------------------------------
3644
import sys

0 commit comments

Comments
 (0)