]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make sure program2doxygen does not change code blocks
authorLuca Heltai <luca.heltai@sissa.it>
Thu, 10 May 2018 08:47:51 +0000 (10:47 +0200)
committerMatthias Maier <tamiko@43-1.org>
Fri, 11 May 2018 14:41:25 +0000 (09:41 -0500)
doc/doxygen/scripts/program2doxygen

index 4e4be2712989d962fec8ab32b3de84e86f78be6e..bf19d63878842b3cc26dc1cd22d38c6f75e5d028 100644 (file)
@@ -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";

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.