summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-21 21:05:49 (GMT)
committerGeorg Brandl <georg@python.org>2008-01-21 21:05:49 (GMT)
commitf2dae0e14a79df11135fea05c20f66bcada51c06 (patch)
tree60195322754238c749b0476c3f797cd1904011a4 /Lib/pydoc.py
parentdd76e05dd91dbf948a5bf6561b7f5a8f2dfbbebe (diff)
downloadcpython-f2dae0e14a79df11135fea05c20f66bcada51c06.zip
cpython-f2dae0e14a79df11135fea05c20f66bcada51c06.tar.gz
cpython-f2dae0e14a79df11135fea05c20f66bcada51c06.tar.bz2
#1715: include sub-extension modules in pydoc text output.
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 c2b2088..26cd55d 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1051,9 +1051,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:
@@ -1063,6 +1065,16 @@ class TextDoc(Doc):
result = result + self.section(
'PACKAGE CONTENTS', join(modpkgs, '\n'))
+ # 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 = map(lambda (key, value): value, classes)
contents = [self.formattree(