|
2 | 2 | # |
3 | 3 | # For the full list of built-in configuration values, see the documentation: |
4 | 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html |
| 5 | +from docutils import nodes |
| 6 | +from sphinx.application import Sphinx |
5 | 7 |
|
6 | 8 | # -- Project information ----------------------------------------------------- |
7 | 9 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information |
|
18 | 20 | templates_path = ['_templates'] |
19 | 21 | exclude_patterns = [] |
20 | 22 |
|
| 23 | +html_sidebars = { |
| 24 | + "**": [ |
| 25 | + "globaltoc.html", # Site contents |
| 26 | + "localtoc.html", # Page contents |
| 27 | + ] |
| 28 | +} |
| 29 | + |
21 | 30 |
|
22 | 31 |
|
23 | 32 | # -- Options for HTML output ------------------------------------------------- |
|
62 | 71 | 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/languages/python.min.js', |
63 | 72 | 'https://unpkg.com/@highlightjs/cdn-assets@11.11.1/languages/yaml.min.js', |
64 | 73 | ] |
| 74 | + |
| 75 | + |
| 76 | +# Coloured inline roles for the SOAP property table. |
| 77 | +def _highlight_role(background): |
| 78 | + """Return a docutils role function that wraps text in a highlighted <span>.""" |
| 79 | + |
| 80 | + def role(name, rawtext, text, lineno, inliner, options=None, content=None): |
| 81 | + style = ( |
| 82 | + f"background-color: {background};" |
| 83 | + " color: black;" |
| 84 | + " padding: 1px 4px;" |
| 85 | + " border-radius: 3px;" |
| 86 | + " font-family: monospace;" |
| 87 | + ) |
| 88 | + html = f'<span style="{style}">{text}</span>' |
| 89 | + # raw() node so the HTML passes through unchanged; latex() node is a |
| 90 | + # plain-text fallback for PDF builds. |
| 91 | + node = nodes.raw("", html, format="html") |
| 92 | + latex_node = nodes.raw("", text, format="latex") |
| 93 | + return [node, latex_node], [] |
| 94 | + |
| 95 | + return role |
| 96 | + |
| 97 | + |
| 98 | +def setup(app: Sphinx): |
| 99 | + app.add_role("avail", _highlight_role("#c8e6c9")) # light green |
| 100 | + app.add_role("snaponly", _highlight_role("#bbdefb")) # light blue |
| 101 | + app.add_role("unavail", _highlight_role("#ffcdd2")) # light red |
0 commit comments