File: missing_static.py

package info (click to toggle)
sphinx-astropy 1.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 300 kB
  • sloc: python: 563; makefile: 5
file content (31 lines) | stat: -rw-r--r-- 967 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Licensed under a 3-clause BSD style license - see LICENSE.rst

"""
The purpose of this extension is to give a clear warning if sphinx is expecting
a static directory to be present but it isn't.
"""
import os
from sphinx.util import logging

WARNING_TEMPLATE = """
Note: The static directory '{0}' was not found. This is often because it is
      empty and you are using git. If so, you don't need it, so make
      sure it isn't included in the html_static_path setting in your conf.py
      file, otherwise Sphinx may fail the build if you are turning warnings into
      errors.
"""


def static_warning(app, config=None):
    info = logging.getLogger(__name__).info

    for directory in app.config.html_static_path:
        if not os.path.exists(directory):
            info(WARNING_TEMPLATE.format(directory))


def setup(app):
    app.connect('build-finished', static_warning)

    return {'parallel_read_safe': True,
            'parallel_write_safe': True}