diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-11-10 00:31:44 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-10 00:31:44 +0900 |
commit | ed5af2461f77a5bd7d1cc371877a0ab961224f79 (patch) | |
tree | 51209e90bbad638bd02573537cea39bed76b8f0a | |
parent | 787444ff182c4a3c490e26647f1cd99872a575ba (diff) | |
parent | 0be0cd606cdc240480ee5e57089562a9007da6bf (diff) | |
download | sphinx-git-ed5af2461f77a5bd7d1cc371877a0ab961224f79.tar.gz |
Merge branch '3.3.x' into 7727_autosummary_PycodeError
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | sphinx/ext/autodoc/__init__.py | 3 | ||||
-rw-r--r-- | sphinx/pycode/__init__.py | 13 |
3 files changed, 11 insertions, 6 deletions
@@ -16,6 +16,7 @@ Features added Bugs fixed ---------- +* #8372: autodoc: autoclass directive became slower than Sphinx-3.2 * #7727: autosummary: raise PycodeError when documenting python package without __init__.py * #8364: C, properly initialize attributes in empty symbols. diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 7343d41b6..b69eb18a0 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -1503,6 +1503,9 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: qualname = '.'.join([cls.__qualname__, self._signature_method_name]) if qualname in analyzer.overloads: return analyzer.overloads.get(qualname) + elif qualname in analyzer.tagorder: + # the constructor is defined in the class, but not overrided. + return [] except PycodeError: pass diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py index 4fef4a394..b7163072f 100644 --- a/sphinx/pycode/__init__.py +++ b/sphinx/pycode/__init__.py @@ -150,9 +150,13 @@ class ModuleAnalyzer: 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 def parse(self) -> None: """Parse the source code.""" + if self._parsed: + return None + try: parser = Parser(self.code, self._encoding) parser.parse() @@ -169,21 +173,18 @@ class ModuleAnalyzer: self.overloads = parser.overloads self.tags = parser.definitions self.tagorder = parser.deforders + self._parsed = True except Exception as exc: raise PycodeError('parsing %r failed: %r' % (self.srcname, exc)) from exc def find_attr_docs(self) -> Dict[Tuple[str, str], List[str]]: """Find class and module-level attributes and their documentation.""" - if self.attr_docs is None: - self.parse() - + self.parse() return self.attr_docs def find_tags(self) -> Dict[str, Tuple[str, int, int]]: """Find class, function and method definitions and their location.""" - if self.tags is None: - self.parse() - + self.parse() return self.tags @property |