From 421a544aabcf66dadcd947e5d7afee39d48c1266 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 26 Apr 2020 02:15:52 +0900 Subject: [PATCH] Fix #6703: autodoc: incremental build does not work for imported objects --- CHANGES | 2 ++ sphinx/ext/autodoc/__init__.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 453cfe3e8..60e71e23c 100644 --- a/CHANGES +++ b/CHANGES @@ -62,6 +62,8 @@ Features added Bugs fixed ---------- +* #6703: autodoc: incremental build does not work for imported objects + Testing -------- diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index c572c4fff..3bfda9e1b 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -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():