Fix #6703: autodoc: incremental build does not work for imported objects

This commit is contained in:
Takeshi KOMIYA 2020-04-26 02:15:52 +09:00
parent 56ed2991fd
commit 421a544aab
2 changed files with 12 additions and 1 deletions

View File

@ -62,6 +62,8 @@ Features added
Bugs fixed
----------
* #6703: autodoc: incremental build does not work for imported objects
Testing
--------

View File

@ -732,7 +732,8 @@ class Documenter:
# where the attribute documentation would actually be found in.
# This is used for situations where you have a module that collects the
# functions and classes of internal submodules.
self.real_modname = real_modname or self.get_real_modname() # type: str
guess_modname = self.get_real_modname()
self.real_modname = real_modname or guess_modname
# try to also get a source code analyzer for attribute docs
try:
@ -750,6 +751,14 @@ class Documenter:
else:
self.directive.filename_set.add(self.analyzer.srcname)
if self.real_modname != guess_modname:
# Add module to dependency list if target object is defined in other module.
try:
analyzer = ModuleAnalyzer.for_module(guess_modname)
self.directive.filename_set.add(analyzer.srcname)
except PycodeError:
pass
# check __module__ of object (for members not given explicitly)
if check_module:
if not self.check_module():