Skip to content

Commit

Permalink
Merge pull request #5261 from tk0miya/5246_singlehtml_sidebars
Browse files Browse the repository at this point in the history
Fix #5246: Add :confval:`singlehtml_sidebars` to configure sidebars for singlehtml
  • Loading branch information
tk0miya authored Aug 13, 2018
2 parents e5c5d37 + f670a33 commit f77216c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ Features added
* #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`)
* quickstart: epub builder is enabled by default
* #5246: Add :confval:`singlehtml_sidebars` to configure sidebars for singlehtml
builder

Bugs fixed
----------
Expand Down
10 changes: 10 additions & 0 deletions doc/usage/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,16 @@ 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. And it only allows a key named `'index'`. All other keys
are ignored. For more information, refer to :confval:`html_sidebars`. By
default, it is same as :confval:`html_sidebars`.


.. _htmlhelp-options:

Expand Down
5 changes: 4 additions & 1 deletion sphinx/builders/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f77216c

Please sign in to comment.