diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-09 22:58:00 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-05-11 12:10:09 +0900 |
commit | 6c08963f25c0834eab7d31543810c82f4e09daf5 (patch) | |
tree | 7fb7cea1cde4adead49ff4cf54c86a09221bb4f7 /sphinx/ext/autodoc/directive.py | |
parent | 169297d0b76bf0b503033dadeb14f9a2b735e422 (diff) | |
download | sphinx-git-6c08963f25c0834eab7d31543810c82f4e09daf5.tar.gz |
refactor: Replace Directive by SphinxDirective
Diffstat (limited to 'sphinx/ext/autodoc/directive.py')
-rw-r--r-- | sphinx/ext/autodoc/directive.py | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 77b3f7aaf..64d19fcc7 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -8,13 +8,12 @@ """ from docutils import nodes -from docutils.parsers.rst import Directive from docutils.statemachine import ViewList from docutils.utils import assemble_option_dict from sphinx.ext.autodoc import Options, get_documenters from sphinx.util import logging -from sphinx.util.docutils import switch_source_input +from sphinx.util.docutils import SphinxDirective, switch_source_input from sphinx.util.nodes import nested_parse_with_titles if False: @@ -91,7 +90,7 @@ def parse_generated_content(state, content, documenter): return node.children -class AutodocDirective(Directive): +class AutodocDirective(SphinxDirective): """A directive class for all autodoc directives. It works as a dispatcher of Documenters. It invokes a Documenter on running. After the processing, it parses and returns @@ -105,7 +104,6 @@ class AutodocDirective(Directive): def run(self): # type: () -> List[nodes.Node] - env = self.state.document.settings.env reporter = self.state.document.reporter try: @@ -116,11 +114,11 @@ class AutodocDirective(Directive): # look up target Documenter objtype = self.name[4:] # strip prefix (auto-). - doccls = get_documenters(env.app)[objtype] + doccls = get_documenters(self.env.app)[objtype] # process the options with the selected documenter's option_spec try: - documenter_options = process_documenter_options(doccls, env.config, self.options) + documenter_options = process_documenter_options(doccls, self.config, self.options) except (KeyError, ValueError, TypeError) as exc: # an option is either unknown or has a wrong type logger.error('An option to %s is either unknown or has an invalid value: %s' % @@ -128,7 +126,7 @@ class AutodocDirective(Directive): return [] # generate the output - params = DocumenterBridge(env, reporter, documenter_options, lineno) + params = DocumenterBridge(self.env, reporter, documenter_options, lineno) documenter = doccls(params, self.arguments[0]) documenter.generate(more_content=self.content) if not params.result: |