mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Record deps from autodoc.
This commit is contained in:
parent
55aacf998a
commit
6433cca6a8
6
CHANGES
6
CHANGES
@ -4,6 +4,12 @@ Changes in trunk
|
||||
* sphinx.environment: Take dependent files into account when collecting
|
||||
the set of outdated sources.
|
||||
|
||||
* sphinx.directives: Record files included with ``.. literalinclude::``
|
||||
as dependencies.
|
||||
|
||||
* sphinx.ext.autodoc: Record files from which docstrings are included
|
||||
as dependencies.
|
||||
|
||||
|
||||
Release 0.1.61843 (Mar 24, 2008)
|
||||
================================
|
||||
|
@ -361,6 +361,7 @@ class BuildEnvironment:
|
||||
# finally, check the mtime of dependencies
|
||||
for dep in self.dependencies.get(docname, ()):
|
||||
try:
|
||||
# this will do the right thing when dep is absolute too
|
||||
deppath = path.join(self.srcdir, dep)
|
||||
if not path.isfile(deppath):
|
||||
changed.add(docname)
|
||||
@ -639,6 +640,7 @@ class BuildEnvironment:
|
||||
|
||||
def note_dependency(self, filename):
|
||||
basename = path.dirname(self.doc2path(self.docname, base=None))
|
||||
# this will do the right thing when filename is absolute too
|
||||
filename = path.join(basename, filename)
|
||||
self.dependencies.setdefault(self.docname, set()).add(filename)
|
||||
# -------
|
||||
|
@ -69,8 +69,8 @@ def get_module_charset(module):
|
||||
return charset
|
||||
|
||||
|
||||
def generate_rst(what, name, members, undoc, add_content,
|
||||
document, lineno, indent=''):
|
||||
def generate_rst(what, name, members, undoc, add_content, document, lineno,
|
||||
indent='', filename_set=None):
|
||||
env = document.settings.env
|
||||
|
||||
# find out what to import
|
||||
@ -101,6 +101,11 @@ def generate_rst(what, name, members, undoc, add_content,
|
||||
|
||||
try:
|
||||
todoc = module = __import__(mod, None, None, ['foo'])
|
||||
if filename_set is not None and hasattr(module, '__file__') and module.__file__:
|
||||
modfile = module.__file__
|
||||
if modfile.lower().endswith('.pyc') or modfile.lower().endswith('.pyo'):
|
||||
modfile = modfile[:-1]
|
||||
filename_set.add(modfile)
|
||||
for part in objpath:
|
||||
todoc = getattr(todoc, part)
|
||||
if hasattr(todoc, '__module__'):
|
||||
@ -218,8 +223,14 @@ def _auto_directive(dirname, arguments, options, content, lineno,
|
||||
members = options.get('members', [])
|
||||
undoc = 'undoc-members' in options
|
||||
|
||||
filename_set = set()
|
||||
warnings, result = generate_rst(what, name, members, undoc, content,
|
||||
state.document, lineno)
|
||||
state.document, lineno, filename_set=filename_set)
|
||||
|
||||
# record all filenames as dependencies -- this will at least partially make
|
||||
# automatic invalidation possible
|
||||
for fn in filename_set:
|
||||
state.document.settings.env.note_dependency(fn)
|
||||
|
||||
if dirname == 'automodule':
|
||||
node = nodes.section()
|
||||
|
Loading…
Reference in New Issue
Block a user