Skip to content

Commit

Permalink
Fix sphinx-doc#9876: autodoc: Failed to document a class on binary mo…
Browse files Browse the repository at this point in the history
…dule
  • Loading branch information
tk0miya committed Jan 30, 2022
1 parent 99947d9 commit bd98673
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGES
Expand Up @@ -16,6 +16,9 @@ Features added
Bugs fixed
----------

* #9876: autodoc: Failed to document an imported class that is built from native
binary module

Testing
--------

Expand Down
9 changes: 6 additions & 3 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -1771,9 +1771,12 @@ def get_variable_comment(self) -> Optional[List[str]]:
def add_content(self, more_content: Optional[StringList], no_docstring: bool = False
) -> None:
if self.doc_as_attr and self.modname != self.get_real_modname():
# override analyzer to obtain doccomment around its definition.
self.analyzer = ModuleAnalyzer.for_module(self.modname)
self.analyzer.analyze()
try:
# override analyzer to obtain doccomment around its definition.
self.analyzer = ModuleAnalyzer.for_module(self.modname)
self.analyzer.analyze()
except PycodeError:
pass

if self.doc_as_attr and not self.get_variable_comment():
try:
Expand Down

0 comments on commit bd98673

Please sign in to comment.