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