From: Luca Heltai Date: Thu, 10 May 2018 08:47:51 +0000 (+0200) Subject: Make sure program2doxygen does not change code blocks X-Git-Tag: v9.0.0~1^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=37bff0bcad01ff107a1687ddab0b0659c241c504;p=dealii.git Make sure program2doxygen does not change code blocks --- diff --git a/doc/doxygen/scripts/program2doxygen b/doc/doxygen/scripts/program2doxygen index 4e4be27129..bf19d63878 100644 --- a/doc/doxygen/scripts/program2doxygen +++ b/doc/doxygen/scripts/program2doxygen @@ -26,11 +26,12 @@ if ($ARGV[0] =~ /step-\d+.cc/) } -# have three states, in which the program can be: -# comment-mode, program-mode and skip-mode -$comment_mode = 0; -$program_mode = 1; -$skip_mode = 2; +# have four states, in which the program can be: +# comment-mode, program-mode, skip-mode, and code-fragment-mode +$comment_mode = 0; +$program_mode = 1; +$skip_mode = 2; +$code_fragment_mode = 3; $state = $comment_mode; print " * \n"; @@ -43,8 +44,19 @@ do { s/\t/ /g; + # We are entering code fragments + if (($state != $code_fragment_mode) && m!^\s*//\s*\@code!) + { + # Cleanly close @code segments in program mode: + if ($state == $program_mode) + { + print " * \@endcode\n"; + print " * \n"; + } + $state = $code_fragment_mode; + } # We shall skip something... - if (($state != $skip_mode) && m!^\s*//\s*\@cond SKIP!) + elsif (($state != $skip_mode) && m!^\s*//\s*\@cond SKIP!) { # Cleanly close @code segments in program mode: if ($state == $program_mode) @@ -114,7 +126,22 @@ do { $state = $comment_mode; } } -} while (<>); + elsif ($state == $code_fragment_mode) + { + # This is the end of a @code - @endcode block, so back to + # comment_mode: + if (m!^\s*//\s*\@endcode!) + { + $state = $comment_mode; + } + # in code fragment mode: only skip leading whitespace and + # comment // signs + s!\s*//\s(.*)\n!$1!; + + # finally print this line + print " * $_\n"; + } + } while (<>); if ($state == $program_mode) { print " * \@endcode\n";