summaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorKa-Ping Yee <ping@zesty.ca>2001-03-01 00:25:40 (GMT)
committerKa-Ping Yee <ping@zesty.ca>2001-03-01 00:25:40 (GMT)
commit895e8925d6569a0be13a714f8417c6374fe1031b (patch)
tree41c32453633c2d6e7ab5923c21c0efc0d2ca24ce /Tools
parent1d384634bf8f9e6180839048207bfd3539bbbc51 (diff)
downloadcpython-895e8925d6569a0be13a714f8417c6374fe1031b.zip
cpython-895e8925d6569a0be13a714f8417c6374fe1031b.tar.gz
cpython-895e8925d6569a0be13a714f8417c6374fe1031b.tar.bz2
Call main routine in pydoc module (pydoc.cli).
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/pydoc78
1 files changed, 2 insertions, 76 deletions
diff --git a/Tools/scripts/pydoc b/Tools/scripts/pydoc
index a1dcbcc..0964929 100755
--- a/Tools/scripts/pydoc
+++ b/Tools/scripts/pydoc
@@ -1,78 +1,4 @@
#!/usr/bin/env python
-# -------------------------------------------------- command-line interface
-
-import sys, os, pydoc
-from string import lower
-
-if __name__ == '__main__':
- import getopt
- class BadUsage: pass
-
- try:
- opts, args = getopt.getopt(sys.argv[1:], 'k:p:w')
- writing = 0
-
- for opt, val in opts:
- if opt == '-k':
- pydoc.apropos(lower(val))
- break
- if opt == '-p':
- try:
- port = int(val)
- except ValueError:
- raise BadUsage
- def ready(port=port):
- print 'server ready at http://127.0.0.1:%d/' % port
- pydoc.serve(('127.0.0.1', port), ready)
- break
- if opt == '-w':
- if not args: raise BadUsage
- writing = 1
- else:
- if args:
- for arg in args:
- try:
- if os.path.isfile(arg):
- arg = pydoc.importfile(arg)
- if writing:
- if os.path.isdir(arg): pydoc.writedocs(arg)
- else: pydoc.writedoc(arg)
- else: pydoc.man(arg)
- except pydoc.DocImportError, value:
- print 'problem in %s - %s' % (
- value.filename, value.args)
- else:
- if sys.platform in ['mac', 'win', 'win32', 'nt']:
- # GUI platforms with threading
- import threading
- ready = threading.Event()
- address = ('127.0.0.1', 12346)
- threading.Thread(
- target=pydoc.serve, args=(address, ready.set)).start()
- ready.wait()
- import webbrowser
- webbrowser.open('http://127.0.0.1:12346/')
- else:
- raise BadUsage
-
- except (getopt.error, BadUsage):
- print """%s <name> ...
- Show documentation on something.
- <name> may be the name of a Python function, module, or package,
- or a dotted reference to a class or function within a module or
- module in a package, or the filename of a Python module to import.
-
-%s -k <keyword>
- Search for a keyword in the synopsis lines of all modules.
-
-%s -p <port>
- Start an HTTP server on the given port on the local machine.
-
-%s -w <module> ...
- Write out the HTML documentation for a module to a file.
-
-%s -w <moduledir>
- Write out the HTML documentation for all modules in the tree
- under a given directory to files in the current directory.
-""" % ((sys.argv[0],) * 5)
+import pydoc
+pydoc.cli()