mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add Builder#get_asset_paths() to make less-coupling
This commit is contained in:
parent
cd3f48bb76
commit
b192b3271a
@ -291,7 +291,7 @@ class Sphinx(object):
|
||||
# type: (bool) -> None
|
||||
if freshenv:
|
||||
self.env = BuildEnvironment(self)
|
||||
self.env.find_files(self.config, self.builder.name)
|
||||
self.env.find_files(self.config, self.builder)
|
||||
for domain in self.domains.keys():
|
||||
self.env.domains[domain] = self.domains[domain](self.env)
|
||||
else:
|
||||
|
@ -149,6 +149,11 @@ class Builder(object):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_asset_paths(self):
|
||||
# type: () -> List[unicode]
|
||||
"""Return list of paths for assets (ex. templates, CSS, etc.)."""
|
||||
return []
|
||||
|
||||
supported_image_types = [] # type: List[unicode]
|
||||
|
||||
def post_process_images(self, doctree):
|
||||
|
@ -264,6 +264,10 @@ class StandaloneHTMLBuilder(Builder):
|
||||
# source doesn't exist anymore
|
||||
pass
|
||||
|
||||
def get_asset_paths(self):
|
||||
# type: () -> List[unicode]
|
||||
return self.config.html_extra_path
|
||||
|
||||
def render_partial(self, node):
|
||||
# type: (nodes.Nodes) -> Dict[unicode, unicode]
|
||||
"""Utility: Render a lone doctree node."""
|
||||
|
@ -405,15 +405,15 @@ class BuildEnvironment(object):
|
||||
enc_rel_fn = rel_fn.encode(sys.getfilesystemencoding())
|
||||
return rel_fn, path.abspath(path.join(self.srcdir, enc_rel_fn))
|
||||
|
||||
def find_files(self, config, buildername):
|
||||
# type: (Config, unicode) -> None
|
||||
def find_files(self, config, builder):
|
||||
# type: (Config, Builder) -> None
|
||||
"""Find all source files in the source dir and put them in
|
||||
self.found_docs.
|
||||
"""
|
||||
matchers = compile_matchers(
|
||||
config.exclude_patterns[:] +
|
||||
config.templates_path +
|
||||
config.html_extra_path +
|
||||
builder.get_asset_paths() +
|
||||
['**/_sources', '.#*', '**/.#*', '*.lproj/**']
|
||||
)
|
||||
self.found_docs = set()
|
||||
@ -430,7 +430,7 @@ class BuildEnvironment(object):
|
||||
# is set for the doc source and the mo file, it is processed again from
|
||||
# the reading phase when mo is updated. In the future, we would like to
|
||||
# move i18n process into the writing phase, and remove these lines.
|
||||
if buildername != 'gettext':
|
||||
if builder.name != 'gettext':
|
||||
# add catalog mo file dependency
|
||||
for docname in self.found_docs:
|
||||
catalog_files = find_catalog_files(
|
||||
@ -522,7 +522,7 @@ class BuildEnvironment(object):
|
||||
# the source and doctree directories may have been relocated
|
||||
self.srcdir = srcdir
|
||||
self.doctreedir = doctreedir
|
||||
self.find_files(config, self.app.buildername)
|
||||
self.find_files(config, self.app.builder)
|
||||
self.config = config
|
||||
|
||||
# this cache also needs to be updated every time
|
||||
|
Loading…
Reference in New Issue
Block a user