|
1 | 1 | """This is the ansys-sphinx-theme module.""" |
2 | 2 | import pathlib |
3 | | -from typing import Dict |
| 3 | +from typing import Any, Dict |
4 | 4 |
|
| 5 | +from docutils.nodes import document |
5 | 6 | from sphinx.application import Sphinx |
6 | 7 |
|
7 | 8 | from ansys_sphinx_theme.latex import generate_404 # noqa: F401 |
8 | 9 |
|
9 | | -__version__ = "0.9.7" |
| 10 | +__version__ = "0.9.8" |
10 | 11 |
|
11 | 12 | # Declare the fundamental paths of the theme |
12 | 13 | THIS_PATH = pathlib.Path(__file__).parent.resolve() |
@@ -84,6 +85,31 @@ def setup_default_html_theme_options(app): |
84 | 85 | app.config.html_theme_options.setdefault("collapse_navigation", True) |
85 | 86 |
|
86 | 87 |
|
| 88 | +def update_footer_theme( |
| 89 | + app: Sphinx, pagename: str, templatename: str, context: Dict[str, Any], doctree: document |
| 90 | +) -> None: |
| 91 | + """Update the version number of the Ansys Sphinx theme in the footer. |
| 92 | +
|
| 93 | + Connect to the Sphinx application instance for rendering the documentation, |
| 94 | + and add the current version number of the Ansys Sphinx theme to the page context. |
| 95 | + This allows the theme to update the footer with the current version number. |
| 96 | +
|
| 97 | + Parameters |
| 98 | + ---------- |
| 99 | + app : ~sphinx.application.Sphinx |
| 100 | + Application instance for rendering the documentation. |
| 101 | + pagename : str |
| 102 | + The name of the current page. |
| 103 | + templatename : str |
| 104 | + The name of the template being used. |
| 105 | + context : dict |
| 106 | + The context dictionary for the page. |
| 107 | + doctree : ~docutils.nodes.document |
| 108 | + The document tree for the page. |
| 109 | + """ |
| 110 | + context["ansys_sphinx_theme_version"] = __version__ |
| 111 | + |
| 112 | + |
87 | 113 | def setup(app: Sphinx) -> Dict: |
88 | 114 | """Connect to the sphinx theme app. |
89 | 115 |
|
@@ -113,6 +139,7 @@ def setup(app: Sphinx) -> Dict: |
113 | 139 | app.add_js_file(str(JS_FILE.relative_to(STATIC_PATH))) |
114 | 140 | app.add_js_file("https://cdn.datatables.net/1.10.23/js/jquery.dataTables.min.js") |
115 | 141 | app.add_css_file("https://cdn.datatables.net/1.10.23/css/jquery.dataTables.min.css") |
| 142 | + app.connect("html-page-context", update_footer_theme) |
116 | 143 | # Add templates for autosummary |
117 | 144 | app.config.templates_path.append(str(TEMPLATES_PATH)) |
118 | 145 |
|
|
0 commit comments