Typo fixes and small touches.
This commit is contained in:
parent
9aa0d90947
commit
662469619a
29
Lib/pydoc.py
29
Lib/pydoc.py
|
@ -1065,7 +1065,7 @@ def locate(path):
|
||||||
text = TextDoc()
|
text = TextDoc()
|
||||||
html = HTMLDoc()
|
html = HTMLDoc()
|
||||||
|
|
||||||
def doc(thing, title='Python Library Documentation: '):
|
def doc(thing, title='Python Library Documentation: %s'):
|
||||||
"""Display text documentation, given an object or a path to an object."""
|
"""Display text documentation, given an object or a path to an object."""
|
||||||
suffix, name = '', None
|
suffix, name = '', None
|
||||||
if type(thing) is type(''):
|
if type(thing) is type(''):
|
||||||
|
@ -1086,7 +1086,7 @@ def doc(thing, title='Python Library Documentation: '):
|
||||||
module = inspect.getmodule(thing)
|
module = inspect.getmodule(thing)
|
||||||
if not suffix and module and module is not thing:
|
if not suffix and module and module is not thing:
|
||||||
suffix = ' in module ' + module.__name__
|
suffix = ' in module ' + module.__name__
|
||||||
pager(title + desc + suffix + '\n\n' + text.document(object, name))
|
pager(title % (desc + suffix) + '\n\n' + text.document(thing, name))
|
||||||
|
|
||||||
def writedoc(key):
|
def writedoc(key):
|
||||||
"""Write HTML documentation to a file in the current directory."""
|
"""Write HTML documentation to a file in the current directory."""
|
||||||
|
@ -1178,17 +1178,20 @@ class ModuleScanner(Scanner):
|
||||||
def ispackage(self, (dir, package)):
|
def ispackage(self, (dir, package)):
|
||||||
return ispackage(dir)
|
return ispackage(dir)
|
||||||
|
|
||||||
def run(self, key, callback, completer=None):
|
def run(self, callback, key=None, completer=None):
|
||||||
key = lower(key)
|
if key: key = lower(key)
|
||||||
self.quit = 0
|
self.quit = 0
|
||||||
seen = {}
|
seen = {}
|
||||||
|
|
||||||
for modname in sys.builtin_module_names:
|
for modname in sys.builtin_module_names:
|
||||||
if modname != '__main__':
|
if modname != '__main__':
|
||||||
seen[modname] = 1
|
seen[modname] = 1
|
||||||
desc = split(freshimport(modname).__doc__ or '', '\n')[0]
|
if key is None:
|
||||||
if find(lower(modname + ' - ' + desc), key) >= 0:
|
callback(None, modname, '')
|
||||||
callback(None, modname, desc)
|
else:
|
||||||
|
desc = split(freshimport(modname).__doc__ or '', '\n')[0]
|
||||||
|
if find(lower(modname + ' - ' + desc), key) >= 0:
|
||||||
|
callback(None, modname, desc)
|
||||||
|
|
||||||
while not self.quit:
|
while not self.quit:
|
||||||
node = self.next()
|
node = self.next()
|
||||||
|
@ -1199,12 +1202,12 @@ class ModuleScanner(Scanner):
|
||||||
modname = package + (package and '.') + modname
|
modname = package + (package and '.') + modname
|
||||||
if not seen.has_key(modname):
|
if not seen.has_key(modname):
|
||||||
seen[modname] = 1 # if we see spam.py, skip spam.pyc
|
seen[modname] = 1 # if we see spam.py, skip spam.pyc
|
||||||
if key:
|
if key is None:
|
||||||
|
callback(path, modname, '')
|
||||||
|
else:
|
||||||
desc = synopsis(path) or ''
|
desc = synopsis(path) or ''
|
||||||
if find(lower(modname + ' - ' + desc), key) >= 0:
|
if find(lower(modname + ' - ' + desc), key) >= 0:
|
||||||
callback(path, modname, desc)
|
callback(path, modname, desc)
|
||||||
else:
|
|
||||||
callback(path, modname, '')
|
|
||||||
if completer: completer()
|
if completer: completer()
|
||||||
|
|
||||||
def apropos(key):
|
def apropos(key):
|
||||||
|
@ -1216,11 +1219,11 @@ def apropos(key):
|
||||||
try: import warnings
|
try: import warnings
|
||||||
except ImportError: pass
|
except ImportError: pass
|
||||||
else: warnings.filterwarnings('ignore') # ignore problems during import
|
else: warnings.filterwarnings('ignore') # ignore problems during import
|
||||||
ModuleScanner().run(key, callback)
|
ModuleScanner().run(callback, key)
|
||||||
|
|
||||||
# --------------------------------------------------- web browser interface
|
# --------------------------------------------------- web browser interface
|
||||||
|
|
||||||
def serve(port, callback=None, finalizer=None):
|
def serve(port, callback=None, completer=None):
|
||||||
import BaseHTTPServer, SocketServer, mimetools, select
|
import BaseHTTPServer, SocketServer, mimetools, select
|
||||||
|
|
||||||
# Patch up mimetools.Message so it doesn't break if rfc822 is reloaded.
|
# Patch up mimetools.Message so it doesn't break if rfc822 is reloaded.
|
||||||
|
@ -1307,7 +1310,7 @@ pydoc</strong> by Ka-Ping Yee <ping@lfw.org></font></small></small>'''
|
||||||
except (KeyboardInterrupt, select.error):
|
except (KeyboardInterrupt, select.error):
|
||||||
pass
|
pass
|
||||||
finally:
|
finally:
|
||||||
if finalizer: finalizer()
|
if completer: completer()
|
||||||
|
|
||||||
# ----------------------------------------------------- graphical interface
|
# ----------------------------------------------------- graphical interface
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue