classification
Title: pydoc should respect __all__
Type: enhancement Stage:
Components: Demos and Tools Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ping Nosy List: david_abrahams, ping, skip.montanaro
Priority: normal Keywords:

Created on 2002-03-09 02:30 by david_abrahams, last changed 2007-08-29 00:58 by skip.montanaro. This issue is now closed.

Messages (2)
msg53500 - (view) Author: David Abrahams (david_abrahams) Date: 2002-03-09 02:30
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)



msg55395 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2007-08-29 00:58
This was fixed in r36142 (i.e., ages ago).
History
Date User Action Args
2007-08-29 00:58:19skip.montanarosetstatus: open -> closed
resolution: fixed
messages: + msg55395
nosy: + skip.montanaro
2002-03-09 02:30:30david_abrahamscreate