Chris@55
|
1 import os
|
Chris@55
|
2 import os.path
|
Chris@55
|
3 import string
|
Chris@55
|
4
|
Chris@55
|
5 paRootDirectory = '../../'
|
Chris@55
|
6 paHtmlDocDirectory = os.path.join( paRootDirectory, "doc", "html" )
|
Chris@55
|
7
|
Chris@55
|
8 ## Script to check documentation status
|
Chris@55
|
9 ## this script assumes that html doxygen documentation has been generated
|
Chris@55
|
10 ##
|
Chris@55
|
11 ## it then walks the entire portaudio source tree and check that
|
Chris@55
|
12 ## - every source file (.c,.h,.cpp) has a doxygen comment block containing
|
Chris@55
|
13 ## - a @file directive
|
Chris@55
|
14 ## - a @brief directive
|
Chris@55
|
15 ## - a @ingroup directive
|
Chris@55
|
16 ## - it also checks that a corresponding html documentation file has been generated.
|
Chris@55
|
17 ##
|
Chris@55
|
18 ## This can be used as a first-level check to make sure the documentation is in order.
|
Chris@55
|
19 ##
|
Chris@55
|
20 ## The idea is to get a list of which files are missing doxygen documentation.
|
Chris@55
|
21 ##
|
Chris@55
|
22 ## How to run:
|
Chris@55
|
23 ## $ cd doc/utils
|
Chris@55
|
24 ## $ python checkfiledocs.py
|
Chris@55
|
25
|
Chris@55
|
26 def oneOf_a_in_b(a, b):
|
Chris@55
|
27 for x in a:
|
Chris@55
|
28 if x in b:
|
Chris@55
|
29 return True
|
Chris@55
|
30 return False
|
Chris@55
|
31
|
Chris@55
|
32 # recurse from top and return a list of all with the given
|
Chris@55
|
33 # extensions. ignore .svn directories. return absolute paths
|
Chris@55
|
34 def recursiveFindFiles( top, extensions, dirBlacklist, includePaths ):
|
Chris@55
|
35 result = []
|
Chris@55
|
36 for (dirpath, dirnames, filenames) in os.walk(top):
|
Chris@55
|
37 if not oneOf_a_in_b(dirBlacklist, dirpath):
|
Chris@55
|
38 for f in filenames:
|
Chris@55
|
39 if os.path.splitext(f)[1] in extensions:
|
Chris@55
|
40 if includePaths:
|
Chris@55
|
41 result.append( os.path.abspath( os.path.join( dirpath, f ) ) )
|
Chris@55
|
42 else:
|
Chris@55
|
43 result.append( f )
|
Chris@55
|
44 return result
|
Chris@55
|
45
|
Chris@55
|
46 # generate the html file name that doxygen would use for
|
Chris@55
|
47 # a particular source file. this is a brittle conversion
|
Chris@55
|
48 # which i worked out by trial and error
|
Chris@55
|
49 def doxygenHtmlDocFileName( sourceFile ):
|
Chris@55
|
50 return sourceFile.replace( '_', '__' ).replace( '.', '_8' ) + '.html'
|
Chris@55
|
51
|
Chris@55
|
52
|
Chris@55
|
53 sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True );
|
Chris@55
|
54 sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True );
|
Chris@55
|
55 docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False );
|
Chris@55
|
56
|
Chris@55
|
57
|
Chris@55
|
58
|
Chris@55
|
59 currentFile = ""
|
Chris@55
|
60
|
Chris@55
|
61 def printError( f, message ):
|
Chris@55
|
62 global currentFile
|
Chris@55
|
63 if f != currentFile:
|
Chris@55
|
64 currentFile = f
|
Chris@55
|
65 print f, ":"
|
Chris@55
|
66 print "\t!", message
|
Chris@55
|
67
|
Chris@55
|
68
|
Chris@55
|
69 for f in sourceFiles:
|
Chris@55
|
70 if not doxygenHtmlDocFileName( os.path.basename(f) ) in docFiles:
|
Chris@55
|
71 printError( f, "no doxygen generated doc page" )
|
Chris@55
|
72
|
Chris@55
|
73 s = file( f, 'rt' ).read()
|
Chris@55
|
74
|
Chris@55
|
75 if not '/**' in s:
|
Chris@55
|
76 printError( f, "no doxygen /** block" )
|
Chris@55
|
77
|
Chris@55
|
78 if not '@file' in s:
|
Chris@55
|
79 printError( f, "no doxygen @file tag" )
|
Chris@55
|
80
|
Chris@55
|
81 if not '@brief' in s:
|
Chris@55
|
82 printError( f, "no doxygen @brief tag" )
|
Chris@55
|
83
|
Chris@55
|
84 if not '@ingroup' in s:
|
Chris@55
|
85 printError( f, "no doxygen @ingroup tag" )
|
Chris@55
|
86
|
Chris@55
|
87
|