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

  ViewVC Help
Powered by ViewVC 1.1.26