4 This script parses the stderr output of doxygen and looks for undocumented
5 stuff. By default, it just counts the undocumented things per file. But with
6 the -A option, it rewrites the files to stick in /*DOCDOC*/ comments
7 to highlight the undocumented stuff.
10 # Future imports for Python 2.7, mandatory in 3.0
11 from __future__
import division
12 from __future__
import print_function
13 from __future__
import unicode_literals
20 warning_pattern
= re
.compile(r
'^([^:]+):(\d+): warning: (.*) is not documented')
22 def readDoxygenOutput(f
):
23 " yields (cfilename, lineno, thingname) "
25 m
= warning_pattern
.match(line
)
32 for fn
, lineno
, what
in list(readDoxygenOutput(sys
.stdin
)):
33 warnings
.setdefault(fn
, []).append( (int(lineno
), what
) )
36 if os
.path
.abspath(fn
) not in warnings
:
39 n
= len(warnings
[os
.path
.abspath(fn
)])
40 print("%d\t%s"%(n
,fn
))
42 def getIndentation(line
):
44 return line
[:len(line
)-len(s
)]
46 def annotate(filename
):
47 if os
.path
.abspath(filename
) not in warnings
:
49 with
open(filename
) as f
:
51 w
= warnings
[os
.path
.abspath(filename
)][:]
55 for lineno
, what
in w
:
56 lineno
-= 1 # list is 0-indexed.
57 if 'DOCDOC' in lines
[lineno
]:
59 ind
= getIndentation(lines
[lineno
])
60 lines
.insert(lineno
, "%s/* DOCDOC %s */\n"%(ind
,what
))
62 shutil
.copy(filename
, filename
+".orig")
63 with
open(filename
, 'w') as f
:
68 if __name__
== '__main__':
69 if len(sys
.argv
) == 1:
70 print("Usage: locatemissingdoxygen.py [-A] filename... <doxygen_log")
73 if sys
.argv
[1] == '-A':
78 for fname
in sys
.argv
[1:]: