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:
6
CHANGES
6
CHANGES
@@ -4,6 +4,12 @@ Changes in trunk
|
|||||||
* sphinx.environment: Take dependent files into account when collecting
|
* sphinx.environment: Take dependent files into account when collecting
|
||||||
the set of outdated sources.
|
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)
|
Release 0.1.61843 (Mar 24, 2008)
|
||||||
================================
|
================================
|
||||||
|
|||||||
@@ -361,6 +361,7 @@ class BuildEnvironment:
|
|||||||
# finally, check the mtime of dependencies
|
# finally, check the mtime of dependencies
|
||||||
for dep in self.dependencies.get(docname, ()):
|
for dep in self.dependencies.get(docname, ()):
|
||||||
try:
|
try:
|
||||||
|
# this will do the right thing when dep is absolute too
|
||||||
deppath = path.join(self.srcdir, dep)
|
deppath = path.join(self.srcdir, dep)
|
||||||
if not path.isfile(deppath):
|
if not path.isfile(deppath):
|
||||||
changed.add(docname)
|
changed.add(docname)
|
||||||
@@ -639,6 +640,7 @@ class BuildEnvironment:
|
|||||||
|
|
||||||
def note_dependency(self, filename):
|
def note_dependency(self, filename):
|
||||||
basename = path.dirname(self.doc2path(self.docname, base=None))
|
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)
|
filename = path.join(basename, filename)
|
||||||
self.dependencies.setdefault(self.docname, set()).add(filename)
|
self.dependencies.setdefault(self.docname, set()).add(filename)
|
||||||
# -------
|
# -------
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ def get_module_charset(module):
|
|||||||
return charset
|
return charset
|
||||||
|
|
||||||
|
|
||||||
def generate_rst(what, name, members, undoc, add_content,
|
def generate_rst(what, name, members, undoc, add_content, document, lineno,
|
||||||
document, lineno, indent=''):
|
indent='', filename_set=None):
|
||||||
env = document.settings.env
|
env = document.settings.env
|
||||||
|
|
||||||
# find out what to import
|
# find out what to import
|
||||||
@@ -101,6 +101,11 @@ def generate_rst(what, name, members, undoc, add_content,
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
todoc = module = __import__(mod, None, None, ['foo'])
|
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:
|
for part in objpath:
|
||||||
todoc = getattr(todoc, part)
|
todoc = getattr(todoc, part)
|
||||||
if hasattr(todoc, '__module__'):
|
if hasattr(todoc, '__module__'):
|
||||||
@@ -218,8 +223,14 @@ def _auto_directive(dirname, arguments, options, content, lineno,
|
|||||||
members = options.get('members', [])
|
members = options.get('members', [])
|
||||||
undoc = 'undoc-members' in options
|
undoc = 'undoc-members' in options
|
||||||
|
|
||||||
|
filename_set = set()
|
||||||
warnings, result = generate_rst(what, name, members, undoc, content,
|
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':
|
if dirname == 'automodule':
|
||||||
node = nodes.section()
|
node = nodes.section()
|
||||||
|
|||||||
Reference in New Issue
Block a user