cannam@162: import os cannam@162: import os.path cannam@162: import string cannam@162: cannam@162: paRootDirectory = '../../' cannam@162: paHtmlDocDirectory = os.path.join( paRootDirectory, "doc", "html" ) cannam@162: cannam@162: ## Script to check documentation status cannam@162: ## this script assumes that html doxygen documentation has been generated cannam@162: ## cannam@162: ## it then walks the entire portaudio source tree and check that cannam@162: ## - every source file (.c,.h,.cpp) has a doxygen comment block containing cannam@162: ## - a @file directive cannam@162: ## - a @brief directive cannam@162: ## - a @ingroup directive cannam@162: ## - it also checks that a corresponding html documentation file has been generated. cannam@162: ## cannam@162: ## This can be used as a first-level check to make sure the documentation is in order. cannam@162: ## cannam@162: ## The idea is to get a list of which files are missing doxygen documentation. cannam@162: ## cannam@162: ## How to run: cannam@162: ## $ cd doc/utils cannam@162: ## $ python checkfiledocs.py cannam@162: cannam@162: def oneOf_a_in_b(a, b): cannam@162: for x in a: cannam@162: if x in b: cannam@162: return True cannam@162: return False cannam@162: cannam@162: # recurse from top and return a list of all with the given cannam@162: # extensions. ignore .svn directories. return absolute paths cannam@162: def recursiveFindFiles( top, extensions, dirBlacklist, includePaths ): cannam@162: result = [] cannam@162: for (dirpath, dirnames, filenames) in os.walk(top): cannam@162: if not oneOf_a_in_b(dirBlacklist, dirpath): cannam@162: for f in filenames: cannam@162: if os.path.splitext(f)[1] in extensions: cannam@162: if includePaths: cannam@162: result.append( os.path.abspath( os.path.join( dirpath, f ) ) ) cannam@162: else: cannam@162: result.append( f ) cannam@162: return result cannam@162: cannam@162: # generate the html file name that doxygen would use for cannam@162: # a particular source file. this is a brittle conversion cannam@162: # which i worked out by trial and error cannam@162: def doxygenHtmlDocFileName( sourceFile ): cannam@162: return sourceFile.replace( '_', '__' ).replace( '.', '_8' ) + '.html' cannam@162: cannam@162: cannam@162: sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True ); cannam@162: sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True ); cannam@162: docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False ); cannam@162: cannam@162: cannam@162: cannam@162: currentFile = "" cannam@162: cannam@162: def printError( f, message ): cannam@162: global currentFile cannam@162: if f != currentFile: cannam@162: currentFile = f cannam@162: print f, ":" cannam@162: print "\t!", message cannam@162: cannam@162: cannam@162: for f in sourceFiles: cannam@162: if not doxygenHtmlDocFileName( os.path.basename(f) ) in docFiles: cannam@162: printError( f, "no doxygen generated doc page" ) cannam@162: cannam@162: s = file( f, 'rt' ).read() cannam@162: cannam@162: if not '/**' in s: cannam@162: printError( f, "no doxygen /** block" ) cannam@162: cannam@162: if not '@file' in s: cannam@162: printError( f, "no doxygen @file tag" ) cannam@162: cannam@162: if not '@brief' in s: cannam@162: printError( f, "no doxygen @brief tag" ) cannam@162: cannam@162: if not '@ingroup' in s: cannam@162: printError( f, "no doxygen @ingroup tag" ) cannam@162: cannam@162: