[Python-checkins] python/dist/src/Lib pydoc.py,1.91,1.92

montanaro at users.sourceforge.net montanaro at users.sourceforge.net
Fri Jun 11 00:46:15 EDT 2004


Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28680
Modified Files:
	pydoc.py 
Log Message:
Respect a module's __all__ attribute. Closes #969938.
Index: pydoc.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pydoc.py,v
retrieving revision 1.91
retrieving revision 1.92
diff -C2 -d -r1.91 -r1.92
*** pydoc.py	7 Jun 2004 02:40:05 -0000	1.91
--- pydoc.py	11 Jun 2004 04:46:12 -0000	1.92
***************
*** 152,156 ****
 return yes, no
 
! def visiblename(name):
 """Decide whether to show documentation on a variable."""
 # Certain special names are redundant.
--- 152,156 ----
 return yes, no
 
! def visiblename(name, all=None):
 """Decide whether to show documentation on a variable."""
 # Certain special names are redundant.
***************
*** 159,163 ****
 # Private names are hidden, but special names are displayed.
 if name.startswith('__') and name.endswith('__'): return 1
! return not name.startswith('_')
 
 # ----------------------------------------------------- module manipulation
--- 159,167 ----
 # Private names are hidden, but special names are displayed.
 if name.startswith('__') and name.endswith('__'): return 1
! if all is not None:
! # only document that which the programmer exported in __all__
! return name in all
! else:
! return not name.startswith('_')
 
 # ----------------------------------------------------- module manipulation
***************
*** 545,548 ****
--- 549,556 ----
 """Produce HTML documentation for a module object."""
 name = object.__name__ # ignore the passed-in name
+ try:
+ all = object.__all__
+ except AttributeError:
+ all = None
 parts = split(name, '.')
 links = []
***************
*** 586,590 ****
 for key, value in inspect.getmembers(object, inspect.isclass):
 if (inspect.getmodule(value) or object) is object:
! if visiblename(key):
 classes.append((key, value))
 cdict[key] = cdict[value] = '#' + key
--- 594,598 ----
 for key, value in inspect.getmembers(object, inspect.isclass):
 if (inspect.getmodule(value) or object) is object:
! if visiblename(key, all):
 classes.append((key, value))
 cdict[key] = cdict[value] = '#' + key
***************
*** 600,604 ****
 for key, value in inspect.getmembers(object, inspect.isroutine):
 if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
! if visiblename(key):
 funcs.append((key, value))
 fdict[key] = '#-' + key
--- 608,612 ----
 for key, value in inspect.getmembers(object, inspect.isroutine):
 if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
! if visiblename(key, all):
 funcs.append((key, value))
 fdict[key] = '#-' + key
***************
*** 606,610 ****
 data = []
 for key, value in inspect.getmembers(object, isdata):
! if visiblename(key):
 data.append((key, value))
 
--- 614,618 ----
 data = []
 for key, value in inspect.getmembers(object, isdata):
! if visiblename(key, all):
 data.append((key, value))
 
***************
*** 989,992 ****
--- 997,1005 ----
 
 try:
+ all = object.__all__
+ except AttributeError:
+ all = None
+ 
+ try:
 file = inspect.getabsfile(object)
 except TypeError:
***************
*** 1004,1017 ****
 for key, value in inspect.getmembers(object, inspect.isclass):
 if (inspect.getmodule(value) or object) is object:
! if visiblename(key):
 classes.append((key, value))
 funcs = []
 for key, value in inspect.getmembers(object, inspect.isroutine):
 if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
! if visiblename(key):
 funcs.append((key, value))
 data = []
 for key, value in inspect.getmembers(object, isdata):
! if visiblename(key):
 data.append((key, value))
 
--- 1017,1030 ----
 for key, value in inspect.getmembers(object, inspect.isclass):
 if (inspect.getmodule(value) or object) is object:
! if visiblename(key, all):
 classes.append((key, value))
 funcs = []
 for key, value in inspect.getmembers(object, inspect.isroutine):
 if inspect.isbuiltin(value) or inspect.getmodule(value) is object:
! if visiblename(key, all):
 funcs.append((key, value))
 data = []
 for key, value in inspect.getmembers(object, isdata):
! if visiblename(key, all):
 data.append((key, value))
 


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /