cpython: b41404a3f7d4 (original) (raw)

--- a/Doc/library/pydoc.rst +++ b/Doc/library/pydoc.rst @@ -63,7 +63,9 @@ documents precisely the version of the m Python interpreter and typed import spam. Module docs for core modules are assumed to reside in -http://docs.python.org/library/. This can be overridden by setting the -:envvar:PYTHONDOCS environment variable to a different URL or to a local -directory containing the Library Reference Manual pages. +http://docs.python.org/X.Y/library/ where X and Y are the +major and minor version numbers of the Python interpreter. This can +be overridden by setting the :envvar:PYTHONDOCS environment variable +to a different URL or to a local directory containing the Library +Reference Manual pages.

--- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -26,13 +26,13 @@ to a file named ".html". Module docs for core modules are assumed to be in

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 ping@lfw.org" date = "26 February 2001" @@ -54,14 +54,7 @@ Richard Chamberlain, for the first imple import sys, imp, os, re, inspect, builtins, pkgutil from reprlib import Repr from traceback import extract_tb as _extract_tb -try:

-except ImportError:

- +from collections import deque

--------------------------------------------------------- common routines

def pathdirs(): @@ -159,7 +152,8 @@ def visiblename(name, all=None): # Certain special names are redundant. _hidden_names = ('builtins', 'doc', 'file', 'path', 'module', 'name', 'slots', 'package',

---------------------------------------------------- formatter base class

class Doc: +

+ def document(self, object, name=None, *args): """Generate documentation for an object.""" args = (object, name) + args @@ -340,10 +339,10 @@ class Doc: except TypeError: file = '(built-in)'

+ basedir = os.path.join(sys.exec_prefix, "lib",

@@ -607,7 +606,7 @@ class HTMLDoc(Doc): head = head + ' (%s)' % ', '.join(info) docloc = self.getdocloc(object) if docloc is not None:

@@ -1016,21 +1015,16 @@ class TextDoc(Doc): name = object.name # ignore the passed-in name synop, desc = splitdoc(getdoc(object)) result = self.section('NAME', name + (synop and ' - ' + synop)) -

-

-

+ +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 +1103,11 @@ class TextDoc(Doc): result = result + self.section('AUTHOR', str(object.author)) if hasattr(object, 'credits'): result = result + self.section('CREDITS', str(object.credits))

def docclass(self, object, name=None, mod=None):

--- a/Lib/test/pydoc_mod.py +++ b/Lib/test/pydoc_mod.py @@ -3,7 +3,7 @@ author = "Benjamin Peterson" credits = "Nobody" version = "1.2.3.4" - +xyz = "X, Y and Z" class A: """Hello and goodbye"""

--- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -22,9 +22,6 @@ if hasattr(pydoc_mod, "loader"): expected_text_pattern = """ NAME test.pydoc_mod - This is a test module for test_pydoc - -FILE

%s CLASSES builtins.object @@ -72,9 +69,7 @@ FUNCTIONS nodoc_func() DATA

VERSION 1.2.3.4 @@ -84,6 +79,9 @@ AUTHOR CREDITS Nobody + +FILE

""".strip() expected_html_pattern = """ @@ -167,9 +165,7 @@ war Data \x20\x20\x20\x20         -author = 'Benjamin Peterson'
-credits = 'Nobody'
-version = '1.2.3.4'

+xyz = 'X, Y and Z'

 
@@ -259,7 +255,7 @@ class PyDocDocTest(unittest.TestCase): def test_text_doc(self): result, doc_loc = get_pydoc_text(pydoc_mod) expected_text = expected_text_pattern % [](#l4.48)

  •                    (inspect.getabsfile(pydoc_mod), doc_loc)[](#l4.49)
  •                    (doc_loc, inspect.getabsfile(pydoc_mod))[](#l4.50)
       if result != expected_text:[](#l4.51)
           print_diffs(expected_text, result)[](#l4.52)
           self.fail("outputs are not equal, see diff above")[](#l4.53)