From 81fe5f847784c1200ce94cf5bf7327d8d22d0b9a Mon Sep 17 00:00:00 2001 From: Septatrix <24257556+Septatrix@users.noreply.github.com> Date: Sat, 14 Mar 2020 18:46:02 +0100 Subject: [PATCH] Remove html_pygments_dark_style option --- doc/theming.rst | 3 +-- doc/usage/configuration.rst | 7 ------- sphinx/builders/html/__init__.py | 5 +---- .../test_theme/test-theme/theme.conf | 1 + tests/test_build_html.py | 16 +++------------- tests/test_theming.py | 16 ++++++++++++++++ 6 files changed, 22 insertions(+), 26 deletions(-) diff --git a/doc/theming.rst b/doc/theming.rst index 50b5f8eaa..6a154affd 100644 --- a/doc/theming.rst +++ b/doc/theming.rst @@ -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 for highlighting when the CSS media query ``(prefers-color-scheme: dark)`` evaluates to true. It is injected into the page using - :meth:`~Sphinx.add_css_file()`. This can be overriden by the user in the - :confval:`html_pygments_dark_style` config value. + :meth:`~Sphinx.add_css_file()`. * The **sidebars** setting gives the comma separated list of sidebar templates for constructing sidebars. This can be overridden by the user in the diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 5149bd931..e5ab9c7c0 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -939,13 +939,6 @@ that use Sphinx's HTMLWriter class. The image file will be copied to the ``_static`` directory of the output 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 A list of CSS files. The entry must be a *filename* string or a tuple diff --git a/sphinx/builders/html/__init__.py b/sphinx/builders/html/__init__.py index 40085776e..0ce5da82b 100644 --- a/sphinx/builders/html/__init__.py +++ b/sphinx/builders/html/__init__.py @@ -271,9 +271,7 @@ class StandaloneHTMLBuilder(Builder): style = 'sphinx' self.highlighter = PygmentsBridge('html', style) - if self.config.html_pygments_dark_style is not None: - dark_style = self.config.html_pygments_dark_style - elif self.theme: + if self.theme: dark_style = self.theme.get_config('theme', 'pygments_dark_style', None) else: 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_logo', 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_js_files', [], 'html') app.add_config_value('html_static_path', [], 'html') diff --git a/tests/roots/test-theming/test_theme/test-theme/theme.conf b/tests/roots/test-theming/test_theme/test-theme/theme.conf index b7518bc9c..522adf1f8 100644 --- a/tests/roots/test-theming/test_theme/test-theme/theme.conf +++ b/tests/roots/test-theming/test_theme/test-theme/theme.conf @@ -1,3 +1,4 @@ [theme] inherit = classic sidebars = globaltoc.html, searchbox.html +pygments_dark = monokai \ No newline at end of file diff --git a/tests/test_build_html.py b/tests/test_build_html.py index f0da3ce30..a0072ca18 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -1525,19 +1525,9 @@ def test_html_pygments_for_classic_theme(app): assert style.__name__ == 'SphinxStyle' -@pytest.mark.sphinx('html', testroot='basic', - confoverrides={'html_pygments_dark_style': 'monokai'}) -def test_html_pygments_style_manually(app): - 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('html', testroot='basic') +def test_html_dark_pygments_style_default(app): + assert app.builder.dark_highlighter is None @pytest.mark.sphinx(testroot='basic', srcdir='validate_html_extra_path') diff --git a/tests/test_theming.py b/tests/test_theming.py index 7854cbd00..58402dcf9 100644 --- a/tests/test_theming.py +++ b/tests/test_theming.py @@ -117,6 +117,22 @@ def test_staticfiles(app, status, warning): assert '' 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 '' in result + assert ('') in result + + @pytest.mark.sphinx(testroot='theming') def test_theme_sidebars(app, status, warning): app.build()