[Python-checkins] r61886 - in doctools/trunk: CHANGES sphinx/environment.py sphinx/ext/autodoc.py
georg.brandl
python-checkins at python.org
Tue Mar 25 11:31:13 CET 2008
Author: georg.brandl
Date: Tue Mar 25 11:31:13 2008
New Revision: 61886
Modified:
doctools/trunk/CHANGES
doctools/trunk/sphinx/environment.py
doctools/trunk/sphinx/ext/autodoc.py
Log:
Record deps from autodoc.
Modified: doctools/trunk/CHANGES
==============================================================================
--- doctools/trunk/CHANGES (original)
+++ doctools/trunk/CHANGES Tue Mar 25 11:31:13 2008
@@ -4,6 +4,12 @@
* 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)
================================
Modified: doctools/trunk/sphinx/environment.py
==============================================================================
--- doctools/trunk/sphinx/environment.py (original)
+++ doctools/trunk/sphinx/environment.py Tue Mar 25 11:31:13 2008
@@ -361,6 +361,7 @@
# 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 @@
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)
# -------
Modified: doctools/trunk/sphinx/ext/autodoc.py
==============================================================================
--- doctools/trunk/sphinx/ext/autodoc.py (original)
+++ doctools/trunk/sphinx/ext/autodoc.py Tue Mar 25 11:31:13 2008
@@ -69,8 +69,8 @@
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 @@
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 @@
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()
More information about the Python-checkins
mailing list