Fix #627: Fix tracebacks for AttributeErrors in autosummary generation.

This commit is contained in:
Georg Brandl
2011-09-23 10:46:43 +02:00
parent 757d0013a7
commit 69f7e07681
2 changed files with 11 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
Release 1.0.8 (Sep 23, 2011) Release 1.0.8 (Sep 23, 2011)
============================ ============================
* #627: Fix tracebacks for AttributeErrors in autosummary generation.
* Fix the ``abbr`` role when the abbreviation has newlines in it. * Fix the ``abbr`` role when the abbreviation has newlines in it.
* #727: Fix the links to search results with custom object types. * #727: Fix the links to search results with custom object types.

View File

@@ -29,6 +29,7 @@ from jinja2.sandbox import SandboxedEnvironment
from sphinx.ext.autosummary import import_by_name, get_documenter from sphinx.ext.autosummary import import_by_name, get_documenter
from sphinx.jinja2glue import BuiltinTemplateLoader from sphinx.jinja2glue import BuiltinTemplateLoader
from sphinx.util.osutil import ensuredir from sphinx.util.osutil import ensuredir
from sphinx.util.inspect import safe_getattr
def main(argv=sys.argv): def main(argv=sys.argv):
usage = """%prog [OPTIONS] SOURCEFILE ...""" usage = """%prog [OPTIONS] SOURCEFILE ..."""
@@ -135,10 +136,14 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
template = template_env.get_template('autosummary/base.rst') template = template_env.get_template('autosummary/base.rst')
def get_members(obj, typ, include_public=[]): def get_members(obj, typ, include_public=[]):
items = [ items = []
name for name in dir(obj) for name in dir(obj):
if get_documenter(getattr(obj, name), obj).objtype == typ try:
] documenter = get_documenter(safe_getattr(obj, name), obj)
except AttributeError:
continue
if documenter.objtype == typ:
items.append(name)
public = [x for x in items public = [x for x in items
if x in include_public or not x.startswith('_')] if x in include_public or not x.startswith('_')]
return public, items return public, items