File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919
2020DEFAULT_SWITCHER_URL = f"https://libhal.github.io/api/{ LIBRARY_NAME } /switcher.json"
2121
22- if os .environ .get ('LIBHAL_LOCAL_BUILD' ):
23- switcher_path = Path ('_static' ) / 'switcher.json'
24- switcher_path .write_text (
25- json .dumps ([{"version" : API_VERSION , "url" : "." }]))
26- switcher_url = "_static/switcher.json"
22+ LOCAL_BUILD = os .environ .get ('LIBHAL_LOCAL_BUILD' )
23+
24+ if LOCAL_BUILD :
25+ switcher_url = "switcher.json"
2726else :
2827 switcher_url = DEFAULT_SWITCHER_URL
2928
4443extensions = ["breathe" , "myst_parser" ]
4544
4645
46+ def write_local_switcher (app , exception ):
47+ if LOCAL_BUILD and exception is None :
48+ outdir = Path (app .outdir )
49+ (outdir / 'switcher.json' ).write_text (
50+ json .dumps ([{"version" : API_VERSION , "url" : "." }]))
51+
52+
4753def setup (app : Sphinx ):
4854 app .add_css_file ("extra.css" )
55+ app .connect ("build-finished" , write_local_switcher )
4956
5057
5158html_css_files = [
You can’t perform that action at this time.
0 commit comments