annotate src/portaudio_20161030_catalina_patch/doc/utils/checkfiledocs.py @ 162:d43aab368df9

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