Skip to content

Commit

Permalink
migrate html_add_permalinks=None and html_add_permalinks=""
Browse files Browse the repository at this point in the history
The docs list: Set it to None or the empty string to disable permalinks.
  • Loading branch information
graingert committed Feb 17, 2021
1 parent f8878bb commit cfa2136
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions sphinx/builders/html/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,12 +1223,15 @@ def validate_html_favicon(app: Sphinx, config: Config) -> None:

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
return

config.html_permalinks_icon = html.escape(config.html_add_permalinks) # type: ignore # NOQA


# for compatibility
Expand All @@ -1237,6 +1240,8 @@ def migrate_html_add_permalinks(app: Sphinx, config: Config) -> None:
import sphinx.builders.dirhtml # NOQA
import sphinx.builders.singlehtml # NOQA

UNSET = object


def setup(app: Sphinx) -> Dict[str, Any]:
# builders
Expand All @@ -1261,7 +1266,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')
Expand Down

0 comments on commit cfa2136

Please sign in to comment.