From 7dacbd96c4fbae237f83682abc99b524f2cc31b3 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 17 Feb 2021 14:50:33 +0000 Subject: [PATCH 1/3] migrate html_add_permalinks=None and html_add_permalinks="" The docs list: Set it to None or the empty string to disable permalinks. --- sphinx/builders/html/__init__.py | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index c799b017671..fe5438e259e 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -1221,15 +1221,26 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None: config.html_favicon = None # type: ignore +UNSET = object() + + def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None: """Migrate html_add_permalinks to html_permalinks*.""" - if config.html_add_permalinks: - if (isinstance(config.html_add_permalinks, bool) and - config.html_add_permalinks is False): - config.html_permalinks = False # type: ignore - else: - config.html_permalinks_icon = html.escape(config.html_add_permalinks) # type: ignore # NOQA + html_add_permalinks = config.html_add_permalinks + if html_add_permalinks is UNSET: + return + + 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 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_additional_pages', {}, 'html') 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_icon', 'ΒΆ', 'html') app.add_config_value('html_use_index', True, 'html') From ae5986f9cdbac0a35110b010126d0d56446bd0de Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 28 Feb 2021 12:00:18 +0000 Subject: [PATCH 2/3] Update sphinx/builders/html/__init__.py --- sphinx/builders/html/__init__.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 760a17dc507..bd31e309b48 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -1260,11 +1260,7 @@ def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None: # RemovedInSphinx60Warning logger.warning(__('html_add_permalinks has been deprecated since v3.5.0. ' 'Please use html_permalinks and html_permalinks_icon instead.')) - if ( - html_add_permalinks is None or - html_add_permalinks is False or - html_add_permalinks == "" - ): + if not html_add_permalinks: config.html_permalinks = False # type: ignore[attr-defined] return From 878c11611275eca4d14a56efcf79a55ad242dc9a Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 28 Feb 2021 14:29:07 +0000 Subject: [PATCH 3/3] Update sphinx/builders/html/__init__.py --- sphinx/builders/html/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index bd31e309b48..01de0b94fd4 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -1265,7 +1265,7 @@ def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None: return config.html_permalinks_icon = html.escape( # type: ignore[attr-defined] - config.html_add_permalinks + html_add_permalinks ) # for compatibility