diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-22 02:47:33 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-22 02:59:29 +0900 |
commit | 8e29d57395f9cc964ac0de7e407c84bb45ec7906 (patch) | |
tree | 964dceb3de4ebb113cc54a79098a35bcc9795b61 /sphinx/pycode | |
parent | 68aa4fb29e7dfe521749e1e14f750d7afabb3481 (diff) | |
download | sphinx-git-8e29d57395f9cc964ac0de7e407c84bb45ec7906.tar.gz |
Rename ModuleAnalyzer.parse() to analyze()
The word "analyze" is much appropriate for "ModuleAnalyzer" instead
of "parse".
Diffstat (limited to 'sphinx/pycode')
-rw-r--r-- | sphinx/pycode/__init__.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index c1c374bb9..05f45a6d8 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -19,7 +19,7 @@ from os import path from typing import IO, Any, Dict, List, Optional, Tuple from zipfile import ZipFile -from sphinx.deprecation import RemovedInSphinx40Warning +from sphinx.deprecation import RemovedInSphinx40Warning, RemovedInSphinx50Warning from sphinx.errors import PycodeError from sphinx.pycode.parser import Parser @@ -143,18 +143,24 @@ class ModuleAnalyzer: self._encoding = None self.code = source.read() - # will be filled by parse() + # will be filled by analyze() self.annotations = None # type: Dict[Tuple[str, str], str] self.attr_docs = None # type: Dict[Tuple[str, str], List[str]] self.finals = None # type: List[str] self.overloads = None # type: Dict[str, List[Signature]] self.tagorder = None # type: Dict[str, int] self.tags = None # type: Dict[str, Tuple[str, int, int]] - self._parsed = False + self._analyzed = False def parse(self) -> None: """Parse the source code.""" - if self._parsed: + warnings.warn('ModuleAnalyzer.parse() is deprecated.', + RemovedInSphinx50Warning, stacklevel=2) + self.analyze() + + def analyze(self) -> None: + """Analyze the source code.""" + if self._analyzed: return None try: @@ -179,12 +185,12 @@ class ModuleAnalyzer: def find_attr_docs(self) -> Dict[Tuple[str, str], List[str]]: """Find class and module-level attributes and their documentation.""" - self.parse() + self.analyze() return self.attr_docs def find_tags(self) -> Dict[str, Tuple[str, int, int]]: """Find class, function and method definitions and their location.""" - self.parse() + self.analyze() return self.tags @property |