From fc44de55c410b859a2c1a2d1f95dfecf3c02e348 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 4 Aug 2018 19:05:21 +0900 Subject: [PATCH] Fix #5246: Add :confval:`singlehtml_sidebars` to configure sidebars for singlehtml --- CHANGES | 2 ++ doc/usage/configuration.rst | 9 +++++++++ sphinx/builders/html.py | 5 ++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index b83f1925f5a..d251eb38f13 100644 --- a/CHANGES +++ b/CHANGES @@ -186,6 +186,8 @@ Features added * #5140: linkcheck: Add better Accept header to HTTP client * #4614: sphinx-build: Add ``--keep-going`` option to show all warnings * Add :rst:role:`math:numref` role to refer equations (Same as :rst:role:`eq`) +* #5246: Add :confval:`singlehtml_sidebars` to configure sidebars for singlehtml + builder Bugs fixed ---------- diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index ba37ccdc151..9204f6a576a 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -1333,6 +1333,15 @@ that use Sphinx's HTMLWriter class. .. versionadded:: 1.6 +Options for Single HTML output +------------------------------- + +.. confval:: singlehtml_sidebars + + Custom sidebar templates, must be a dictionary that maps document names to + template names. For more information, refer to :confval:`html_sidebars`. + By default, it is same as :confval:`html_sidebars`. + .. _htmlhelp-options: diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 0deaec70780..a0550728eba 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -1066,7 +1066,8 @@ def has_wildcard(pattern): sidebars = [name.strip() for name in theme_default_sidebars.split(',')] # user sidebar settings - for pattern, patsidebars in iteritems(self.config.html_sidebars): + html_sidebars = self.get_builder_config('sidebars', 'html') + for pattern, patsidebars in iteritems(html_sidebars): if patmatch(pagename, pattern): if matched: if has_wildcard(pattern): @@ -1714,6 +1715,8 @@ def setup(app): app.add_config_value('html_baseurl', '', 'html') app.add_config_value('html_math_renderer', None, 'env') + app.add_config_value('singlehtml_sidebars', lambda self: self.html_sidebars, 'html') + # event handlers app.connect('config-inited', convert_html_css_files) app.connect('config-inited', convert_html_js_files)