mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
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:
parent
2ae79f5272
commit
c50054c8da
6
CHANGES
6
CHANGES
@ -1,6 +1,12 @@
|
|||||||
Release 1.0.7 (in development)
|
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
|
* Fix a bug where the removal of download files and images wasn't
|
||||||
noticed.
|
noticed.
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ default_settings = {
|
|||||||
|
|
||||||
# This is increased every time an environment attribute is added
|
# This is increased every time an environment attribute is added
|
||||||
# or changed to properly invalidate pickle files.
|
# or changed to properly invalidate pickle files.
|
||||||
ENV_VERSION = 38
|
ENV_VERSION = 39
|
||||||
|
|
||||||
|
|
||||||
default_substitutions = set([
|
default_substitutions = set([
|
||||||
@ -295,6 +295,8 @@ class BuildEnvironment:
|
|||||||
# contains all built docnames
|
# contains all built docnames
|
||||||
self.dependencies = {} # docname -> set of dependent file
|
self.dependencies = {} # docname -> set of dependent file
|
||||||
# names, relative to documentation root
|
# names, relative to documentation root
|
||||||
|
self.reread_always = set() # docnames to re-read unconditionally on
|
||||||
|
# next build
|
||||||
|
|
||||||
# File metadata
|
# File metadata
|
||||||
self.metadata = {} # docname -> dict of metadata items
|
self.metadata = {} # docname -> dict of metadata items
|
||||||
@ -344,6 +346,7 @@ class BuildEnvironment:
|
|||||||
"""Remove all traces of a source file in the inventory."""
|
"""Remove all traces of a source file in the inventory."""
|
||||||
if docname in self.all_docs:
|
if docname in self.all_docs:
|
||||||
self.all_docs.pop(docname, None)
|
self.all_docs.pop(docname, None)
|
||||||
|
self.reread_always.discard(docname)
|
||||||
self.metadata.pop(docname, None)
|
self.metadata.pop(docname, None)
|
||||||
self.dependencies.pop(docname, None)
|
self.dependencies.pop(docname, None)
|
||||||
self.titles.pop(docname, None)
|
self.titles.pop(docname, None)
|
||||||
@ -426,6 +429,10 @@ class BuildEnvironment:
|
|||||||
'.doctree')):
|
'.doctree')):
|
||||||
changed.add(docname)
|
changed.add(docname)
|
||||||
continue
|
continue
|
||||||
|
# check the "reread always" list
|
||||||
|
if docname in self.reread_always:
|
||||||
|
changed.add(docname)
|
||||||
|
continue
|
||||||
# check the mtime of the document
|
# check the mtime of the document
|
||||||
mtime = self.all_docs[docname]
|
mtime = self.all_docs[docname]
|
||||||
newmtime = path.getmtime(self.doc2path(docname))
|
newmtime = path.getmtime(self.doc2path(docname))
|
||||||
@ -729,6 +736,9 @@ class BuildEnvironment:
|
|||||||
def note_dependency(self, filename):
|
def note_dependency(self, filename):
|
||||||
self.dependencies.setdefault(self.docname, set()).add(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):
|
def note_versionchange(self, type, version, node, lineno):
|
||||||
self.versionchanges.setdefault(version, []).append(
|
self.versionchanges.setdefault(version, []).append(
|
||||||
(type, self.temp_data['docname'], lineno,
|
(type, self.temp_data['docname'], lineno,
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
|
import traceback
|
||||||
from types import FunctionType, BuiltinFunctionType, MethodType, ClassType
|
from types import FunctionType, BuiltinFunctionType, MethodType, ClassType
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
@ -336,10 +337,13 @@ class Documenter(object):
|
|||||||
# this used to only catch SyntaxError, ImportError and AttributeError,
|
# this used to only catch SyntaxError, ImportError and AttributeError,
|
||||||
# but importing modules with side effects can raise all kinds of errors
|
# but importing modules with side effects can raise all kinds of errors
|
||||||
except Exception, err:
|
except Exception, err:
|
||||||
|
if self.env.app and not self.env.app.quiet:
|
||||||
|
self.env.app.info(traceback.format_exc().rstrip())
|
||||||
self.directive.warn(
|
self.directive.warn(
|
||||||
'autodoc can\'t import/find %s %r, it reported error: '
|
'autodoc can\'t import/find %s %r, it reported error: '
|
||||||
'"%s", please check your spelling and sys.path' %
|
'"%s", please check your spelling and sys.path' %
|
||||||
(self.objtype, str(self.fullname), err))
|
(self.objtype, str(self.fullname), err))
|
||||||
|
self.env.note_reread()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_real_modname(self):
|
def get_real_modname(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user