Skip to content
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Then open http://localhost:8000 in your browser. The root automatically redirect
- A `/latest/` directory points to the newest version
- Root (`/`) automatically redirects to `/latest/`
- Run `git fetch --tags` before building to ensure all version tags are available
- If no version tags (tags starting with `v`) are found in the repository, the build automatically falls back to a single-version Sphinx build instead of attempting the multi-version build
Comment thread
sankalps0549 marked this conversation as resolved.
Outdated
Comment thread
sankalps0549 marked this conversation as resolved.
Outdated

### Running the Formatter

Expand Down
3 changes: 3 additions & 0 deletions docs/source/readme.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,9 @@ Then open http://localhost:8000 in your browser.
- A ``/latest/`` directory points to the newest version (symlink on Unix, copy on Windows)
- Root (``/``) automatically redirects to ``/latest/`` for convenience
- Version switcher dropdown in the navigation bar allows switching between versions
- If no version tags (tags starting with ``v``) are found in the repository, the build
automatically falls back to a single-version Sphinx build instead of attempting the
multi-version build
Comment thread
sankalps0549 marked this conversation as resolved.
Outdated

Contributing
============
Expand Down
32 changes: 18 additions & 14 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,14 @@ def _build_html_docs_incremental(build_output, skip_switcher, include_current):


# pylint: disable=R0913, R0917
def _run_sphinx_build(target):
"""Run a standard single-version Sphinx build."""
run_command(
[sys.executable, '-m', 'sphinx', 'build', '-M', target, DOCS_SOURCE_DIR, DOCS_BUILD_DIR],
ROOT_DIR,
)


def build_docs(
target, skip_build, local=False, skip_switcher=False, include_current=False, incremental=False
):
Expand All @@ -580,7 +588,9 @@ def build_docs(
logging.info('Incremental build mode: preserving existing documentation...')

try:
if target == 'html' and not local:
has_version_tags = any(tag.name.startswith('v') for tag in GIT_REPO.tags)

if target == 'html' and not local and has_version_tags:
build_output = os.path.join(DOCS_BUILD_DIR, 'html')
Comment thread
sankalps0549 marked this conversation as resolved.
Outdated

if incremental:
Expand All @@ -590,22 +600,16 @@ def build_docs(

create_latest_alias(build_output)
create_root_redirect(build_output)
elif target == 'html' and not local and not has_version_tags:
logging.warning(
'No version tags found in the repository. '
Comment thread
sankalps0549 marked this conversation as resolved.
Outdated
'Falling back to a single-version documentation build.'
)
_run_sphinx_build(target)
Comment thread
sankalps0549 marked this conversation as resolved.
Comment thread
sankalps0549 marked this conversation as resolved.
Comment thread
sankalps0549 marked this conversation as resolved.
else:
if target == 'html' and not skip_switcher:
generate_switcher(include_current=include_current)
Comment thread
sankalps0549 marked this conversation as resolved.
Outdated
run_command(
[
sys.executable,
'-m',
'sphinx',
'build',
'-M',
target,
DOCS_SOURCE_DIR,
DOCS_BUILD_DIR,
],
ROOT_DIR,
)
_run_sphinx_build(target)
logging.info('Sphinx documentation built successfully.')
except Exception as err:
logging.error(
Expand Down
Loading