|
6 | 6 | # full list see the documentation: |
7 | 7 | # http://www.sphinx-doc.org/en/master/config |
8 | 8 |
|
| 9 | +import os |
| 10 | + |
9 | 11 | # -- Path setup -------------------------------------------------------------- |
10 | 12 |
|
11 | 13 | # If extensions (or modules to document with autodoc) are in another directory, |
|
23 | 25 | copyright = "2024, Universal Robots A/S" |
24 | 26 | author = "Universal Robots A/S" |
25 | 27 |
|
26 | | -# The short X.Y version |
27 | | -version = "" |
| 28 | +# The short X.Y version (shown in the sidebar; per-distro label) |
28 | 29 | # The full version, including alpha/beta/rc tags |
29 | 30 | release = "0.1" |
30 | 31 |
|
|
58 | 59 | master_doc = "index" |
59 | 60 | numfig = True |
60 | 61 |
|
61 | | -ros_distro = "rolling" |
62 | | -distro_title = "Rolling" |
63 | | -distro_title_full = "Rolling Ridley" |
64 | | -repos_file_branch = "main" |
| 62 | +# ROS 2 distribution for this HTML build: humble | jazzy | kilted | rolling |
| 63 | +# Set by scripts/build_docs.sh (or export ROS_DISTRO=... before sphinx-build). |
| 64 | +ros_distro = os.environ.get("ROS_DISTRO", "rolling").lower() |
| 65 | + |
| 66 | +_distro_meta = { |
| 67 | + # "humble": ("Humble", "Humble Hawksbill"), |
| 68 | + "jazzy": ("Jazzy", "Jazzy Jalisco"), |
| 69 | + "kilted": ("Kilted", "Kilted Kaiju"), |
| 70 | + "rolling": ("Rolling", "Rolling Ridley"), |
| 71 | +} |
| 72 | +if ros_distro not in _distro_meta: |
| 73 | + raise ValueError( |
| 74 | + f"Unknown ROS_DISTRO={ros_distro!r}; expected one of: {', '.join(sorted(_distro_meta))}" |
| 75 | + ) |
| 76 | +distro_title, distro_title_full = _distro_meta[ros_distro] |
| 77 | +version = distro_title |
| 78 | + |
| 79 | +# Branch of *this* documentation repo for "Edit on GitHub" links |
| 80 | +repos_file_branch = os.environ.get("DOCUMENTATION_GIT_BRANCH", "main") |
| 81 | + |
| 82 | +# Pairs (slug, label) for the floating version switcher (paths under _build/html/) |
| 83 | +_DOCUMENTATION_VERSION_SLUGS = ( |
| 84 | + # ("humble", "Humble"), |
| 85 | + ("jazzy", "Jazzy"), |
| 86 | + ("kilted", "Kilted"), |
| 87 | + ("rolling", "Rolling"), |
| 88 | +) |
65 | 89 |
|
66 | 90 | # The language for content autogenerated by Sphinx. Refer to documentation |
67 | 91 | # for a list of supported languages. |
|
93 | 117 | # Theme options are theme-specific and customize the look and feel of a theme |
94 | 118 | # further. For a list of options available for each theme, see the |
95 | 119 | # documentation. |
96 | | -# |
97 | | -# html_theme_options = {} |
98 | | - |
99 | 120 | # Add any paths that contain custom static files (such as style sheets) here, |
100 | 121 | # relative to this directory. They are copied after the builtin static files, |
101 | 122 | # so a file named "default.css" will overwrite the builtin "default.css". |
|
216 | 237 | ] |
217 | 238 |
|
218 | 239 | github_url = "https://github.com/UniversalRobots/Universal_Robots_ROS_Documentation" |
| 240 | + |
| 241 | + |
| 242 | +def _html_page_context(app, pagename, templatename, context, doctree): |
| 243 | + """Relative links to the same page under other distro output directories.""" |
| 244 | + depth = 1 + pagename.count("/") |
| 245 | + prefix = "../" * depth |
| 246 | + context["versions"] = [ |
| 247 | + (label, f"{prefix}{slug}/{pagename}.html") |
| 248 | + for slug, label in _DOCUMENTATION_VERSION_SLUGS |
| 249 | + ] |
| 250 | + context["current_version"] = distro_title |
| 251 | + |
| 252 | + |
| 253 | +def setup(app): |
| 254 | + app.connect("html-page-context", _html_page_context) |
| 255 | + return {"parallel_read_safe": True, "parallel_write_safe": True} |
0 commit comments