diff options
| author | Georg Brandl <georg@python.org> | 2014-01-12 16:20:13 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2014-01-12 16:20:13 +0100 |
| commit | 417b2cf7d0837d78e80e94ff1d66ca5c56898273 (patch) | |
| tree | f0e895e73e04094d433f8727404728d65a21f80e /sphinx/ext | |
| parent | 786502bac5a8d44f33221cc222150181effef24a (diff) | |
| download | sphinx-417b2cf7d0837d78e80e94ff1d66ca5c56898273.tar.gz | |
Closes #1181: Report option errors in autodoc directives more gracefully.
Diffstat (limited to 'sphinx/ext')
| -rw-r--r-- | sphinx/ext/autodoc.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 05996f9e..ad7b02bb 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) |
