diff options
author | Georg Brandl <georg@python.org> | 2008-01-21 21:05:49 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-01-21 21:05:49 (GMT) |
commit | f2dae0e14a79df11135fea05c20f66bcada51c06 (patch) | |
tree | 60195322754238c749b0476c3f797cd1904011a4 /Lib/pydoc.py | |
parent | dd76e05dd91dbf948a5bf6561b7f5a8f2dfbbebe (diff) | |
download | cpython-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-x | Lib/pydoc.py | 14 |
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( |