1 | '''Find Python files in GSASII that are not referenced in the sphinx documentation |
---|
2 | ''' |
---|
3 | import glob |
---|
4 | import os.path |
---|
5 | import subprocess as sp |
---|
6 | |
---|
7 | # get list of documented files (misses out on data files -- with no functions or classes) |
---|
8 | import glob |
---|
9 | loc = os.path.split(os.path.realpath(__file__))[0] # where is the documentation? |
---|
10 | |
---|
11 | # prepare a list of the files that show up in the documentation already |
---|
12 | # look for a reference in the .rst files |
---|
13 | documented = [] |
---|
14 | for fil in glob.glob('source/*.rst'): |
---|
15 | for line in open(fil,'r').readlines(): |
---|
16 | if line.strip().startswith('.. automodule::'): |
---|
17 | documented.append(line.strip().split('::')[1].strip()) |
---|
18 | |
---|
19 | # old method looks for an html version of the source |
---|
20 | # documented = [os.path.splitext(os.path.split(fil)[1])[0] for |
---|
21 | # fil in glob.iglob(os.path.join(loc,'build/html/_modules/','*.html'))] |
---|
22 | |
---|
23 | # loop over python files referenced in subversion |
---|
24 | proc = sp.Popen(["svn","list", |
---|
25 | os.path.join(loc,'..'), |
---|
26 | os.path.join(loc,'..','exports'), |
---|
27 | os.path.join(loc,'..','imports'), |
---|
28 | ],stdout=sp.PIPE) |
---|
29 | undoc = [] |
---|
30 | for fil in proc.stdout.readlines(): |
---|
31 | fil = fil.strip() |
---|
32 | #print fil+'...', |
---|
33 | if os.path.splitext(fil.strip())[1] != ".py": continue |
---|
34 | if os.path.splitext(os.path.split(fil)[1])[0] in documented: |
---|
35 | #print fil+' doc' |
---|
36 | continue |
---|
37 | else: |
---|
38 | print fil+' undocumented' |
---|
39 | undoc.append(fil) |
---|
40 | # generate code to place in a .rst file |
---|
41 | if undoc: |
---|
42 | print "\n# place this code somewhere in the .rst files\n#" |
---|
43 | for fil in undoc: |
---|
44 | print ".. automodule:: "+os.path.splitext(os.path.split(fil)[1])[0] |
---|
45 | print " :members: " |
---|
46 | print "" |
---|