@@ -26,13 +26,13 @@ class or function within a module or module in a package. If the
26
26
27
27
Module docs for core modules are assumed to be in
28
28
29
- http://docs.python.org/library/
29
+ http://docs.python.org/X.Y/ library/
30
30
31
31
This can be overridden by setting the PYTHONDOCS environment variable
32
32
to a different URL or to a local directory containing the Library
33
33
Reference Manual pages.
34
34
"""
35
-
35
+ __all__ = [ 'help' ]
36
36
__author__ = "Ka-Ping Yee <ping@lfw.org>"
37
37
__date__ = "26 February 2001"
38
38
@@ -54,14 +54,7 @@ class or function within a module or module in a package. If the
54
54
import sys , imp , os , re , inspect , builtins , pkgutil
55
55
from reprlib import Repr
56
56
from traceback import extract_tb as _extract_tb
57
- try :
58
- from collections import deque
59
- except ImportError :
60
- # Python 2.3 compatibility
61
- class deque (list ):
62
- def popleft (self ):
63
- return self .pop (0 )
64
-
57
+ from collections import deque
65
58
# --------------------------------------------------------- common routines
66
59
67
60
def pathdirs ():
@@ -159,7 +152,8 @@ def visiblename(name, all=None):
159
152
# Certain special names are redundant.
160
153
_hidden_names = ('__builtins__' , '__doc__' , '__file__' , '__path__' ,
161
154
'__module__' , '__name__' , '__slots__' , '__package__' ,
162
- '__cached__' )
155
+ '__cached__' , '__author__' , '__credits__' , '__date__' ,
156
+ '__version__' )
163
157
if name in _hidden_names : return 0
164
158
# Private names are hidden, but special names are displayed.
165
159
if name .startswith ('__' ) and name .endswith ('__' ): return 1
@@ -306,6 +300,11 @@ def safeimport(path, forceload=0, cache={}):
306
300
# ---------------------------------------------------- formatter base class
307
301
308
302
class Doc :
303
+
304
+ PYTHONDOCS = os .environ .get ("PYTHONDOCS" ,
305
+ "http://docs.python.org/%d.%d/library"
306
+ % sys .version_info [:2 ])
307
+
309
308
def document (self , object , name = None , * args ):
310
309
"""Generate documentation for an object."""
311
310
args = (object , name ) + args
@@ -340,10 +339,10 @@ def getdocloc(self, object):
340
339
except TypeError :
341
340
file = '(built-in)'
342
341
343
- docloc = os .environ .get ("PYTHONDOCS" ,
344
- "http://docs.python.org/library" )
342
+ docloc = os .environ .get ("PYTHONDOCS" , self . PYTHONDOCS )
343
+
345
344
basedir = os .path .join (sys .exec_prefix , "lib" ,
346
- "python" + sys .version [ 0 : 3 ])
345
+ "python%d.%d" % sys .version_info [: 2 ])
347
346
if (isinstance (object , type (os )) and
348
347
(object .__name__ in ('errno' , 'exceptions' , 'gc' , 'imp' ,
349
348
'marshal' , 'posix' , 'signal' , 'sys' ,
@@ -607,7 +606,7 @@ def docmodule(self, object, name=None, mod=None, *ignored):
607
606
head = head + ' (%s)' % ', ' .join (info )
608
607
docloc = self .getdocloc (object )
609
608
if docloc is not None :
610
- docloc = '<br><a href="%(docloc)s">Module Docs </a>' % locals ()
609
+ docloc = '<br><a href="%(docloc)s">Module Reference </a>' % locals ()
611
610
else :
612
611
docloc = ''
613
612
result = self .heading (
@@ -1016,21 +1015,16 @@ def docmodule(self, object, name=None, mod=None):
1016
1015
name = object .__name__ # ignore the passed-in name
1017
1016
synop , desc = splitdoc (getdoc (object ))
1018
1017
result = self .section ('NAME' , name + (synop and ' - ' + synop ))
1019
-
1020
- try :
1021
- all = object .__all__
1022
- except AttributeError :
1023
- all = None
1024
-
1025
- try :
1026
- file = inspect .getabsfile (object )
1027
- except TypeError :
1028
- file = '(built-in)'
1029
- result = result + self .section ('FILE' , file )
1030
-
1018
+ all = getattr (object , '__all__' , None )
1031
1019
docloc = self .getdocloc (object )
1032
1020
if docloc is not None :
1033
- result = result + self .section ('MODULE DOCS' , docloc )
1021
+ result = result + self .section ('MODULE REFERENCE' , docloc + """
1022
+
1023
+ The following documentation is automatically generated from the Python source
1024
+ files. It may be incomplete, incorrect or include features that are considered
1025
+ implementation detail and may vary between Python implementations. When in
1026
+ doubt, consult the module reference at the location listed above.
1027
+ """ )
1034
1028
1035
1029
if desc :
1036
1030
result = result + self .section ('DESCRIPTION' , desc )
@@ -1109,6 +1103,11 @@ def docmodule(self, object, name=None, mod=None):
1109
1103
result = result + self .section ('AUTHOR' , str (object .__author__ ))
1110
1104
if hasattr (object , '__credits__' ):
1111
1105
result = result + self .section ('CREDITS' , str (object .__credits__ ))
1106
+ try :
1107
+ file = inspect .getabsfile (object )
1108
+ except TypeError :
1109
+ file = '(built-in)'
1110
+ result = result + self .section ('FILE' , file )
1112
1111
return result
1113
1112
1114
1113
def docclass (self , object , name = None , mod = None ):
0 commit comments