Skip to content

Commit 3186ccb

Browse files
committed
stale switcher remover
1 parent 7582457 commit 3186ccb

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

run.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,13 @@ def _run_sphinx_build(target):
570570
)
571571

572572

573+
def _remove_stale_switcher():
574+
"""Remove any leftover switcher.json so a single-version build doesn't ship stale data."""
575+
if os.path.exists(SWITCHER_JSON):
576+
os.remove(SWITCHER_JSON)
577+
logging.info('Removed stale %s', SWITCHER_JSON)
578+
579+
573580
# pylint: disable=R0912
574581
def build_docs(
575582
target, skip_build, local=False, skip_switcher=False, include_current=False, incremental=False
@@ -606,6 +613,7 @@ def build_docs(
606613
'No version tags starting with \'v\' found in the repository. '
607614
'Falling back to a single-version documentation build.'
608615
)
616+
_remove_stale_switcher()
609617
_run_sphinx_build(target)
610618
else:
611619
if target == 'html' and not skip_switcher:
@@ -616,6 +624,7 @@ def build_docs(
616624
'No version tags starting with \'v\' found in the repository. '
617625
'Skipping switcher.json generation.'
618626
)
627+
_remove_stale_switcher()
619628
_run_sphinx_build(target)
620629
logging.info('Sphinx documentation built successfully.')
621630
except Exception as err:

0 commit comments

Comments
 (0)