summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index d5fb91b..0542fa5 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1055,9 +1055,11 @@ class TextDoc(Doc):
if visiblename(key, all):
data.append((key, value))
+ modpkgs = []
+ modpkgs_names = set()
if hasattr(object, '__path__'):
- modpkgs = []
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
+ modpkgs_names.add(modname)
if ispkg:
modpkgs.append(modname + ' (package)')
else:
@@ -1067,6 +1069,16 @@ class TextDoc(Doc):
result = result + self.section(
'PACKAGE CONTENTS', '\n'.join(modpkgs))
+ # Detect submodules as sometimes created by C extensions
+ submodules = []
+ for key, value in inspect.getmembers(object, inspect.ismodule):
+ if value.__name__.startswith(name + '.') and key not in modpkgs_names:
+ submodules.append(key)
+ if submodules:
+ submodules.sort()
+ result = result + self.section(
+ 'SUBMODULES', join(submodules, '\n'))
+
if classes:
classlist = [value for key, value in classes]
contents = [self.formattree(