Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:

steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history and tags

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/source/_static/switcher.json

# PyBuilder
.pybuilder/
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,17 @@ python run.py build
python run.py build-docs
```

> ***Note: When releasing a new version, update ``switcher.json`` in ``docs/source/_static/`` to include the new tag in the version dropdown for documentation.***
The documentation version switcher (`switcher.json`) is automatically generated from git tags and `version.json` during the build process.

Options:
- `--skip-build` (`-s`): Skip building before generating docs
- `--local` (`-l`): Build documentation locally for a single version (skips multi-version build)
- `--skip-switcher`: Skip generating switcher.json (useful for offline builds or custom switcher configurations)

**Debug command:** To manually generate `switcher.json` without building docs:
```sh
python run.py generate-switcher
```

The documentation can be accessed locally by serving the docs/build/html/ folder:
```sh
Expand Down
44 changes: 0 additions & 44 deletions docs/source/_static/switcher.json

This file was deleted.

5 changes: 3 additions & 2 deletions docs/source/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1259,10 +1259,11 @@ The project includes a ``run.py`` script with several useful commands:

- ``--skip-build`` (``-s``): Skip building the package before generating docs
- ``--local`` (``-l``): Build documentation locally for a single version (skips multi-version build)
- ``--skip-switcher``: Skip generating switcher.json (useful for offline builds or custom switcher configurations)

.. note::
When releasing a new version, update ``switcher.json`` in ``docs/source/_static/``
to include the new tag in the version dropdown.
The documentation version switcher (``switcher.json``) is automatically generated from
git tags and ``version.json`` during the build process.

**Viewing Documentation Locally**

Expand Down
24 changes: 22 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
run.py clean-up
run.py build [-P | --publish] [-i | --install]
run.py build-docs [-t <target> | --target=<target>] [-s | --skip-build] [-l | --local]
[--skip-switcher]
run.py format [--check]
run.py generate-expected-data [<markers>...]
run.py generate-switcher
run.py install [-s | --skip-build]
run.py install-package-requirements
run.py lint [-s | --skip-build]
Expand All @@ -25,6 +27,7 @@
build-docs Build the documentation.
format Format all Python files in the repository using black.
generate-expected-data Generate expected data for integration tests.
generate-switcher Generate switcher.json from git tags.
install Install the moldflow-api package.
install-package-requirements Install package dependencies.
lint Lint all Python files in the repository.
Expand Down Expand Up @@ -54,6 +57,7 @@
--repo-url=<url> Custom PyPI repository URL.
--github-api-url=<url> Custom GitHub API URL.
-l, --local Build documentation locally (single version).
--skip-switcher Skip generating switcher.json for documentation.
<markers> Markers to filter data generation by: mesh_summary, etc.
"""

Expand Down Expand Up @@ -402,7 +406,7 @@ def version_key(v):
shutil.copytree(latest_src, latest_dest)


def build_docs(target, skip_build, local=False):
def build_docs(target, skip_build, local=False, skip_switcher=False):
"""Build Documentation"""

if not skip_build:
Expand All @@ -416,6 +420,9 @@ def build_docs(target, skip_build, local=False):

try:
if target == 'html' and not local:
# Generate switcher.json for docs versioning dropdown from git tags and version.json
if not skip_switcher:
generate_switcher()
Comment on lines 422 to +425
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build_docs() only generates switcher.json when target == 'html' and not local, but this PR also removes the committed docs/source/_static/switcher.json (and .gitignores it). As a result, run.py build-docs --local will produce HTML without _static/switcher.json, breaking the version switcher configured in docs/source/conf.py. Consider generating the switcher for local HTML builds too (unless --skip-switcher is set), or update the docs config to use a remote json_url for local builds.

Copilot uses AI. Check for mistakes.
build_output = os.path.join(DOCS_BUILD_DIR, 'html')
try:
# fmt: off
Expand Down Expand Up @@ -688,6 +695,13 @@ def generate_expected_data(markers: list[str]):
run_command([sys.executable, '-m', generate_data_module] + markers, ROOT_DIR)


def generate_switcher():
"""Generate switcher.json from git tags"""
logging.info('Generating switcher.json from git tags')
switcher_script = os.path.join(ROOT_DIR, 'scripts', 'generate_switcher.py')
run_command([sys.executable, switcher_script], ROOT_DIR)


def set_version():
"""Set current version and write version file to package directory"""

Expand Down Expand Up @@ -734,6 +748,9 @@ def main():
markers = args.get('<markers>') or []
generate_expected_data(markers=markers)

elif args.get('generate-switcher'):
generate_switcher()

elif args.get('test'):
tests = args.get('<tests>') or []
marker = args.get('--marker') or args.get('-m')
Expand Down Expand Up @@ -779,8 +796,11 @@ def main():
target = args.get('--target') or args.get('-t') or 'html'
skip_build = args.get('--skip-build') or args.get('-s')
local = args.get('--local') or args.get('-l')
skip_switcher = args.get('--skip-switcher')

build_docs(target=target, skip_build=skip_build, local=local)
build_docs(
target=target, skip_build=skip_build, local=local, skip_switcher=skip_switcher
)

elif args.get('install-package-requirements'):
install_package(target_path=os.path.join(ROOT_DIR, SITE_PACKAGES))
Expand Down
Loading