migrate html_add_permalinks=None and html_add_permalinks=""

The docs list: Set it to None or the empty string to disable permalinks.
This commit is contained in:
Thomas Grainger
2021-02-17 14:50:33 +00:00
parent f8878bb0b6
commit 7dacbd96c4

View File

@@ -1221,15 +1221,26 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:
config.html_favicon = None # type: ignore config.html_favicon = None # type: ignore
UNSET = object()
def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None: def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None:
"""Migrate html_add_permalinks to html_permalinks*.""" """Migrate html_add_permalinks to html_permalinks*."""
if config.html_add_permalinks: html_add_permalinks = config.html_add_permalinks
if (isinstance(config.html_add_permalinks, bool) and if html_add_permalinks is UNSET:
config.html_add_permalinks is False): return
config.html_permalinks = False # type: ignore
else:
config.html_permalinks_icon = html.escape(config.html_add_permalinks) # type: ignore # NOQA
if (
html_add_permalinks is None or
html_add_permalinks is False or
html_add_permalinks == ""
):
config.html_permalinks = False # type: ignore[attr-defined]
return
config.html_permalinks_icon = html.escape( # type: ignore[attr-defined]
config.html_add_permalinks
)
# for compatibility # for compatibility
import sphinxcontrib.serializinghtml # NOQA import sphinxcontrib.serializinghtml # NOQA
@@ -1261,7 +1272,7 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('html_sidebars', {}, 'html') app.add_config_value('html_sidebars', {}, 'html')
app.add_config_value('html_additional_pages', {}, 'html') app.add_config_value('html_additional_pages', {}, 'html')
app.add_config_value('html_domain_indices', True, 'html', [list]) app.add_config_value('html_domain_indices', True, 'html', [list])
app.add_config_value('html_add_permalinks', None, 'html') app.add_config_value('html_add_permalinks', UNSET, 'html')
app.add_config_value('html_permalinks', True, 'html') app.add_config_value('html_permalinks', True, 'html')
app.add_config_value('html_permalinks_icon', '', 'html') app.add_config_value('html_permalinks_icon', '', 'html')
app.add_config_value('html_use_index', True, 'html') app.add_config_value('html_use_index', True, 'html')