]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Upgrade checkdoxygen.py to check for multiple-defined headers 9505/head
authorgrahambenharper <grahambenharper@gmail.com>
Mon, 10 Feb 2020 17:09:29 +0000 (10:09 -0700)
committergrahambenharper <grahambenharper@gmail.com>
Mon, 17 Feb 2020 16:47:56 +0000 (09:47 -0700)
contrib/utilities/checkdoxygen.py

index fb4a946c71978d8e741c8c0589c2900c65fd982a..4a43942d97427b8b917b8d4d6c306fbfb00ee020 100755 (executable)
@@ -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 "<h" in l:
+            # convert thisheader to the doxygen header name equivalent
+            thisheader = l                             # take this line
+            thisheader = thisheader.replace(' ', '')   # remove all whitespace
+            thisheader = thisheader.split('<h')[1]     # remove header tag '<h'
+            if thisheader[0] in ['1', '2', '3', '4', '5']:  # make sure the next character is 1-5
+                thisheader = thisheader[2:]            # remove '*>'
+                if len(thisheader.split('</h'))==2:    # check for close header on the same line
+                    thisheader = thisheader.split('</h')[0]    # remove close header tag
+                    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)
+                else:
+                    sys.exit("Error: mismatched html header flags in file group '%s'"%(args[0]))
+            # do not check else here because it may match with template arguments like '<hsize_t>'
+        
+        # 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)
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.