wikiheaders.pl: Migrate in docs that exist only in the wiki. This is going to expose some docs that needs cleaning up once the bridge imports those docs, though.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl
index 602b109..7c2411a 100755
--- a/build-scripts/wikiheaders.pl
+++ b/build-scripts/wikiheaders.pl
@@ -292,6 +292,7 @@ my %headerfuncs = (); # $headerfuncs{"SDL_OpenAudio"} -> string of header docu
my %headerdecls = ();
my %headerfuncslocation = (); # $headerfuncslocation{"SDL_OpenAudio"} -> name of header holding SDL_OpenAudio define ("SDL_audio.h" in this case).
my %headerfuncschunk = (); # $headerfuncschunk{"SDL_OpenAudio"} -> offset in array in %headers that should be replaced for this function.
+my %headerfuncshasdoxygen = (); # $headerfuncschunk{"SDL_OpenAudio"} -> 1 if there was no existing doxygen for this function.
my $incpath = "$srcpath/include";
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
@@ -304,46 +305,54 @@ while (readdir(DH)) {
while (<FH>) {
chomp;
- if (not /\A\/\*\*\s*\Z/) { # not doxygen comment start?
+ my $decl;
+ my @templines;
+ my $str;
+ my $has_doxygen = 1;
+ if (/\A\s*extern\s+DECLSPEC/) { # a function declaration without a doxygen comment?
+ @templines = ();
+ $decl = $_;
+ $str = '';
+ $has_doxygen = 0;
+ } elsif (not /\A\/\*\*\s*\Z/) { # not doxygen comment start?
push @contents, $_;
next;
- }
-
- my @templines = ();
- push @templines, $_;
- my $str = '';
- while (<FH>) {
- chomp;
- push @templines, $_;
- last if /\A\s*\*\/\Z/;
- if (s/\A\s*\*\s*\`\`\`/```/) { # this is a hack, but a lot of other code relies on the whitespace being trimmed, but we can't trim it in code blocks...
- $str .= "$_\n";
- while (<FH>) {
- chomp;
- push @templines, $_;
- s/\A\s*\*\s?//;
- if (s/\A\s*\`\`\`/```/) {
- $str .= "$_\n";
- last;
- } else {
- $str .= "$_\n";
+ } else { # Start of a doxygen comment, parse it out.
+ @templines = ( $_ );
+ while (<FH>) {
+ chomp;
+ push @templines, $_;
+ last if /\A\s*\*\/\Z/;
+ if (s/\A\s*\*\s*\`\`\`/```/) { # this is a hack, but a lot of other code relies on the whitespace being trimmed, but we can't trim it in code blocks...
+ $str .= "$_\n";
+ while (<FH>) {
+ chomp;
+ push @templines, $_;
+ s/\A\s*\*\s?//;
+ if (s/\A\s*\`\`\`/```/) {
+ $str .= "$_\n";
+ last;
+ } else {
+ $str .= "$_\n";
+ }
}
+ } else {
+ s/\A\s*\*\s*//;
+ $str .= "$_\n";
}
- } else {
- s/\A\s*\*\s*//;
- $str .= "$_\n";
}
- }
- my $decl = <FH>;
- chomp($decl);
- if (not $decl =~ /\A\s*extern\s+DECLSPEC/) {
- #print "Found doxygen but no function sig:\n$str\n\n";
- foreach (@templines) {
- push @contents, $_;
+ $decl = <FH>;
+ $decl = '' if not defined $decl;
+ chomp($decl);
+ if (not $decl =~ /\A\s*extern\s+DECLSPEC/) {
+ #print "Found doxygen but no function sig:\n$str\n\n";
+ foreach (@templines) {
+ push @contents, $_;
+ }
+ push @contents, $decl;
+ next;
}
- push @contents, $decl;
- next;
}
my @decllines = ( $decl );
@@ -397,6 +406,7 @@ while (readdir(DH)) {
$headerdecls{$fn} = $decl;
$headerfuncslocation{$fn} = $dent;
$headerfuncschunk{$fn} = scalar(@contents);
+ $headerfuncshasdoxygen{$fn} = $has_doxygen;
push @contents, join("\n", @templines);
push @contents, join("\n", @decllines);
@@ -522,7 +532,6 @@ if ($copy_direction == 1) { # --copy-to-headers
$wordwrap_mode = 'md'; # the headers use Markdown format.
- # if it's not in the headers already, we don't add it, so iterate what we know is already there for changes.
foreach (keys %headerfuncs) {
my $fn = $_;
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
@@ -537,6 +546,8 @@ if ($copy_direction == 1) { # --copy-to-headers
my $addblank = 0;
my $str = '';
+ $headerfuncshasdoxygen{$fn} = 1; # Added/changed doxygen for this header.
+
$brief = dewikify($wikitype, $brief);
$brief =~ s/\A(.*?\.) /$1\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary.
my @briefsplit = split /\n/, $brief;
@@ -632,8 +643,15 @@ if ($copy_direction == 1) { # --copy-to-headers
}
}
+ my $header = $headerfuncslocation{$fn};
+ my $contentsref = $headers{$header};
+ my $chunk = $headerfuncschunk{$fn};
+
my @lines = split /\n/, $str;
- my $output = "/**\n";
+
+ my $addnewline = (($chunk > 0) && ($$contentsref[$chunk-1] ne '')) ? "\n" : '';
+
+ my $output = "$addnewline/**\n";
foreach (@lines) {
chomp;
s/\s*\Z//;
@@ -647,9 +665,6 @@ if ($copy_direction == 1) { # --copy-to-headers
#print("$fn:\n$output\n\n");
- my $header = $headerfuncslocation{$fn};
- my $chunk = $headerfuncschunk{$fn};
- my $contentsref = $headers{$header};
$$contentsref[$chunk] = $output;
#$$contentsref[$chunk+1] = $headerdecls{$fn};
@@ -657,19 +672,36 @@ if ($copy_direction == 1) { # --copy-to-headers
}
foreach (keys %changed_headers) {
- my $contentsref = $headers{$_};
- my $path = "$incpath/$_.tmp";
+ my $header = $_;
+
+ # this is kinda inefficient, but oh well.
+ my @removelines = ();
+ foreach (keys %headerfuncslocation) {
+ my $fn = $_;
+ next if $headerfuncshasdoxygen{$fn};
+ next if $headerfuncslocation{$fn} ne $header;
+ # the index of the blank line we put before the function declaration in case we needed to replace it with new content from the wiki.
+ push @removelines, $headerfuncschunk{$fn};
+ }
+
+ my $contentsref = $headers{$header};
+ foreach (@removelines) {
+ delete $$contentsref[$_]; # delete DOES NOT RENUMBER existing elements!
+ }
+
+ my $path = "$incpath/$header.tmp";
open(FH, '>', $path) or die("Can't open '$path': $!\n");
foreach (@$contentsref) {
- print FH "$_\n";
+ print FH "$_\n" if defined $_;
}
close(FH);
- rename($path, "$incpath/$_") or die("Can't rename '$path' to '$incpath/$_': $!\n");
+ rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
}
} elsif ($copy_direction == -1) { # --copy-to-wiki
foreach (keys %headerfuncs) {
my $fn = $_;
+ next if not $headerfuncshasdoxygen{$fn};
my $wikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'mediawiki'; # default to MediaWiki for new stuff FOR NOW.
die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md'));
@@ -678,6 +710,7 @@ if ($copy_direction == 1) { # --copy-to-headers
$wordwrap_mode = $wikitype;
my $raw = $headerfuncs{$fn}; # raw doxygen text with comment characters stripped from start/end and start of each line.
+ next if not defined $raw;
$raw =~ s/\A\s*\\brief\s+//; # Technically we don't need \brief (please turn on JAVADOC_AUTOBRIEF if you use Doxygen), so just in case one is present, strip it.
my @doxygenlines = split /\n/, $raw;