blob: 32cb3d24e854e34c4994a10067ad06d5bf80690a [file] [log] [blame]
Guido van Rossum6cb2ac21997-06-02 17:57:10 +00001# Generate custlib.tex, which is a site-specific library document.
2
3# Phase I: list all the things that can be imported
4
5import glob, os, sys, string
6modules={}
7
8for modname in sys.builtin_module_names:
9 modules[modname]=modname
10
11for dir in sys.path:
12 # Look for *.py files
13 filelist=glob.glob(os.path.join(dir, '*.py'))
14 for file in filelist:
15 path, file = os.path.split(file)
16 base, ext=os.path.splitext(file)
17 modules[string.lower(base)]=base
18
19 # Look for shared library files
20 filelist=(glob.glob(os.path.join(dir, '*.so')) +
21 glob.glob(os.path.join(dir, '*.sl')) +
22 glob.glob(os.path.join(dir, '*.o')) )
23 for file in filelist:
24 path, file = os.path.split(file)
25 base, ext=os.path.splitext(file)
26 if base[-6:]=='module': base=base[:-6]
27 modules[string.lower(base)]=base
28
29# Minor oddity: the types module is documented in libtypes2.tex
30if modules.has_key('types'):
31 del modules['types'] ; modules['types2']=None
32
33# Phase II: find all documentation files (lib*.tex)
34# and eliminate modules that don't have one.
35
36docs={}
37filelist=glob.glob('lib*.tex')
38for file in filelist:
39 modname=file[3:-4]
40 docs[modname]=modname
41
42mlist=modules.keys()
43mlist=filter(lambda x, docs=docs: docs.has_key(x), mlist)
44mlist.sort()
45mlist=map(lambda x, docs=docs: docs[x], mlist)
46
47modules=mlist
48
49# Phase III: write custlib.tex
50
51# Write the boilerplate
52# XXX should be fancied up.
53print """\documentstyle[twoside,11pt,myformat]{report}
54\\title{Python Library Reference}
55\\input{boilerplate}
56\\makeindex % tell \\index to actually write the .idx file
57\\begin{document}
58\\pagenumbering{roman}
59\\maketitle
60\\input{copyright}
61\\begin{abstract}
62\\noindent This is a customized version of the Python Library Reference.
63\\end{abstract}
64\\pagebreak
65{\\parskip = 0mm \\tableofcontents}
66\\pagebreak\\pagenumbering{arabic}"""
67
68for modname in mlist:
69 print "\\input{lib%s}" % (modname,)
70
71# Write the end
72print """\\input{custlib.ind} % Index
73\\end{document}"""