Index: Lib/pydoc.py =================================================================== --- Lib/pydoc.py (revision 86477) +++ Lib/pydoc.py (working copy) @@ -26,13 +26,13 @@ Module docs for core modules are assumed to be in - http://docs.python.org/library/ + http://docs.python.org/release/X.Y[.Z]/library/ This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library Reference Manual pages. """ - +__all__ = ['help'] __author__ = "Ka-Ping Yee " __date__ = "26 February 2001" @@ -54,14 +54,7 @@ import sys, imp, os, re, inspect, builtins, pkgutil from reprlib import Repr from traceback import extract_tb as _extract_tb -try: - from collections import deque -except ImportError: - # Python 2.3 compatibility - class deque(list): - def popleft(self): - return self.pop(0) - +from collections import deque # --------------------------------------------------------- common routines def pathdirs(): @@ -159,7 +152,8 @@ # Certain special names are redundant. _hidden_names = ('__builtins__', '__doc__', '__file__', '__path__', '__module__', '__name__', '__slots__', '__package__', - '__cached__') + '__cached__', '__author__', '__credits__', '__date__', + '__version__') if name in _hidden_names: return 0 # Private names are hidden, but special names are displayed. if name.startswith('__') and name.endswith('__'): return 1 @@ -305,7 +299,18 @@ # ---------------------------------------------------- formatter base class +def _version_string(): + ver = sys.version_info + if ver.micro == 0: + return '%d.%d' % ver[:2] + return '%d.%d.%d' % ver[:3] + class Doc: + + PYTHONDOCS = os.environ.get("PYTHONDOCS", + "http://docs.python.org/release/%s/library" + % _version_string()) + def document(self, object, name=None, *args): """Generate documentation for an object.""" args = (object, name) + args @@ -340,8 +345,8 @@ except TypeError: file = '(built-in)' - docloc = os.environ.get("PYTHONDOCS", - "http://docs.python.org/library") + docloc = os.environ.get("PYTHONDOCS", self.PYTHONDOCS) + basedir = os.path.join(sys.exec_prefix, "lib", "python"+sys.version[0:3]) if (isinstance(object, type(os)) and @@ -1016,22 +1021,17 @@ name = object.__name__ # ignore the passed-in name synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop)) - - try: - all = object.__all__ - except AttributeError: - all = None - - try: - file = inspect.getabsfile(object) - except TypeError: - file = '(built-in)' - result = result + self.section('FILE', file) - + all = getattr(object, '__all__', None) docloc = self.getdocloc(object) if docloc is not None: - result = result + self.section('MODULE DOCS', docloc) + result = result + self.section('MODULE REFERENCE', docloc + """ +The following documentation is automatically generated from the Python source +files. It may be incomplete, incorrect or include features that are considered +implementation detail and may vary between Python implementations. When in +doubt, consult the module reference at the location listed above. +""") + if desc: result = result + self.section('DESCRIPTION', desc) @@ -1109,6 +1109,11 @@ result = result + self.section('AUTHOR', str(object.__author__)) if hasattr(object, '__credits__'): result = result + self.section('CREDITS', str(object.__credits__)) + try: + file = inspect.getabsfile(object) + except TypeError: + file = '(built-in)' + result = result + self.section('FILE', file) return result def docclass(self, object, name=None, mod=None):