From cbf4ee24f9c7f83a7558786d2f43c9b79ad60418 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 27 Apr 2018 22:23:59 +0900 Subject: [PATCH] Fix #4811: The files under html_static_path are excluded from source --- CHANGES | 2 ++ doc/usage/configuration.rst | 11 +++++++++-- sphinx/builders/html.py | 2 +- tests/roots/test-html_assets/extra/index.rst | 0 tests/roots/test-html_assets/static/index.rst | 0 tests/test_build_html.py | 4 ++++ 6 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 tests/roots/test-html_assets/extra/index.rst create mode 100644 tests/roots/test-html_assets/static/index.rst diff --git a/CHANGES b/CHANGES index 1f412d1cf..aaf0fd38a 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,8 @@ Incompatible changes * ``docutils.conf`` on ``$HOME`` and ``/etc`` directories are ignored. Only ``docutils.conf`` on confdir is refered. * #789: ``:samp:`` role supports to escape curly braces with backslash +* #4811: The files under :confval:`html_static_path` are excluded from source + files. Deprecated ---------- diff --git a/doc/usage/configuration.rst b/doc/usage/configuration.rst index 948a9ffbc..0c3353f98 100644 --- a/doc/usage/configuration.rst +++ b/doc/usage/configuration.rst @@ -883,6 +883,9 @@ that use Sphinx's HTMLWriter class. named :file:`default.css` will overwrite the theme's :file:`default.css`. + As these files are not meant to be built, they are automatically excluded + from source files. + .. note:: For security reason, dotfiles under ``html_static_path`` will @@ -901,6 +904,10 @@ that use Sphinx's HTMLWriter class. .. versionchanged:: 1.0 The entries in :confval:`html_static_path` can now be single files. + .. versionchanged:: 1.8 + The files under :confval:`html_static_path` are excluded from source + files. + .. confval:: html_extra_path A list of paths that contain extra files not directly related to @@ -909,8 +916,8 @@ that use Sphinx's HTMLWriter class. directory. They are copied to the output directory. They will overwrite any existing file of the same name. - As these files are not meant to be built, they are automatically added to - :confval:`exclude_patterns`. + As these files are not meant to be built, they are automatically excluded + from source files. .. versionadded:: 1.2 diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 7e6475980..2c8ac42ea 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -411,7 +411,7 @@ class StandaloneHTMLBuilder(Builder): def get_asset_paths(self): # type: () -> List[unicode] - return self.config.html_extra_path + return self.config.html_extra_path + self.config.html_static_path def render_partial(self, node): # type: (nodes.Nodes) -> Dict[unicode, unicode] diff --git a/tests/roots/test-html_assets/extra/index.rst b/tests/roots/test-html_assets/extra/index.rst new file mode 100644 index 000000000..e69de29bb diff --git a/tests/roots/test-html_assets/static/index.rst b/tests/roots/test-html_assets/static/index.rst new file mode 100644 index 000000000..e69de29bb diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 655feec03..2b45720d1 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -1089,6 +1089,10 @@ def test_enumerable_node(app, cached_etree_parse, fname, expect): def test_html_assets(app): app.builder.build_all() + # exclude_path and its family + assert not (app.outdir / 'static' / 'index.html').exists() + assert not (app.outdir / 'extra' / 'index.html').exists() + # html_static_path assert not (app.outdir / '_static' / '.htaccess').exists() assert not (app.outdir / '_static' / '.htpasswd').exists()