[939] | 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) |
---|
[1112] | 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'))] |
---|
[939] | 22 | |
---|
[1112] | 23 | # loop over python files referenced in subversion |
---|
[1123] | 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) |
---|
[1109] | 29 | undoc = [] |
---|
[939] | 30 | for fil in proc.stdout.readlines(): |
---|
[1109] | 31 | fil = fil.strip() |
---|
[1112] | 32 | #print fil+'...', |
---|
[939] | 33 | if os.path.splitext(fil.strip())[1] != ".py": continue |
---|
| 34 | if os.path.splitext(os.path.split(fil)[1])[0] in documented: |
---|
[1514] | 35 | #print fil+' doc' |
---|
[939] | 36 | continue |
---|
| 37 | else: |
---|
[1112] | 38 | print fil+' undocumented' |
---|
[1109] | 39 | undoc.append(fil) |
---|
[1112] | 40 | # generate code to place in a .rst file |
---|
| 41 | if undoc: |
---|
| 42 | print "\n# place this code somewhere in the .rst files\n#" |
---|
[1109] | 43 | for fil in undoc: |
---|
| 44 | print ".. automodule:: "+os.path.splitext(os.path.split(fil)[1])[0] |
---|
| 45 | print " :members: " |
---|
| 46 | print "" |
---|