STYLE: improve formatting of doxygen filter output

This commit is contained in:
Andrew Heather 2017-11-10 14:53:18 +01:00 committed by Mark Olesen
parent 834d46c64a
commit 6fd27353e4
2 changed files with 46 additions and 49 deletions

View File

@ -29,70 +29,71 @@
# #
# Assumes comment strings are formatted as follows # Assumes comment strings are formatted as follows
# //- General description # //- General description
# // Detailed information # //- with a continuation of general description
# // and even more information # // Detailed description
# or # // with more particulars
# //- General description
# //- that spans several
# //- lines
# // Detailed information
# // and even more information
#
# This should be re-formatted as the following # This should be re-formatted as the following
# /*! \brief General description # /*!
# that spans several # * \brief General description
# lines # * with a continuation of general description
# *
# * Detailed description
# * with more particulars
# */ # */
# /*! Detailed information
# and even more information
# */
#
# The intermediate "/*! ... */" block is left-justified to handle
# possible verbatim text
#
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# States: 0=normal, 1=brief, 2=details # state: 0=normal, 1=brief, 2=details
# indent: whitespace content prior to the opening "//-"
BEGIN { BEGIN {
state = 0 state = 0
indent = ""
} }
/^ *\/\/-/ { /^\s*\/\/-/ {
if (state == 0) if (state == 0)
{ {
# Changed from normal to brief (start of comment block) # Changed from normal to brief (start of comment block)
printf "/*! \\brief" ## indent = substr($0, 1, index($0, "/")-1)
indent = $0
sub(/\S.*/, "", indent)
printf indent "/*!\n"
printf indent " * \\brief "
sub(/^\s*\/\/-\s*/, "")
state = 1 state = 1
} }
else
if (state == 1)
{ {
# Within brief: strip leading # Within brief: replace leading space with proper indent amount
if (!sub(/^ *\/\/- /, "")) printf indent
{ sub(/^\s*\/\/-\s*/, " * ")
sub(/^ *\/\/-/, "")
}
} }
print print
next next
} }
/^ *\/\// {
/^\s*\/\// {
if (state == 1) if (state == 1)
{ {
# Change from brief to details # Change from brief to details. Extra line to start new paragraph.
printf "*/\n" printf indent " *\n"
printf "/*! "
state = 2 state = 2
} }
if (state == 2) if (state == 2)
{ {
# Within details: strip leading # Within details
if (!sub(/^ *\/\/ /, "")) printf indent
# '//' with 4 spaces or more - assume indent is intentional
if (match($0, /^\s*\/\/( )+/))
{ {
sub(/^ *\/\//, "") sub(/^\s*\/\/\s/, " *")
}
else
{
sub(/^\s*\/\/\s*/, " * ")
} }
} }
@ -100,13 +101,14 @@ BEGIN {
next next
} }
{ {
# End comment filtering # End comment filtering
if (state) if (state)
{ {
printf "*/\n" printf indent " */\n"
}
state = 0 state = 0
}
print print
next next
} }

View File

@ -14,13 +14,6 @@ s?^License.*?\*\/\
\/\*! \\file %realFilePath%\ \/\*! \\file %realFilePath%\
<b>Original source file</b> <a href="%filePath%">%fileName%</a>\ <b>Original source file</b> <a href="%filePath%">%fileName%</a>\
\ \
\
\
\
\
\
\
\
? ?
/^ /d /^ /d
} }
@ -112,7 +105,8 @@ s/^ /\\typedef /
# the first paragraph will be 'brief' and the others 'detail' # the first paragraph will be 'brief' and the others 'detail'
/^Description *$/,/^[^ ]/{ /^Description *$/,/^[^ ]/{
/^Description/c\ /^Description/c\
<a class="anchor" name="Description"></a> \\brief <a class="anchor" name="Description"></a>\
\\brief
s/^ // s/^ //
} }
@ -145,7 +139,8 @@ s/^ //
/^SourceFiles *$/,/^$/{ /^SourceFiles *$/,/^$/{
s?SourceFiles?\\par Source files\ s?SourceFiles?\\par Source files\
<ul><li><a href="%filePath%">%fileName%</a></li>? <ul>\
<li><a href="%filePath%">%fileName%</a></li> ?
s? *\([a-zA-Z0-9]*\.[a-zA-Z]*\)? <li><a href="%dirName%/\1">\1</a></li>? s? *\([a-zA-Z0-9]*\.[a-zA-Z]*\)? <li><a href="%dirName%/\1">\1</a></li>?
s?^$?</ul>? s?^$?</ul>?
} }
@ -164,7 +159,7 @@ s/.*\*\//\*\//
# Convert \heading in source files to bold font and add some space # Convert \heading in source files to bold font and add some space
s#\\heading \(.*\)#<br><b>\1</b>#g s#\\heading \(.*\)#<br><b>\1</b>#g
# add a linebreak # Add a linebreak
s#\\linebreak#<br>#g s#\\linebreak#<br>#g
} }