diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 1fd9e6cac3a..a21aeb79857 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -783,9 +783,6 @@ def copy_static_files(self) -> None: excluded = Matcher(self.config.exclude_patterns + ["**/.*"]) for static_path in self.config.html_static_path: entry = path.join(self.confdir, static_path) - if not path.exists(entry): - logger.warning(__('html_static_path entry %r does not exist'), entry) - continue copy_asset(entry, path.join(self.outdir, '_static'), excluded, context=ctx, renderer=self.templates) # copy logo and favicon files if not already in static path @@ -1166,6 +1163,14 @@ def validate_math_renderer(app: Sphinx) -> None: raise ConfigError(__('Unknown math_renderer %r is given.') % name) +def validate_html_static_path(app: Sphinx, config: Config) -> None: + """Check html_static_paths setting.""" + for entry in config.html_static_path[:]: + if not path.exists(path.join(app.confdir, entry)): + logger.warning(__('html_static_path entry %r does not exist'), entry) + config.html_static_path.remove(entry) + + # for compatibility import sphinx.builders.dirhtml # NOQA import sphinx.builders.singlehtml # NOQA @@ -1221,6 +1226,7 @@ def setup(app: Sphinx) -> Dict[str, Any]: # event handlers app.connect('config-inited', convert_html_css_files) app.connect('config-inited', convert_html_js_files) + app.connect('config-inited', validate_html_static_path) app.connect('builder-inited', validate_math_renderer) app.connect('html-page-context', setup_js_tag_helper)