From 521719f8a1f4fb907d7f7384955d1f9db530494f Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 12 Jan 2014 16:20:13 +0100 Subject: [PATCH] Closes #1181: Report option errors in autodoc directives more gracefully. --- CHANGES | 2 ++ sphinx/ext/autodoc.py | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 82595c1b1..50f63252e 100644 --- a/CHANGES +++ b/CHANGES @@ -62,6 +62,8 @@ Bugs fixed * #1085: Fix current classname not getting set if class description has ``:noindex:`` set. +* #1181: Report option errors in autodoc directives more gracefully. + Documentation ------------- diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 05996f9e5..ad7b02bbb 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -1384,8 +1384,15 @@ class AutoDirective(Directive): not negated: self.options[flag] = None # process the options with the selected documenter's option_spec - self.genopt = Options(assemble_option_dict( - self.options.items(), doc_class.option_spec)) + try: + 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 documenter = doc_class(self, self.arguments[0]) documenter.generate(more_content=self.content)