diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 9829d5c58c0..3b5c20abb74 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -62,7 +62,7 @@ def synopsis(filename, cache={}): while strip(line) == '': line = file.readline() if not line: break - result = split(line, '"""')[0] + result = strip(split(line, '"""')[0]) else: result = None file.close() cache[filename] = (mtime, result) @@ -86,7 +86,7 @@ def getdoc(object): if not result: try: result = inspect.getcomments(object) except: pass - return result and rstrip(result) or '' + return result and re.sub('^ *\n', '', rstrip(result)) or '' def classname(object, modname): """Get a class name and qualify it with a module name if necessary.""" @@ -393,9 +393,7 @@ class HTMLDoc(Doc): linkedname = join(links + parts[-1:], '.') head = '%s' % linkedname try: - path = os.path.abspath(inspect.getfile(object)) - sourcepath = os.path.abspath(inspect.getsourcefile(object)) - if os.path.isfile(sourcepath): path = sourcepath + path = inspect.getabsfile(object) filelink = '%s' % (path, path) except TypeError: filelink = '(built-in)' @@ -675,9 +673,9 @@ class TextDoc(Doc): if lines[0]: name = name + ' - ' + lines[0] lines = lines[2:] result = result + self.section('NAME', name) - try: file = inspect.getfile(object) # XXX or getsourcefile? - except TypeError: file = None - result = result + self.section('FILE', file or '(built-in)') + try: file = inspect.getabsfile(object) + except TypeError: file = '(built-in)' + result = result + self.section('FILE', file) if lines: result = result + self.section('DESCRIPTION', join(lines, '\n')) @@ -1049,10 +1047,11 @@ class ModuleScanner(Scanner): seen = {} for modname in sys.builtin_module_names: - seen[modname] = 1 - desc = split(__import__(modname).__doc__ or '', '\n')[0] - if find(lower(modname + ' - ' + desc), lower(key)) >= 0: - callback(None, modname, desc) + if modname != '__main__': + seen[modname] = 1 + desc = split(__import__(modname).__doc__ or '', '\n')[0] + if find(lower(modname + ' - ' + desc), lower(key)) >= 0: + callback(None, modname, desc) while not self.quit: node = self.next() @@ -1124,10 +1123,13 @@ def serve(port, callback=None): heading = html.heading( 'Python: Index of Modules', '#ffffff', '#7799ee') - builtins = [] - for name in sys.builtin_module_names: - builtins.append('%s' % (name, name)) - indices = ['
Built-in modules: ' + join(builtins, ', ')] + def bltinlink(name): + return '%s' % (name, name) + names = filter(lambda x: x != '__main__', sys.builtin_module_names) + contents = html.multicolumn(names, bltinlink) + indices = ['
' + html.bigsection(
+ 'Built-in Modules', '#ffffff', '#ee77aa', contents)]
+
seen = {}
for dir in pathdirs():
indices.append(html.index(dir, seen))
@@ -1206,8 +1208,8 @@ def gui():
self.search_frm.pack(side='top', fill='x')
self.search_ent.focus_set()
- self.result_lst = Tkinter.Listbox(window,
- font=('helvetica', 8), height=6)
+ font = ('helvetica', sys.platform in ['win32', 'win', 'nt'] and 8 or 10)
+ self.result_lst = Tkinter.Listbox(window, font=font, height=6)
self.result_lst.bind('