Commits

Anonymous committed 139b3b3

Record deps from autodoc.

  • Participants
  • Parent commits 65fb597

Comments (0)

Files changed (3)

 * 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)
 ================================

File sphinx/environment.py

                 # 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)
 
     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)
     # -------

File sphinx/ext/autodoc.py

     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
 
     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__'):
     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()