Closes #1181: Report option errors in autodoc directives more gracefully.

This commit is contained in:
Georg Brandl 2014-01-12 16:20:13 +01:00
parent 31aed07386
commit 521719f8a1
2 changed files with 11 additions and 2 deletions

View File

@ -62,6 +62,8 @@ Bugs fixed
* #1085: Fix current classname not getting set if class description has * #1085: Fix current classname not getting set if class description has
``:noindex:`` set. ``:noindex:`` set.
* #1181: Report option errors in autodoc directives more gracefully.
Documentation Documentation
------------- -------------

View File

@ -1384,8 +1384,15 @@ class AutoDirective(Directive):
not negated: not negated:
self.options[flag] = None self.options[flag] = None
# process the options with the selected documenter's option_spec # process the options with the selected documenter's option_spec
self.genopt = Options(assemble_option_dict( try:
self.options.items(), doc_class.option_spec)) self.genopt = Options(assemble_option_dict(
self.options.items(), doc_class.option_spec))
except (KeyError, ValueError, TypeError), err:
# an option is either unknown or has a wrong type
msg = self.reporter.error('An option to %s is either unknown or '
'has an invalid value: %s' % (self.name, err),
line=self.lineno)
return [msg]
# generate the output # generate the output
documenter = doc_class(self, self.arguments[0]) documenter = doc_class(self, self.arguments[0])
documenter.generate(more_content=self.content) documenter.generate(more_content=self.content)