[Python-bugs-list] [ python-Feature Requests-527668 ] pydoc should respect __all__

noreply@sourceforge.net noreply@sourceforge.net
Fri, 08 Mar 2002 18:30:30 -0800


Feature Requests item #527668, was opened at 2002-03-08 21:30
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=527668&group_id=5470

Category: Demos and Tools
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: David Abrahams (david_abrahams)
Assigned to: Nobody/Anonymous (nobody)
Summary: pydoc should respect __all__

Initial Comment:
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)





----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=355470&aid=527668&group_id=5470