Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 15a1d44

Browse files
committed
Don't check switcher if not published
- pydata-sphinx-theme 0.11 started checking switcher - this meant you couldn't bootstrap a gh-pages build - pydata-sphinx-theme 0.12 put in an option not to check - but we want checking if the file exists - so only check if we can get the json file - and suggest user turns pages on if we can't
1 parent 7383739 commit 15a1d44

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

docs/conf.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
# list see the documentation:
55
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

7+
import sys
78
from pathlib import Path
89
from subprocess import check_output
910

11+
import requests
12+
1013
import python3_pip_skeleton
1114

1215
# -- General configuration ------------------------------------------------
@@ -126,6 +129,17 @@
126129
html_theme = "pydata_sphinx_theme"
127130
github_repo = project
128131
github_user = "DiamondLightSource"
132+
switcher_json = f"https://{github_user}.github.io/{github_repo}/switcher.json"
133+
# Don't check switcher if it doesn't exist, but warn in a non-failing way
134+
check_switcher = requests.get(switcher_json).ok
135+
if not check_switcher:
136+
print(
137+
"*** Can't read version switcher, is GitHub pages enabled? \n"
138+
" Once Docs CI job has successfully run once, set the "
139+
"Github pages source branch to be 'gh-pages' at:\n"
140+
f" https://github.com/{github_user}/{github_repo}/settings/pages",
141+
file=sys.stderr,
142+
)
129143

130144
# Theme options for pydata_sphinx_theme
131145
html_theme_options = dict(
@@ -142,9 +156,10 @@
142156
)
143157
],
144158
switcher=dict(
145-
json_url=f"https://{github_user}.github.io/{github_repo}/switcher.json",
159+
json_url=switcher_json,
146160
version_match=version,
147161
),
162+
check_switcher=check_switcher,
148163
navbar_end=["theme-switcher", "icon-links", "version-switcher"],
149164
external_links=[
150165
dict(

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dev = [
2929
"Flake8-pyproject",
3030
"pipdeptree",
3131
"pre-commit",
32-
"pydata-sphinx-theme",
32+
"pydata-sphinx-theme>=0.12",
3333
"pytest-cov",
3434
"sphinx-autobuild",
3535
"sphinx-copybutton",

0 commit comments

Comments
 (0)