10
"""depfile is a Sphinx extension that writes a dependency file for
11
an external build system"""
16
from pathlib import Path
21
for x in env.found_docs:
22
yield str(env.doc2path(x))
23
yield from ((os.path.join(env.srcdir, dep)
24
for dep in env.dependencies[x]))
25
for mod in sys.modules.values():
26
if hasattr(mod, '__file__'):
30
for static_path in env.config.html_static_path + env.config.templates_path:
31
for path in Path(static_path).rglob('*'):
35
def write_depfile(app, exception):
40
if not env.config.depfile:
46
if env.config.depfile_stamp:
47
with open(env.config.depfile_stamp, 'w') as f:
50
with open(env.config.depfile, 'w') as f:
51
print((env.config.depfile_stamp or app.outdir) + ": \\", file=f)
52
print(*get_infiles(env), file=f)
53
for x in get_infiles(env):
54
print(x + ":", file=f)
58
app.add_config_value('depfile', None, 'env')
59
app.add_config_value('depfile_stamp', None, 'env')
60
app.connect('build-finished', write_depfile)
63
version = __version__,
64
parallel_read_safe = True,
65
parallel_write_safe = True