If an autodoc object cannot be imported, always re-read the document and show the full traceback of the import error.

This commit is contained in:
Georg Brandl 2011-01-07 10:19:45 +01:00
parent 2ae79f5272
commit c50054c8da
3 changed files with 21 additions and 1 deletions

View File

@ -1,6 +1,12 @@
Release 1.0.7 (in development)
==============================
* If an autodoc object cannot be imported, always re-read the
document containing the directive on next build.
* If an autodoc object cannot be imported, show the full traceback
of the import error.
* Fix a bug where the removal of download files and images wasn't
noticed.

View File

@ -64,7 +64,7 @@ default_settings = {
# This is increased every time an environment attribute is added
# or changed to properly invalidate pickle files.
ENV_VERSION = 38
ENV_VERSION = 39
default_substitutions = set([
@ -295,6 +295,8 @@ class BuildEnvironment:
# contains all built docnames
self.dependencies = {} # docname -> set of dependent file
# names, relative to documentation root
self.reread_always = set() # docnames to re-read unconditionally on
# next build
# File metadata
self.metadata = {} # docname -> dict of metadata items
@ -344,6 +346,7 @@ class BuildEnvironment:
"""Remove all traces of a source file in the inventory."""
if docname in self.all_docs:
self.all_docs.pop(docname, None)
self.reread_always.discard(docname)
self.metadata.pop(docname, None)
self.dependencies.pop(docname, None)
self.titles.pop(docname, None)
@ -426,6 +429,10 @@ class BuildEnvironment:
'.doctree')):
changed.add(docname)
continue
# check the "reread always" list
if docname in self.reread_always:
changed.add(docname)
continue
# check the mtime of the document
mtime = self.all_docs[docname]
newmtime = path.getmtime(self.doc2path(docname))
@ -729,6 +736,9 @@ class BuildEnvironment:
def note_dependency(self, filename):
self.dependencies.setdefault(self.docname, set()).add(filename)
def note_reread(self):
self.reread_always.add(self.docname)
def note_versionchange(self, type, version, node, lineno):
self.versionchanges.setdefault(version, []).append(
(type, self.temp_data['docname'], lineno,

View File

@ -14,6 +14,7 @@
import re
import sys
import inspect
import traceback
from types import FunctionType, BuiltinFunctionType, MethodType, ClassType
from docutils import nodes
@ -336,10 +337,13 @@ class Documenter(object):
# this used to only catch SyntaxError, ImportError and AttributeError,
# but importing modules with side effects can raise all kinds of errors
except Exception, err:
if self.env.app and not self.env.app.quiet:
self.env.app.info(traceback.format_exc().rstrip())
self.directive.warn(
'autodoc can\'t import/find %s %r, it reported error: '
'"%s", please check your spelling and sys.path' %
(self.objtype, str(self.fullname), err))
self.env.note_reread()
return False
def get_real_modname(self):