Message53500
If __all__ is set in a module, pydoc should only
document those attributes, IMO. For example:
# foo.py
__all__ = [ 'hello' ]
from sys import *
def hello():
"""hi there"""
print "hi"
def goodbye():
"""ciao"""
print "bye"
>>> import foo, pydoc
>>> pydoc.help(foo)
Help on module foo:
NAME
foo
FILE
e:\temp\foo.py
FUNCTIONS
goodbye()
ciao
hello()
hi there
DATA
__all__ = ['hello']
__file__ = 'foo.py'
__name__ = 'foo'
-------
Whereas right now it dumps everything from sys. A
little proof-of-concept (not quite a patch):
import imp
import foo as _foo # do this programmatically using
the imp module
if !hasattr(_foo,'__all__'):
_foo.__all__ = _foo.__dict__.keys()
foo = imp.new_module('foo')
# Get exported attributes
for a in _foo.__all__:
setattr(foo, a, getattr(_foo, a))
# Get special attributes
for a in _foo.__dict__.keys():
if len(a) > 4 and a[:2] == '__' and a[-2:] == '__':
setattr(foo, a, getattr(_foo, a))
import pydoc
pydoc.help(foo)
|
|
Date |
User |
Action |
Args |
2007-08-23 16:02:07 | admin | link | issue527668 messages |
2007-08-23 16:02:07 | admin | create | |
|