/[escript]/trunk/doc/sphinx_api/genrst.py
ViewVC logotype

Contents of /trunk/doc/sphinx_api/genrst.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4141 - (show annotations)
Tue Jan 15 04:11:12 2013 UTC (7 years, 4 months ago) by jfenwick
File MIME type: text/x-python
File size: 2639 byte(s)
Fixed to scripts to allow doco to build in pbuilder.
Looking for libraries in the place they were built is a good I've found.

1 #!/usr/bin/env python
2
3 import os
4 import inspect
5 import sys
6
7 if len(sys.argv)!=4:
8 sys.stderr.write('Usage: startdir startpackage outputdirectory\n')
9 sys.exit(1)
10
11 #startdir='./esys'
12 #startpackage='esys'
13 #outdir='doctest'
14
15 pathdir=sys.argv[1]
16 startpackage=sys.argv[2]
17 startdir=os.path.join(pathdir, startpackage)
18 outdir=sys.argv[3]
19
20 def listmods():
21 W=os.walk(startdir,topdown=True)
22 sys.path.append(pathdir)
23 main=open(os.path.join(outdir,'index.rst'),'w')
24 main.write('.. Generated by Joel\'s script\n\n')
25 main.write('Documentation for esys.escript\n')
26 main.write('==============================\n')
27 main.write('\n')
28 main.write('Contents:\n\n')
29 main.write('.. toctree::\n')
30 main.write(' :maxdepth: 4\n')
31 main.write('\n')
32
33 for z in W:
34 print "Beginning ",z[0]
35 # Now make the package name
36 n=startpackage+'.'.join(z[0][len(startdir):].split(os.path.sep))
37 main.write(" "+n+"\n")
38 #Now we need to create a page for this
39 pack=open(os.path.join(outdir,n+'.rst'),'w')
40 pack.write(n+' Package\n')
41 pack.write('='*len(n)+'========\n\n')
42 pack.write('.. py:module:: '+n+'\n\n')
43 #Automodule does not seem to do what we want so we need to drill down
44 exec('import '+n+' as PP')
45 clist=[]
46 flist=[]
47 vlist=[]
48 for (name, mem) in inspect.getmembers(PP):
49 if inspect.ismodule(mem):
50 #pack.write('Module '+name+'\n')
51 pass
52 elif inspect.isclass(mem):
53 clist+=[(name, mem)]
54 elif inspect.isfunction(mem):
55 flist+=[(name, mem)]
56 else:
57 if type(mem).__module__+'.'+type(mem).__name__=='Boost.Python.function':
58 flist+=[(name, mem)]
59 else:
60 vlist+=[(name, mem)]
61 pack.write('Classes\n')
62 pack.write('-------\n')
63 for (name, mem) in clist:
64 pack.write('* `'+name+'`\n')
65 pack.write('\n')
66 for (name, mem) in clist:
67 pack.write('.. autoclass:: '+name+'\n')
68 pack.write(' :members:\n :undoc-members:\n\n')
69 pack.write('\n')
70
71 pack.write('Functions\n')
72 pack.write('---------\n')
73 for (name, mem) in flist:
74 pack.write('.. autofunction:: '+name+'\n')
75 pack.write('\n')
76
77 pack.write('Others\n')
78 pack.write('------\n')
79 for (name, mem) in vlist:
80 pack.write('* '+name+'\n')
81 pack.write('\n')
82
83
84 for m in z[2]: #This will list the files
85 if m.split('.')[1]=='pyc' and m!='__init__.pyc':
86 print ".."+n+"."+m
87 pack.close()
88 main.write('\n')
89 main.write('Indices and Tables\n')
90 main.write('==================\n')
91 main.write('\n')
92 main.write('* :ref:`genindex`\n')
93 main.write('* :ref:`modindex`\n')
94 main.write('\n')
95 main.close()
96
97
98 listmods()

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26