Commit 8ec9fbdd0c3f2ae6d91acc0351e6241314509f23

Ryan C. Gordon 2021-07-14T11:58:57

wikiheaders.pl: pull in full sections from headers, fix more whitespace.

diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl
index 59b0935..f332161 100755
--- a/build-scripts/wikiheaders.pl
+++ b/build-scripts/wikiheaders.pl
@@ -118,7 +118,7 @@ sub wordwrap {
     }
 
     $retval .= wordwrap_paragraphs($str);  # wrap what's left.
-    $retval =~ s/\n+$//;
+    $retval =~ s/\n+\Z//ms;
 
     #print("\n\nWORDWRAP DONE:\n\n$retval\n\n\n");
     return $retval;
@@ -738,11 +738,16 @@ if ($copy_direction == 1) {  # --copy-to-headers
                     my $subline = $doxygenlines[0];
                     $subline =~ s/\A\s*//;
                     last if $subline =~ /\A\\/;  # some sort of doxygen command, assume we're past this thing.
-                    last if $subline eq '';  # empty line, this param is done.
                     shift @doxygenlines;  # dump this line from the array; we're using it.
-                    $desc .= " $subline";
+                    if ($subline eq '') {  # empty line, make sure it keeps the newline char.
+                        $desc .= "\n";
+                    } else {
+                        $desc .= " $subline";
+                    }
                 }
 
+                $desc =~ s/[\s\n]+\Z//ms;
+
                 # We need to know the length of the longest string to make Markdown tables, so we just store these off until everything is parsed.
                 push @params, $arg;
                 push @params, $desc;
@@ -753,22 +758,30 @@ if ($copy_direction == 1) {  # --copy-to-headers
                     my $subline = $doxygenlines[0];
                     $subline =~ s/\A\s*//;
                     last if $subline =~ /\A\\/;  # some sort of doxygen command, assume we're past this thing.
-                    last if $subline eq '';  # empty line, this param is done.
                     shift @doxygenlines;  # dump this line from the array; we're using it.
-                    $desc .= wikify($wikitype, " $subline");
+                    if ($subline eq '') {  # empty line, make sure it keeps the newline char.
+                        $desc .= "\n";
+                    } else {
+                        $desc .= " $subline";
+                    }
                 }
-                $sections{'Return Value'} = wordwrap("$retstr $desc") . "\n";
+                $desc =~ s/[\s\n]+\Z//ms;
+                $sections{'Return Value'} = wordwrap("$retstr " . wikify($wikitype, $desc)) . "\n";
             } elsif ($l =~ /\A\\since\s+(.*)\Z/) {
                 my $desc = $1;
                 while (@doxygenlines) {
                     my $subline = $doxygenlines[0];
                     $subline =~ s/\A\s*//;
                     last if $subline =~ /\A\\/;  # some sort of doxygen command, assume we're past this thing.
-                    last if $subline eq '';  # empty line, this param is done.
                     shift @doxygenlines;  # dump this line from the array; we're using it.
-                    $desc .= wikify($wikitype, " $subline");
+                    if ($subline eq '') {  # empty line, make sure it keeps the newline char.
+                        $desc .= "\n";
+                    } else {
+                        $desc .= " $subline";
+                    }
                 }
-                $sections{'Version'} = wordwrap($desc) . "\n";
+                $desc =~ s/[\s\n]+\Z//ms;
+                $sections{'Version'} = wordwrap(wikify($wikitype, $desc)) . "\n";
             } elsif ($l =~ /\A\\sa\s+(.*)\Z/) {
                 my $sa = $1;
                 $sa =~ s/\(\)\Z//;  # Convert "SDL_Func()" to "SDL_Func"