| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # -*- coding: latin-1 -*- | 2 # -*- coding: latin-1 -*- |
| 3 """Generate Python documentation in HTML or text for interactive use. | 3 """Generate Python documentation in HTML or text for interactive use. |
| 4 | 4 |
| 5 In the Python interpreter, do "from pydoc import help" to provide online | 5 In the Python interpreter, do "from pydoc import help" to provide online |
| 6 help. Calling help(thing) on a Python object documents the object. | 6 help. Calling help(thing) on a Python object documents the object. |
| 7 | 7 |
| 8 Or, at the shell command line outside of Python: | 8 Or, at the shell command line outside of Python: |
| 9 | 9 |
| 10 Run "pydoc <name>" to show documentation on something. <name> may be | 10 Run "pydoc <name>" to show documentation on something. <name> may be |
| (...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1954 | 1954 |
| 1955 if completer: | 1955 if completer: |
| 1956 completer() | 1956 completer() |
| 1957 | 1957 |
| 1958 def apropos(key): | 1958 def apropos(key): |
| 1959 """Print all the one-line module summaries that contain a substring.""" | 1959 """Print all the one-line module summaries that contain a substring.""" |
| 1960 def callback(path, modname, desc): | 1960 def callback(path, modname, desc): |
| 1961 if modname[-9:] == '.__init__': | 1961 if modname[-9:] == '.__init__': |
| 1962 modname = modname[:-9] + ' (package)' | 1962 modname = modname[:-9] + ' (package)' |
| 1963 print modname, desc and '- ' + desc | 1963 print modname, desc and '- ' + desc |
| 1964 def onerror(modname): |
| 1965 # Ignore non-ImportError exceptions raised whilst trying to |
| 1966 # import modules |
| 1967 pass |
| 1964 try: import warnings | 1968 try: import warnings |
| 1965 except ImportError: pass | 1969 except ImportError: pass |
| 1966 else: warnings.filterwarnings('ignore') # ignore problems during import | 1970 else: warnings.filterwarnings('ignore') # ignore problems during import |
| 1967 ModuleScanner().run(callback, key) | 1971 ModuleScanner().run(callback, key, onerror=onerror) |
| 1968 | 1972 |
| 1969 # --------------------------------------------------- web browser interface | 1973 # --------------------------------------------------- web browser interface |
| 1970 | 1974 |
| 1971 def serve(port, callback=None, completer=None): | 1975 def serve(port, callback=None, completer=None): |
| 1972 import BaseHTTPServer, mimetools, select | 1976 import BaseHTTPServer, mimetools, select |
| 1973 | 1977 |
| 1974 # Patch up mimetools.Message so it doesn't break if rfc822 is reloaded. | 1978 # Patch up mimetools.Message so it doesn't break if rfc822 is reloaded. |
| 1975 class Message(mimetools.Message): | 1979 class Message(mimetools.Message): |
| 1976 def __init__(self, fp, seekable=1): | 1980 def __init__(self, fp, seekable=1): |
| 1977 Message = self.__class__ | 1981 Message = self.__class__ |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 %s -g | 2330 %s -g |
| 2327 Pop up a graphical interface for finding and serving documentation. | 2331 Pop up a graphical interface for finding and serving documentation. |
| 2328 | 2332 |
| 2329 %s -w <name> ... | 2333 %s -w <name> ... |
| 2330 Write out the HTML documentation for a module to a file in the current | 2334 Write out the HTML documentation for a module to a file in the current |
| 2331 directory. If <name> contains a '%s', it is treated as a filename; if | 2335 directory. If <name> contains a '%s', it is treated as a filename; if |
| 2332 it names a directory, documentation is written for all the contents. | 2336 it names a directory, documentation is written for all the contents. |
| 2333 """ % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep) | 2337 """ % (cmd, os.sep, cmd, cmd, cmd, cmd, os.sep) |
| 2334 | 2338 |
| 2335 if __name__ == '__main__': cli() | 2339 if __name__ == '__main__': cli() |
| OLD | NEW |