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