Remove html_pygments_dark_style option

This commit is contained in:
Septatrix 2020-03-14 18:46:02 +01:00
parent 6314419bc5
commit 81fe5f8477
6 changed files with 22 additions and 26 deletions

View File

@ -66,8 +66,7 @@ Python :mod:`ConfigParser` module) and has the following structure:
* The **pygments_dark_style** setting gives the name of a Pygments style to use * The **pygments_dark_style** setting gives the name of a Pygments style to use
for highlighting when the CSS media query ``(prefers-color-scheme: dark)`` for highlighting when the CSS media query ``(prefers-color-scheme: dark)``
evaluates to true. It is injected into the page using evaluates to true. It is injected into the page using
:meth:`~Sphinx.add_css_file()`. This can be overriden by the user in the :meth:`~Sphinx.add_css_file()`.
:confval:`html_pygments_dark_style` config value.
* The **sidebars** setting gives the comma separated list of sidebar templates * The **sidebars** setting gives the comma separated list of sidebar templates
for constructing sidebars. This can be overridden by the user in the for constructing sidebars. This can be overridden by the user in the

View File

@ -939,13 +939,6 @@ that use Sphinx's HTMLWriter class.
The image file will be copied to the ``_static`` directory of the output The image file will be copied to the ``_static`` directory of the output
HTML, but only if the file does not already exist there. HTML, but only if the file does not already exist there.
.. confval:: html_pygments_dark_style
The style name to use for an additional Pygments stylesheet similar to
:confval:`pygments_style` . If not set and the theme defines a default
``'pygments_dark_style'`` it will be used, otherwise no additional style
will be generated. See :doc:`/usage/theming` for further information.
.. confval:: html_css_files .. confval:: html_css_files
A list of CSS files. The entry must be a *filename* string or a tuple A list of CSS files. The entry must be a *filename* string or a tuple

View File

@ -271,9 +271,7 @@ class StandaloneHTMLBuilder(Builder):
style = 'sphinx' style = 'sphinx'
self.highlighter = PygmentsBridge('html', style) self.highlighter = PygmentsBridge('html', style)
if self.config.html_pygments_dark_style is not None: if self.theme:
dark_style = self.config.html_pygments_dark_style
elif self.theme:
dark_style = self.theme.get_config('theme', 'pygments_dark_style', None) dark_style = self.theme.get_config('theme', 'pygments_dark_style', None)
else: else:
dark_style = None dark_style = None
@ -1200,7 +1198,6 @@ def setup(app: Sphinx) -> Dict[str, Any]:
app.add_config_value('html_style', None, 'html', [str]) app.add_config_value('html_style', None, 'html', [str])
app.add_config_value('html_logo', None, 'html', [str]) app.add_config_value('html_logo', None, 'html', [str])
app.add_config_value('html_favicon', None, 'html', [str]) app.add_config_value('html_favicon', None, 'html', [str])
app.add_config_value('html_pygments_dark_style', None, 'html', [str])
app.add_config_value('html_css_files', [], 'html') app.add_config_value('html_css_files', [], 'html')
app.add_config_value('html_js_files', [], 'html') app.add_config_value('html_js_files', [], 'html')
app.add_config_value('html_static_path', [], 'html') app.add_config_value('html_static_path', [], 'html')

View File

@ -1,3 +1,4 @@
[theme] [theme]
inherit = classic inherit = classic
sidebars = globaltoc.html, searchbox.html sidebars = globaltoc.html, searchbox.html
pygments_dark = monokai

View File

@ -1525,19 +1525,9 @@ def test_html_pygments_for_classic_theme(app):
assert style.__name__ == 'SphinxStyle' assert style.__name__ == 'SphinxStyle'
@pytest.mark.sphinx('html', testroot='basic', @pytest.mark.sphinx('html', testroot='basic')
confoverrides={'html_pygments_dark_style': 'monokai'}) def test_html_dark_pygments_style_default(app):
def test_html_pygments_style_manually(app): assert app.builder.dark_highlighter is None
style = app.builder.highlighter.formatter_args.get('style')
assert style.__name__ == 'MonokaiStyle'
@pytest.mark.sphinx('html', testroot='basic',
confoverrides={'html_theme_options.pygments_dark_style':
'solarized-dark'})
def test_html_pygments_for_classic_theme(app):
style = app.builder.highlighter.formatter_args.get('style')
assert style.__name__ == 'SolarizedDarkStyle'
@pytest.mark.sphinx(testroot='basic', srcdir='validate_html_extra_path') @pytest.mark.sphinx(testroot='basic', srcdir='validate_html_extra_path')

View File

@ -117,6 +117,22 @@ def test_staticfiles(app, status, warning):
assert '<meta name="testopt" content="optdefault" />' in result assert '<meta name="testopt" content="optdefault" />' in result
@pytest.mark.sphinx(testroot='theming',
confoverrides={'html_theme': 'test-theme'})
def test_staticfiles(app, status, warning):
style = app.builder.highlighter.formatter_args.get('style')
assert style.__name__ == 'MonokaiStyle'
app.build()
assert (app.outdir / '_static' / 'pygments_dark.css').exists()
result = (app.outdir / 'index.html').read_text()
assert '<link rel="stylesheet" href="_static/pygments.css" type="text/css">' in result
assert ('<link rel="stylesheet" href="_static/pygments_dark.css"'
'type="text/css" media="(prefers-color-scheme: dark)"'
'id="pygments_dark_css">') in result
@pytest.mark.sphinx(testroot='theming') @pytest.mark.sphinx(testroot='theming')
def test_theme_sidebars(app, status, warning): def test_theme_sidebars(app, status, warning):
app.build() app.build()