summaryrefslogtreecommitdiff
path: root/sphinx/ext/autosummary/generate.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-04 23:44:52 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-07-04 23:44:52 +0900
commit9fd9edebb47a3a5eda8c6065b12b71cdb0985a73 (patch)
tree70a79d15fa7ed3f2c1ce8eb68eaf74a97ae271e1 /sphinx/ext/autosummary/generate.py
parentf27dfe337e58332ce8632462270deccc3432ecaf (diff)
parentf743df6c20eb7895ff299fc8d8b43353f20d9116 (diff)
downloadsphinx-git-9fd9edebb47a3a5eda8c6065b12b71cdb0985a73.tar.gz
Merge branch '3.1.x' into 3.x
Diffstat (limited to 'sphinx/ext/autosummary/generate.py')
-rw-r--r--sphinx/ext/autosummary/generate.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py
index 7583d9894..d908e2088 100644
--- a/sphinx/ext/autosummary/generate.py
+++ b/sphinx/ext/autosummary/generate.py
@@ -230,7 +230,8 @@ class ModuleScanner:
def generate_autosummary_content(name: str, obj: Any, parent: Any,
template: AutosummaryRenderer, template_name: str,
imported_members: bool, app: Any,
- recursive: bool, context: Dict) -> str:
+ recursive: bool, context: Dict,
+ modname: str = None, qualname: str = None) -> str:
doc = get_documenter(app, obj, parent)
def skip_member(obj: Any, name: str, objtype: str) -> bool:
@@ -319,7 +320,9 @@ def generate_autosummary_content(name: str, obj: Any, parent: Any,
ns['attributes'], ns['all_attributes'] = \
get_members(obj, {'attribute', 'property'})
- modname, qualname = split_full_qualified_name(name)
+ if modname is None or qualname is None:
+ modname, qualname = split_full_qualified_name(name)
+
if doc.objtype in ('method', 'attribute', 'property'):
ns['class'] = qualname.rsplit(".", 1)[0]
@@ -401,7 +404,8 @@ def generate_autosummary_docs(sources: List[str], output_dir: str = None,
ensuredir(path)
try:
- name, obj, parent, mod_name = import_by_name(entry.name)
+ name, obj, parent, modname = import_by_name(entry.name)
+ qualname = name.replace(modname + ".", "")
except ImportError as e:
_warn(__('[autosummary] failed to import %r: %s') % (entry.name, e))
continue
@@ -411,7 +415,8 @@ def generate_autosummary_docs(sources: List[str], output_dir: str = None,
context.update(app.config.autosummary_context)
content = generate_autosummary_content(name, obj, parent, template, entry.template,
- imported_members, app, entry.recursive, context)
+ imported_members, app, entry.recursive, context,
+ modname, qualname)
filename = os.path.join(path, name + suffix)
if os.path.isfile(filename):