~exarkun/pyopenssl/trunk

« back to all changes in this revision

Viewing changes to doc/tools/custlib.py

  • Committer: Jean-Paul Calderone
  • Date: 2011-09-11 19:49:43 UTC
  • mfrom: (156.3.22 sphinx-doc)
  • Revision ID: exarkun@divmod.com-20110911194943-ucaan2tzidk7ek5l
Convert the documentation from LaTeX/epytext to Sphinx/ReST

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Generate custlib.tex, which is a site-specific library document.
2
 
 
3
 
# Phase I: list all the things that can be imported
4
 
 
5
 
import glob, os, sys, string
6
 
modules={}
7
 
 
8
 
for modname in sys.builtin_module_names:
9
 
    modules[modname]=modname
10
 
    
11
 
for 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
30
 
if 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
 
 
36
 
docs={}
37
 
filelist=glob.glob('lib*.tex')
38
 
for file in filelist:
39
 
    modname=file[3:-4]
40
 
    docs[modname]=modname
41
 
 
42
 
mlist=modules.keys()
43
 
mlist=filter(lambda x, docs=docs: docs.has_key(x), mlist)
44
 
mlist.sort()
45
 
mlist=map(lambda x, docs=docs: docs[x], mlist)
46
 
 
47
 
modules=mlist
48
 
 
49
 
# Phase III: write custlib.tex
50
 
 
51
 
# Write the boilerplate
52
 
# XXX should be fancied up.  
53
 
print """\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
 
    
68
 
for modname in mlist: 
69
 
    print "\\input{lib%s}" % (modname,)
70
 
    
71
 
# Write the end
72
 
print """\\input{custlib.ind}                   % Index
73
 
\\end{document}"""