mirror of https://github.com/encounter/SDL.git
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.
This commit is contained in:
parent
194657a2c6
commit
3970a885a5
|
@ -292,6 +292,7 @@ my %headerfuncs = (); # $headerfuncs{"SDL_OpenAudio"} -> string of header docu
|
||||||
my %headerdecls = ();
|
my %headerdecls = ();
|
||||||
my %headerfuncslocation = (); # $headerfuncslocation{"SDL_OpenAudio"} -> name of header holding SDL_OpenAudio define ("SDL_audio.h" in this case).
|
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 %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";
|
my $incpath = "$srcpath/include";
|
||||||
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
||||||
|
@ -304,46 +305,54 @@ while (readdir(DH)) {
|
||||||
|
|
||||||
while (<FH>) {
|
while (<FH>) {
|
||||||
chomp;
|
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, $_;
|
push @contents, $_;
|
||||||
next;
|
next;
|
||||||
}
|
} else { # Start of a doxygen comment, parse it out.
|
||||||
|
@templines = ( $_ );
|
||||||
my @templines = ();
|
while (<FH>) {
|
||||||
push @templines, $_;
|
chomp;
|
||||||
my $str = '';
|
push @templines, $_;
|
||||||
while (<FH>) {
|
last if /\A\s*\*\/\Z/;
|
||||||
chomp;
|
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...
|
||||||
push @templines, $_;
|
$str .= "$_\n";
|
||||||
last if /\A\s*\*\/\Z/;
|
while (<FH>) {
|
||||||
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...
|
chomp;
|
||||||
$str .= "$_\n";
|
push @templines, $_;
|
||||||
while (<FH>) {
|
s/\A\s*\*\s?//;
|
||||||
chomp;
|
if (s/\A\s*\`\`\`/```/) {
|
||||||
push @templines, $_;
|
$str .= "$_\n";
|
||||||
s/\A\s*\*\s?//;
|
last;
|
||||||
if (s/\A\s*\`\`\`/```/) {
|
} else {
|
||||||
$str .= "$_\n";
|
$str .= "$_\n";
|
||||||
last;
|
}
|
||||||
} else {
|
|
||||||
$str .= "$_\n";
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
s/\A\s*\*\s*//;
|
||||||
|
$str .= "$_\n";
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
s/\A\s*\*\s*//;
|
|
||||||
$str .= "$_\n";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
my $decl = <FH>;
|
$decl = <FH>;
|
||||||
chomp($decl);
|
$decl = '' if not defined $decl;
|
||||||
if (not $decl =~ /\A\s*extern\s+DECLSPEC/) {
|
chomp($decl);
|
||||||
#print "Found doxygen but no function sig:\n$str\n\n";
|
if (not $decl =~ /\A\s*extern\s+DECLSPEC/) {
|
||||||
foreach (@templines) {
|
#print "Found doxygen but no function sig:\n$str\n\n";
|
||||||
push @contents, $_;
|
foreach (@templines) {
|
||||||
|
push @contents, $_;
|
||||||
|
}
|
||||||
|
push @contents, $decl;
|
||||||
|
next;
|
||||||
}
|
}
|
||||||
push @contents, $decl;
|
|
||||||
next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
my @decllines = ( $decl );
|
my @decllines = ( $decl );
|
||||||
|
@ -397,6 +406,7 @@ while (readdir(DH)) {
|
||||||
$headerdecls{$fn} = $decl;
|
$headerdecls{$fn} = $decl;
|
||||||
$headerfuncslocation{$fn} = $dent;
|
$headerfuncslocation{$fn} = $dent;
|
||||||
$headerfuncschunk{$fn} = scalar(@contents);
|
$headerfuncschunk{$fn} = scalar(@contents);
|
||||||
|
$headerfuncshasdoxygen{$fn} = $has_doxygen;
|
||||||
|
|
||||||
push @contents, join("\n", @templines);
|
push @contents, join("\n", @templines);
|
||||||
push @contents, join("\n", @decllines);
|
push @contents, join("\n", @decllines);
|
||||||
|
@ -522,7 +532,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
|
|
||||||
$wordwrap_mode = 'md'; # the headers use Markdown format.
|
$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) {
|
foreach (keys %headerfuncs) {
|
||||||
my $fn = $_;
|
my $fn = $_;
|
||||||
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
|
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 $addblank = 0;
|
||||||
my $str = '';
|
my $str = '';
|
||||||
|
|
||||||
|
$headerfuncshasdoxygen{$fn} = 1; # Added/changed doxygen for this header.
|
||||||
|
|
||||||
$brief = dewikify($wikitype, $brief);
|
$brief = dewikify($wikitype, $brief);
|
||||||
$brief =~ s/\A(.*?\.) /$1\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary.
|
$brief =~ s/\A(.*?\.) /$1\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary.
|
||||||
my @briefsplit = split /\n/, $brief;
|
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 @lines = split /\n/, $str;
|
||||||
my $output = "/**\n";
|
|
||||||
|
my $addnewline = (($chunk > 0) && ($$contentsref[$chunk-1] ne '')) ? "\n" : '';
|
||||||
|
|
||||||
|
my $output = "$addnewline/**\n";
|
||||||
foreach (@lines) {
|
foreach (@lines) {
|
||||||
chomp;
|
chomp;
|
||||||
s/\s*\Z//;
|
s/\s*\Z//;
|
||||||
|
@ -647,9 +665,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
|
|
||||||
#print("$fn:\n$output\n\n");
|
#print("$fn:\n$output\n\n");
|
||||||
|
|
||||||
my $header = $headerfuncslocation{$fn};
|
|
||||||
my $chunk = $headerfuncschunk{$fn};
|
|
||||||
my $contentsref = $headers{$header};
|
|
||||||
$$contentsref[$chunk] = $output;
|
$$contentsref[$chunk] = $output;
|
||||||
#$$contentsref[$chunk+1] = $headerdecls{$fn};
|
#$$contentsref[$chunk+1] = $headerdecls{$fn};
|
||||||
|
|
||||||
|
@ -657,19 +672,36 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (keys %changed_headers) {
|
foreach (keys %changed_headers) {
|
||||||
my $contentsref = $headers{$_};
|
my $header = $_;
|
||||||
my $path = "$incpath/$_.tmp";
|
|
||||||
|
# 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");
|
open(FH, '>', $path) or die("Can't open '$path': $!\n");
|
||||||
foreach (@$contentsref) {
|
foreach (@$contentsref) {
|
||||||
print FH "$_\n";
|
print FH "$_\n" if defined $_;
|
||||||
}
|
}
|
||||||
close(FH);
|
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
|
} elsif ($copy_direction == -1) { # --copy-to-wiki
|
||||||
foreach (keys %headerfuncs) {
|
foreach (keys %headerfuncs) {
|
||||||
my $fn = $_;
|
my $fn = $_;
|
||||||
|
next if not $headerfuncshasdoxygen{$fn};
|
||||||
my $wikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'mediawiki'; # default to MediaWiki for new stuff FOR NOW.
|
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'));
|
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;
|
$wordwrap_mode = $wikitype;
|
||||||
|
|
||||||
my $raw = $headerfuncs{$fn}; # raw doxygen text with comment characters stripped from start/end and start of each line.
|
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.
|
$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;
|
my @doxygenlines = split /\n/, $raw;
|
||||||
|
|
Loading…
Reference in New Issue