From: grahambenharper Date: Mon, 10 Feb 2020 17:09:29 +0000 (-0700) Subject: Upgrade checkdoxygen.py to check for multiple-defined headers X-Git-Tag: v9.2.0-rc1~512^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f87fe34d71dcb34a63a5cc7824e3a65c8b77112f;p=dealii.git Upgrade checkdoxygen.py to check for multiple-defined headers --- diff --git a/contrib/utilities/checkdoxygen.py b/contrib/utilities/checkdoxygen.py index fb4a946c71..4a43942d97 100755 --- a/contrib/utilities/checkdoxygen.py +++ b/contrib/utilities/checkdoxygen.py @@ -49,6 +49,45 @@ def check_empty_lines_in_tables(lines): return +# have more than one header with the same name in a tutorial? +def check_multiple_defined_headers(lines): + headers = [] + for l in lines: + # this may break if a header splits across a line + if "' + if len(thisheader.split('' + + # detect @sect[1-5]{ ... } + if "@sect" in l: + thisheader = l # take this line + thisheader = thisheader.replace(' ', '') # remove all whitespace + thisheader = thisheader.split('@sect')[1] # remove '@sect' + if thisheader[0] in ['1', '2', '3', '4', '5']: # make sure the next character is 1-5 + thisheader = thisheader[2:] # remove the number + thisheader = ''.join(ch for ch in thisheader if ch.isalnum()) # remove nonalphanumeric + + if thisheader in headers: + sys.exit("Error: repeated header title '%s' in file group '%s'"%(thisheader,args[0])) + else: + headers.append(thisheader) + + return + args = sys.argv args.pop(0) @@ -60,4 +99,29 @@ f.close() check_doxygen_groups(lines) check_empty_lines_in_tables(lines) +# if it's intro.dox, combine it with step-**.cc and results.dox and check headers +if 'intro.dox' in args[0]: + # get stepname.cc + stepname = args[0].split('/doc',1)[0] + stepname = stepname + '/' + stepname.split('/',1)[1] + '.cc' + + # get results.dox + resultsname = args[0].split('intro.dox',1)[0] + 'results.dox' + + # try to open the '.cc' file, otherwise try to open a '.cu' file + try: + fstep = open(stepname) + except IOError: + stepname = stepname[:-2] + 'cu' + fstep = open(stepname) + + lines += fstep.readlines() + fstep.close() + + fres = open(resultsname) + lines.append(fres.readlines()) + fres.close() + + # check the file group + check_multiple_defined_headers(lines)