Skip to content

Commit

Permalink
FEAT: add default HTML options
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgepiloto committed Feb 1, 2023
1 parent 62d041c commit 57d2fe2
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions src/ansys_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,26 @@ def get_version_match(semver: str) -> str:
return ".".join([major, minor])


def setup_default_html_theme_options(app):
"""Set up the default configuration for the HTML options.
Parameters
----------
app : sphinx.application.Sphinx
Application instance for rendering the documentation.
Notes
-----
This function is the only way to overwrite ``pydata-sphinx-theme``
configuration. Variables declared in the ``theme.conf`` do not include
inherited ones.
"""
# Place all switchers and icons at the end of the navigation bar
app.config.html_theme_options.setdefault(
"navbar_end", ["version-switcher", "theme-switcher", "navbar-icon-links"]
)

def setup(app: sphinx.application.Sphinx) -> Dict:
"""Connect to the sphinx theme app.
Expand All @@ -80,14 +100,8 @@ def setup(app: sphinx.application.Sphinx) -> Dict:
app.add_html_theme("ansys_sphinx_theme", theme_path)
app.config.templates_path.append(str(THEME_PATH / "components"))

# Add default configuration
for key, value in app.config.html_theme_options.items():
print(f"Key {key} has value {value}")

# Add default configuration
app.config.html_theme_options.setdefault(
"navbar_end", ["version-switcher", "theme-switcher", "navbar-icon-links"]
)
# Add default HTML configuration
setup_default_html_theme_options(app)

# Verify that the main CSS file exists
if not CSS_PATH.exists():
Expand Down

0 comments on commit 57d2fe2

Please sign in to comment.