mirror of
https://github.com/python/cpython.git
synced 2025-07-28 05:34:31 +00:00
#1715: include sub-extension modules in pydoc text output.
This commit is contained in:
parent
dd76e05dd9
commit
f2dae0e14a
3 changed files with 21 additions and 1 deletions
14
Lib/pydoc.py
14
Lib/pydoc.py
|
@ -1051,9 +1051,11 @@ class TextDoc(Doc):
|
||||||
if visiblename(key, all):
|
if visiblename(key, all):
|
||||||
data.append((key, value))
|
data.append((key, value))
|
||||||
|
|
||||||
|
modpkgs = []
|
||||||
|
modpkgs_names = set()
|
||||||
if hasattr(object, '__path__'):
|
if hasattr(object, '__path__'):
|
||||||
modpkgs = []
|
|
||||||
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
|
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
|
||||||
|
modpkgs_names.add(modname)
|
||||||
if ispkg:
|
if ispkg:
|
||||||
modpkgs.append(modname + ' (package)')
|
modpkgs.append(modname + ' (package)')
|
||||||
else:
|
else:
|
||||||
|
@ -1063,6 +1065,16 @@ class TextDoc(Doc):
|
||||||
result = result + self.section(
|
result = result + self.section(
|
||||||
'PACKAGE CONTENTS', join(modpkgs, '\n'))
|
'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:
|
if classes:
|
||||||
classlist = map(lambda (key, value): value, classes)
|
classlist = map(lambda (key, value): value, classes)
|
||||||
contents = [self.formattree(
|
contents = [self.formattree(
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
"""Something just to look at via pydoc."""
|
"""Something just to look at via pydoc."""
|
||||||
|
|
||||||
|
import types
|
||||||
|
|
||||||
class A_classic:
|
class A_classic:
|
||||||
"A classic class."
|
"A classic class."
|
||||||
def A_method(self):
|
def A_method(self):
|
||||||
|
@ -208,3 +210,7 @@ class FunkyProperties(object):
|
||||||
del inst.desc[self.attr]
|
del inst.desc[self.attr]
|
||||||
|
|
||||||
x = property(get_desc('x'), set_desc('x'), del_desc('x'), 'prop x')
|
x = property(get_desc('x'), set_desc('x'), del_desc('x'), 'prop x')
|
||||||
|
|
||||||
|
|
||||||
|
submodule = types.ModuleType(__name__ + '.submodule',
|
||||||
|
"""A submodule, which should appear in its parent's summary""")
|
||||||
|
|
|
@ -372,6 +372,8 @@ Core and builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- #1715: include sub-extension modules in pydoc's text output.
|
||||||
|
|
||||||
- #1836: fix an off-by-one bug in TimedRotatingHandler's rollover
|
- #1836: fix an off-by-one bug in TimedRotatingHandler's rollover
|
||||||
time calculation.
|
time calculation.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue