1717import os
1818import sys
1919from pathlib import Path
20+ from typing import Any
2021
2122from sphinx .application import Sphinx
2223
4041# We add stable as current version, we might add the version switch in the future
4142tags .add ("stable" ) # type: ignore
4243
43- # The short X.Y version.
44- version = "." .join (pyagentspec .__version__ .split ("." )[:2 ])
45-
4644# The full version, including alpha/beta/rc tags.
4745release = pyagentspec .__version__
4846
5149if stable_release is None :
5250 raise Exception ("Error: STABLE_RELEASE environment variable is not set." )
5351
52+ docs_version = os .getenv ("DOCS_VERSION" )
53+
54+ if not docs_version :
55+ if any (x in release for x in (".dev" , "a" , "b" , "rc" )):
56+ docs_version = "dev"
57+ else :
58+ docs_version = stable_release
59+
5460# -- General configuration ---------------------------------------------------
5561
5662# Add any Sphinx extension module names here, as strings. They can be
148154 "pygments_light_style" : "xcode" , # for light mode
149155 "pygments_dark_style" : "monokai" , # for dark mode
150156 "navbar_align" : "left" ,
151- "navbar_start" : ["navbar-logo" ],
157+ "navbar_start" : ["navbar-logo" , "version-switcher" ],
158+ "switcher" : {
159+ "json_url" : "https://oracle.github.io/agent-spec/switcher.json" ,
160+ "version_match" : docs_version ,
161+ },
152162 "navbar_center" : [
153163 "navbar-new"
154164 ], # Custom top navigation - defined in the template, navbar-new.html, in the _templates dir.
179189copybutton_prompt_is_regexp = True
180190
181191
182- def autodoc_skip_member (app : Sphinx , what , name , obj , skip , options ):
192+ def autodoc_skip_member (app : Sphinx , what , name , obj , skip , options ): # type: ignore
183193 """
184194 Skips showing an attribute as a member if it is already in the list of parameters.
185195 This prevents duplicated fields in Pydantic / dataclasses.
@@ -191,7 +201,7 @@ def autodoc_skip_member(app: Sphinx, what, name, obj, skip, options):
191201 return skip
192202
193203
194- def setup (app : Sphinx ):
204+ def setup (app : Sphinx ) -> dict [ str , Any ] :
195205 app .connect ("autodoc-skip-member" , autodoc_skip_member )
196206 app .add_js_file ("js/fix-navigation.js" )
197207
0 commit comments