An awesome theme for the Sphinx documentation generator with enhanced features, custom code highlighting, and modern responsive design
Comprehensive backward compatibility system that automatically detects deprecated configuration options, provides migration guidance, and ensures smooth transitions between theme versions. This system maintains compatibility with legacy configurations while encouraging adoption of modern alternatives.
Main function that scans Sphinx configuration for deprecated options and provides automatic migration.
def check_deprecated(app: Sphinx, config: Config) -> None:
"""
Check the Sphinx configuration for deprecated options and migrate them automatically if possible.
Scans configuration for deprecated theme options and:
- Issues appropriate warning messages
- Automatically migrates settings to modern equivalents
- Provides guidance for manual migration when needed
- Tracks whether any deprecated options were found
Parameters:
- app (Sphinx): The Sphinx application instance
- config (Config): The Sphinx configuration object
"""Extension registration that adds deprecated configuration values to Sphinx.
def setup(app: Sphinx) -> dict[str, Any]:
"""
Register the deprecated options extension.
Registers deprecated configuration values with Sphinx so they
don't cause errors when present in conf.py files. Also connects
the deprecation checker to the config-inited event.
Parameters:
- app (Sphinx): The Sphinx application instance
Returns:
dict[str, Any]: Extension metadata with version and parallel processing flags
"""# Deprecated (< 5.0)
html_awesome_headerlinks = True
# Modern equivalent
html_theme_options = {
"awesome_headerlinks": True
}# Deprecated (< 5.0)
html_awesome_external_links = True
# Modern equivalent
html_theme_options = {
"awesome_external_links": True
}# Deprecated (< 5.0)
html_awesome_docsearch = True
# Modern equivalent
extensions = [
# ... other extensions
"sphinx_docsearch"
]# Deprecated (< 5.0)
html_collapsible_definitions = True
# Modern equivalent
extensions = [
# ... other extensions
"sphinx_design"
]# This option no longer has any effect
html_awesome_code_headers = True # Generates info message only# Deprecated - no longer needed
extensions = [
"sphinxawesome_theme", # Warning: remove this
"sphinxawesome_theme.highlighting" # Warning: remove this
]
# Modern approach - just set the theme
html_theme = "sphinxawesome_theme"The system automatically migrates compatible options:
config._raw_config for deprecated keys# Original deprecated configuration
html_awesome_headerlinks = True
html_awesome_external_links = False
html_awesome_docsearch = True
# After automatic migration
html_theme_options = {
"awesome_headerlinks": True, # Migrated automatically
"awesome_external_links": False # Migrated automatically
}
# html_awesome_docsearch generates warning only (manual migration required)The system provides specific warning messages for each deprecated option:
`html_awesome_headerlinks` is deprecated.
Use `html_theme_options = {'awesome_headerlinks: True '} instead.`html_awesome_external_links` is deprecated.
Use `html_theme_options = {'awesome_external_links: True '} instead.`html_awesome_docsearch` is deprecated.
Use the `sphinx-docsearch` extension instead.`html_collapsible_definitions` is deprecated.
Use the `sphinx-design` extension instead.Including `sphinxawesome_theme` in your `extensions` is deprecated.
Setting `html_theme = "sphinxawesome_theme"` is enough.You don't need to include the `sphinxawesome_theme.highlighting` extension anymore.The extension registers deprecated configuration values to prevent Sphinx errors:
# Registered deprecated configuration values
app.add_config_value("html_collapsible_definitions", default=False, rebuild="html", types=(bool))
app.add_config_value("html_awesome_external_links", default=False, rebuild="html", types=(bool))
app.add_config_value("html_awesome_docsearch", default=False, rebuild="html", types=(bool))
app.add_config_value("docsearch_config", default={}, rebuild="html", types=(dict))
app.add_config_value("html_awesome_headerlinks", default=True, rebuild="html", types=(str))
app.add_config_value("html_awesome_code_headers", default=True, rebuild="html", types=(str))# In conf.py - add to extensions for deprecation checking
extensions = [
"sphinxawesome_theme.deprecated",
# ... other extensions
]When no deprecated options are found:
No deprecated options found. You can remove the `sphinxawesome_theme.deprecated` extension.The deprecation checker connects to Sphinx's configuration system:
app.connect("config-inited", check_deprecated)This ensures checking happens after configuration is loaded but before the build process begins.
The system safely accesses raw configuration data:
raw = config._raw_config
found_deprecated = False
if "deprecated_option" in raw:
# Handle deprecated option
found_deprecated = TrueMigration preserves existing theme options:
# Safely update theme options without overwriting existing values
config.html_theme_options["new_option"] = raw["deprecated_option"]
del raw["deprecated_option"]To deprecate a new option:
check_deprecated()setup() if neededThe extension tracks theme version for context:
from . import __version__
return {
"version": __version__,
"parallel_read_safe": True,
"parallel_write_safe": True,
}This ensures deprecation messages are contextually appropriate for the theme version.
Install with Tessl CLI
npx tessl i tessl/pypi-sphinxawesome-theme