diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-22 10:04:07 +0300 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-22 10:04:07 +0300 |
commit | a00d62c4455f9038c228acae453ad35387ef1041 (patch) | |
tree | cfa368272d44c8505606706749a02529c441d717 /sphinx/pycode | |
parent | 1e50ab98e54b65cde3e7027a3eaa19ada2a25312 (diff) | |
parent | 3ea1ec84cc610f7a9f4f6b354e264565254923ff (diff) |
Merge branch '3.x'
Diffstat (limited to 'sphinx/pycode')
-rw-r--r-- | sphinx/pycode/__init__.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index 9ece164b1..718380881 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -18,6 +18,7 @@ from os import path from typing import IO, Any, Dict, List, Optional, Tuple from zipfile import ZipFile +from sphinx.deprecation import RemovedInSphinx50Warning from sphinx.errors import PycodeError from sphinx.pycode.parser import Parser @@ -132,18 +133,24 @@ class ModuleAnalyzer: # cache the source code as well 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: @@ -168,10 +175,10 @@ 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 |