From 6d4fefebf4ecee4416da016d8e647298003fb57a Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 7 Mar 2020 10:45:39 +0900 Subject: Deprecate codes for python 3.5 --- sphinx/ext/autodoc/directive.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index b44bd75b3..3fe5dc950 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -7,7 +7,7 @@ """ import warnings -from typing import Any, Callable, Dict, List, Set +from typing import Any, Callable, Dict, List, Set, Type from docutils import nodes from docutils.nodes import Element, Node @@ -23,10 +23,6 @@ from sphinx.util import logging from sphinx.util.docutils import SphinxDirective, switch_source_input from sphinx.util.nodes import nested_parse_with_titles -if False: - # For type annotation - from typing import Type # for python3.5.1 - logger = logging.getLogger(__name__) -- cgit v1.2.1 From a86346aca6bf99a8920da366caaad7c47809ecce Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 7 Mar 2020 20:43:25 +0900 Subject: Remove deprecated features marked as RemovedInSphinx40Warning --- sphinx/ext/autodoc/directive.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index c12d451be..5543059cb 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -6,17 +6,15 @@ :license: BSD, see LICENSE for details. """ -import warnings from typing import Any, Callable, Dict, List, Set, Type from docutils import nodes from docutils.nodes import Element, Node -from docutils.parsers.rst.states import RSTState, Struct +from docutils.parsers.rst.states import RSTState from docutils.statemachine import StringList from docutils.utils import Reporter, assemble_option_dict from sphinx.config import Config -from sphinx.deprecation import RemovedInSphinx40Warning from sphinx.environment import BuildEnvironment from sphinx.ext.autodoc import Documenter, Options from sphinx.util import logging @@ -49,23 +47,14 @@ class DocumenterBridge: """A parameters container for Documenters.""" def __init__(self, env: BuildEnvironment, reporter: Reporter, options: Options, - lineno: int, state: Any = None) -> None: + lineno: int, state: Any) -> None: self.env = env self.reporter = reporter self.genopt = options self.lineno = lineno self.filename_set = set() # type: Set[str] self.result = StringList() - - if state: - self.state = state - else: - # create fake object for self.state.document.settings.tab_width - warnings.warn('DocumenterBridge requires a state object on instantiation.', - RemovedInSphinx40Warning) - settings = Struct(tab_width=8) - document = Struct(settings=settings) - self.state = Struct(document=document) + self.state = state def warn(self, msg: str) -> None: logger.warning(msg, location=(self.env.docname, self.lineno)) -- cgit v1.2.1 From b718aef7d876ca6a9e08fc225f8f2031845083a4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 12 Nov 2020 02:52:50 +0900 Subject: Do isort --- sphinx/ext/autodoc/directive.py | 1 - 1 file changed, 1 deletion(-) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 5543059cb..604a9d51d 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -21,7 +21,6 @@ from sphinx.util import logging from sphinx.util.docutils import SphinxDirective, switch_source_input from sphinx.util.nodes import nested_parse_with_titles - logger = logging.getLogger(__name__) -- cgit v1.2.1 From 1d4c414319598320f95eed245e4a2f9ad3e5a668 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Mon, 15 Mar 2021 13:11:07 +0900 Subject: refactor: Use PEP-526 based variable annotation (sphinx.ext) --- sphinx/ext/autodoc/directive.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 69177f271..78e17b867 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -56,7 +56,7 @@ class DocumenterBridge: self._reporter = reporter self.genopt = options self.lineno = lineno - self.filename_set = set() # type: Set[str] + self.filename_set: Set[str] = set() self.result = StringList() self.state = state @@ -101,7 +101,7 @@ def parse_generated_content(state: RSTState, content: StringList, documenter: Do """Parse a generated content by Documenter.""" with switch_source_input(state, content): if documenter.titles_allowed: - node = nodes.section() # type: Element + node: Element = nodes.section() # necessary so that the child nodes get the right source/line set node.document = state.document nested_parse_with_titles(state, content, node) -- cgit v1.2.1 From cb654d287b0296a5acc539f962c7ef1ecc4a523f Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 21 Mar 2021 00:52:49 +0900 Subject: Rename DocumenterBridge.filename_set to record_dependencies DocumenterBridge.filename_set has been used since its beginning. On the other hand, in docutils, record_dependencies attribute is well-used to store the list of dependency files. So this renames it to docutils' standard attribute. --- sphinx/ext/autodoc/directive.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 78e17b867..a6608698d 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -16,7 +16,7 @@ from docutils.statemachine import StringList from docutils.utils import Reporter, assemble_option_dict from sphinx.config import Config -from sphinx.deprecation import RemovedInSphinx50Warning +from sphinx.deprecation import RemovedInSphinx50Warning, RemovedInSphinx60Warning from sphinx.environment import BuildEnvironment from sphinx.ext.autodoc import Documenter, Options from sphinx.util import logging @@ -56,13 +56,19 @@ class DocumenterBridge: self._reporter = reporter self.genopt = options self.lineno = lineno - self.filename_set: Set[str] = set() + self.record_dependencies: Set[str] = set() self.result = StringList() self.state = state def warn(self, msg: str) -> None: logger.warning(msg, location=(self.env.docname, self.lineno)) + @property + def filename_set(self) -> Set: + warnings.warn('DocumenterBridge.filename_set is deprecated.', + RemovedInSphinx60Warning, stacklevel=2) + return self.record_dependencies + @property def reporter(self) -> Reporter: warnings.warn('DocumenterBridge.reporter is deprecated.', @@ -158,7 +164,7 @@ class AutodocDirective(SphinxDirective): # record all filenames as dependencies -- this will at least # partially make automatic invalidation possible - for fn in params.filename_set: + for fn in params.record_dependencies: self.state.document.settings.record_dependencies.add(fn) result = parse_generated_content(self.state, params.result, documenter) -- cgit v1.2.1 From 6007bbf797000e818daa220aa39e46c744240024 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 21 Mar 2021 01:09:03 +0900 Subject: Deprecate DocumenterBridge.warn() Since 1.6, sphinx.util.logging module became the default logging interface of Sphinx. It allows sphinx-components to output log without the app (or env) object. According to the policy, DocumenterBridge.warn() is no longer needed and should be replaced by the logging module. --- sphinx/ext/autodoc/directive.py | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index a6608698d..8ed622d23 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -61,6 +61,9 @@ class DocumenterBridge: self.state = state def warn(self, msg: str) -> None: + warnings.warn('DocumenterBridge.warn is deprecated. Plase use sphinx.util.logging ' + 'module instead.', + RemovedInSphinx60Warning, stacklevel=2) logger.warning(msg, location=(self.env.docname, self.lineno)) @property -- cgit v1.2.1 From 1b0d4672a41e91289292dd5d05b7fe09a8feec17 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 4 Apr 2021 14:37:15 +0900 Subject: refactor: use raw Type for type annotations --- sphinx/ext/autodoc/directive.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sphinx/ext/autodoc/directive.py') diff --git a/sphinx/ext/autodoc/directive.py b/sphinx/ext/autodoc/directive.py index 8ed622d23..c58d0c411 100644 --- a/sphinx/ext/autodoc/directive.py +++ b/sphinx/ext/autodoc/directive.py @@ -79,7 +79,7 @@ class DocumenterBridge: return self._reporter -def process_documenter_options(documenter: "Type[Documenter]", config: Config, options: Dict +def process_documenter_options(documenter: Type[Documenter], config: Config, options: Dict ) -> Options: """Recognize options of Documenter from user input.""" for name in AUTODOC_DEFAULT_OPTIONS: -- cgit v1.2.1