Skip to content

Commit

Permalink
validate html_static_path on config-inited
Browse files Browse the repository at this point in the history
  • Loading branch information
tk0miya committed Jun 17, 2019
1 parent 564d23b commit 9bef665
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions sphinx/builders/html.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 9bef665

Please sign in to comment.