annotate Doc/tools/custlib.py @ 21467:4e35fa5d5708 legacy-trunk

Add documentation for the help() built-in; contributed by Ka-Ping Yee. This is part of SF patch #494622.
author Fred Drake <fdrake@acm.org>
date Tue, 18 Dec 2001 16:31:08 +0000
parents 1a6f9158630f
children 85c87b3ac96b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5691
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
1 # Generate custlib.tex, which is a site-specific library document.
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
2
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
3 # Phase I: list all the things that can be imported
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
4
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
5 import glob, os, sys, string
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 modules={}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 for modname in sys.builtin_module_names:
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 modules[modname]=modname
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 for dir in sys.path:
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
12 # Look for *.py files
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 filelist=glob.glob(os.path.join(dir, '*.py'))
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 for file in filelist:
15088
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
15 path, file = os.path.split(file)
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
16 base, ext=os.path.splitext(file)
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
17 modules[string.lower(base)]=base
5691
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
18
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 # Look for shared library files
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 filelist=(glob.glob(os.path.join(dir, '*.so')) +
15088
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
21 glob.glob(os.path.join(dir, '*.sl')) +
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
22 glob.glob(os.path.join(dir, '*.o')) )
5691
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 for file in filelist:
15088
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
24 path, file = os.path.split(file)
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
25 base, ext=os.path.splitext(file)
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
26 if base[-6:]=='module': base=base[:-6]
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
27 modules[string.lower(base)]=base
5691
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
28
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 # Minor oddity: the types module is documented in libtypes2.tex
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 if modules.has_key('types'):
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 del modules['types'] ; modules['types2']=None
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
32
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 # Phase II: find all documentation files (lib*.tex)
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 # and eliminate modules that don't have one.
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
35
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
36 docs={}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
37 filelist=glob.glob('lib*.tex')
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
38 for file in filelist:
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
39 modname=file[3:-4]
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
40 docs[modname]=modname
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
41
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
42 mlist=modules.keys()
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
43 mlist=filter(lambda x, docs=docs: docs.has_key(x), mlist)
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
44 mlist.sort()
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
45 mlist=map(lambda x, docs=docs: docs[x], mlist)
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
46
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 modules=mlist
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 # Phase III: write custlib.tex
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
50
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 # Write the boilerplate
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
52 # XXX should be fancied up.
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
53 print """\documentstyle[twoside,11pt,myformat]{report}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
54 \\title{Python Library Reference}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
55 \\input{boilerplate}
15088
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
56 \\makeindex % tell \\index to actually write the .idx file
5691
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
57 \\begin{document}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
58 \\pagenumbering{roman}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
59 \\maketitle
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
60 \\input{copyright}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
61 \\begin{abstract}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
62 \\noindent This is a customized version of the Python Library Reference.
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
63 \\end{abstract}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 \\pagebreak
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 {\\parskip = 0mm \\tableofcontents}
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
66 \\pagebreak\\pagenumbering{arabic}"""
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
67
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
68 for modname in mlist:
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
69 print "\\input{lib%s}" % (modname,)
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
70
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
71 # Write the end
15088
1a6f9158630f Hush the nanny.
Fred Drake <fdrake@acm.org>
parents: 5691
diff changeset
72 print """\\input{custlib.ind} % Index
5691
38383ada388e A nicety (author lost).
Guido van Rossum <guido@python.org>
parents:
diff changeset
73 \\end{document}"""