early-access version 2835
This commit is contained in:
412
externals/SDL/build-scripts/wikiheaders.pl
vendored
412
externals/SDL/build-scripts/wikiheaders.pl
vendored
@@ -4,24 +4,101 @@ use warnings;
|
||||
use strict;
|
||||
use Text::Wrap;
|
||||
|
||||
$Text::Wrap::huge = 'overflow';
|
||||
|
||||
my $projectfullname = 'Simple Directmedia Layer';
|
||||
my $projectshortname = 'SDL';
|
||||
my $wikisubdir = '';
|
||||
my $incsubdir = 'include';
|
||||
my $apiprefixregex = undef;
|
||||
my $versionfname = 'include/SDL_version.h';
|
||||
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
||||
my $versionminorregex = '\A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z';
|
||||
my $versionpatchregex = '\A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z';
|
||||
my $mainincludefname = 'SDL.h';
|
||||
my $selectheaderregex = '\ASDL.*?\.h\Z';
|
||||
my $projecturl = 'https://libsdl.org/';
|
||||
my $wikiurl = 'https://wiki.libsdl.org';
|
||||
my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new';
|
||||
my $srcpath = undef;
|
||||
my $wikipath = undef;
|
||||
my $warn_about_missing = 0;
|
||||
my $copy_direction = 0;
|
||||
my $optionsfname = undef;
|
||||
|
||||
foreach (@ARGV) {
|
||||
$warn_about_missing = 1, next if $_ eq '--warn-about-missing';
|
||||
$copy_direction = 1, next if $_ eq '--copy-to-headers';
|
||||
$copy_direction = 1, next if $_ eq '--copy-to-header';
|
||||
$copy_direction = -1, next if $_ eq '--copy-to-wiki';
|
||||
$copy_direction = -2, next if $_ eq '--copy-to-manpages';
|
||||
if (/\A--options=(.*)\Z/) {
|
||||
$optionsfname = $1;
|
||||
next;
|
||||
}
|
||||
$srcpath = $_, next if not defined $srcpath;
|
||||
$wikipath = $_, next if not defined $wikipath;
|
||||
}
|
||||
|
||||
my $default_optionsfname = '.wikiheaders-options';
|
||||
$default_optionsfname = "$srcpath/$default_optionsfname" if defined $srcpath;
|
||||
|
||||
if ((not defined $optionsfname) && (-f $default_optionsfname)) {
|
||||
$optionsfname = $default_optionsfname;
|
||||
}
|
||||
|
||||
if (defined $optionsfname) {
|
||||
open OPTIONS, '<', $optionsfname or die("Failed to open options file '$optionsfname': $!\n");
|
||||
while (<OPTIONS>) {
|
||||
chomp;
|
||||
if (/\A(.*?)\=(.*)\Z/) {
|
||||
my $key = $1;
|
||||
my $val = $2;
|
||||
$key =~ s/\A\s+//;
|
||||
$key =~ s/\s+\Z//;
|
||||
$val =~ s/\A\s+//;
|
||||
$val =~ s/\s+\Z//;
|
||||
$warn_about_missing = int($val), next if $key eq 'warn_about_missing';
|
||||
$srcpath = $val, next if $key eq 'srcpath';
|
||||
$wikipath = $val, next if $key eq 'wikipath';
|
||||
$apiprefixregex = $val, next if $key eq 'apiprefixregex';
|
||||
$projectfullname = $val, next if $key eq 'projectfullname';
|
||||
$projectshortname = $val, next if $key eq 'projectshortname';
|
||||
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
||||
$incsubdir = $val, next if $key eq 'incsubdir';
|
||||
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
|
||||
$versionminorregex = $val, next if $key eq 'versionminorregex';
|
||||
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
|
||||
$versionfname = $val, next if $key eq 'versionfname';
|
||||
$mainincludefname = $val, next if $key eq 'mainincludefname';
|
||||
$selectheaderregex = $val, next if $key eq 'selectheaderregex';
|
||||
$projecturl = $val, next if $key eq 'projecturl';
|
||||
$wikiurl = $val, next if $key eq 'wikiurl';
|
||||
$bugreporturl = $val, next if $key eq 'bugreporturl';
|
||||
}
|
||||
}
|
||||
close(OPTIONS);
|
||||
}
|
||||
|
||||
my $wordwrap_mode = 'mediawiki';
|
||||
sub wordwrap_atom { # don't call this directly.
|
||||
my $str = shift;
|
||||
return fill('', '', $str);
|
||||
my $retval = '';
|
||||
|
||||
# wordwrap but leave links intact, even if they overflow.
|
||||
if ($wordwrap_mode eq 'mediawiki') {
|
||||
while ($str =~ s/(.*?)\s*(\[https?\:\/\/.*?\s+.*?\])\s*//ms) {
|
||||
$retval .= fill('', '', $1); # wrap it.
|
||||
$retval .= "\n$2\n"; # don't wrap it.
|
||||
}
|
||||
} elsif ($wordwrap_mode eq 'md') {
|
||||
while ($str =~ s/(.*?)\s*(\[.*?\]\(https?\:\/\/.*?\))\s*//ms) {
|
||||
$retval .= fill('', '', $1); # wrap it.
|
||||
$retval .= "\n$2\n"; # don't wrap it.
|
||||
}
|
||||
}
|
||||
|
||||
return $retval . fill('', '', $str);
|
||||
}
|
||||
|
||||
sub wordwrap_with_bullet_indent { # don't call this directly.
|
||||
@@ -141,16 +218,23 @@ sub wikify_chunk {
|
||||
while ($str =~ s/\A(.*?)\`(.*?)\`//ms) {
|
||||
my $codeblock = $2;
|
||||
$codedstr .= wikify_chunk($wikitype, $1, undef, undef);
|
||||
# Convert obvious SDL things to wikilinks, even inside `code` blocks.
|
||||
$codeblock =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
|
||||
if (defined $apiprefixregex) {
|
||||
# Convert obvious API things to wikilinks, even inside `code` blocks.
|
||||
$codeblock =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[[$1]]/gms;
|
||||
}
|
||||
$codedstr .= "<code>$codeblock</code>";
|
||||
}
|
||||
|
||||
# Convert obvious SDL things to wikilinks.
|
||||
$str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[[$1]]/gms;
|
||||
# Convert obvious API things to wikilinks.
|
||||
if (defined $apiprefixregex) {
|
||||
$str =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[[$1]]/gms;
|
||||
}
|
||||
|
||||
# Make some Markdown things into MediaWiki...
|
||||
|
||||
# links
|
||||
$str =~ s/\[(.*?)\]\((https?\:\/\/.*?)\)/\[$2 $1\]/g;
|
||||
|
||||
# bold+italic
|
||||
$str =~ s/\*\*\*(.*?)\*\*\*/'''''$1'''''/gms;
|
||||
|
||||
@@ -169,8 +253,10 @@ sub wikify_chunk {
|
||||
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
|
||||
}
|
||||
} elsif ($wikitype eq 'md') {
|
||||
# Convert obvious SDL things to wikilinks.
|
||||
$str =~ s/\b(SDL_[a-zA-Z0-9_]+)/[$1]($1)/gms;
|
||||
# Convert obvious API things to wikilinks.
|
||||
if (defined $apiprefixregex) {
|
||||
$str =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[$1]($1)/gms;
|
||||
}
|
||||
if (defined $code) {
|
||||
$str .= "```$codelang$code```";
|
||||
}
|
||||
@@ -199,6 +285,9 @@ sub wikify {
|
||||
}
|
||||
|
||||
|
||||
my $dewikify_mode = 'md';
|
||||
my $dewikify_manpage_code_indent = 1;
|
||||
|
||||
sub dewikify_chunk {
|
||||
my $wikitype = shift;
|
||||
my $str = shift;
|
||||
@@ -207,30 +296,79 @@ sub dewikify_chunk {
|
||||
|
||||
#print("\n\nDEWIKIFY CHUNK:\n\n$str\n\n\n");
|
||||
|
||||
if ($wikitype eq 'mediawiki') {
|
||||
# Doxygen supports Markdown (and it just simply looks better than MediaWiki
|
||||
# when looking at the raw headers), so do some conversions here as necessary.
|
||||
if ($dewikify_mode eq 'md') {
|
||||
if ($wikitype eq 'mediawiki') {
|
||||
# Doxygen supports Markdown (and it just simply looks better than MediaWiki
|
||||
# when looking at the raw headers), so do some conversions here as necessary.
|
||||
|
||||
$str =~ s/\[\[(SDL_[a-zA-Z0-9_]+)\]\]/$1/gms; # Dump obvious wikilinks.
|
||||
# Dump obvious wikilinks.
|
||||
if (defined $apiprefixregex) {
|
||||
$str =~ s/\[\[($apiprefixregex[a-zA-Z0-9_]+)\]\]/$1/gms;
|
||||
}
|
||||
|
||||
# <code></code> is also popular. :/
|
||||
$str =~ s/\<code>(.*?)<\/code>/`$1`/gms;
|
||||
# links
|
||||
$str =~ s/\[(https?\:\/\/.*?)\s+(.*?)\]/\[$2\]\($1\)/g;
|
||||
|
||||
# bold+italic
|
||||
$str =~ s/\'''''(.*?)'''''/***$1***/gms;
|
||||
# <code></code> is also popular. :/
|
||||
$str =~ s/\<code>(.*?)<\/code>/`$1`/gms;
|
||||
|
||||
# bold
|
||||
$str =~ s/\'''(.*?)'''/**$1**/gms;
|
||||
# bold+italic
|
||||
$str =~ s/'''''(.*?)'''''/***$1***/gms;
|
||||
|
||||
# italic
|
||||
$str =~ s/\''(.*?)''/*$1*/gms;
|
||||
# bold
|
||||
$str =~ s/'''(.*?)'''/**$1**/gms;
|
||||
|
||||
# bullets
|
||||
$str =~ s/^\* /- /gm;
|
||||
}
|
||||
# italic
|
||||
$str =~ s/''(.*?)''/*$1*/gms;
|
||||
|
||||
if (defined $code) {
|
||||
$str .= "```$codelang$code```";
|
||||
# bullets
|
||||
$str =~ s/^\* /- /gm;
|
||||
}
|
||||
|
||||
if (defined $code) {
|
||||
$str .= "```$codelang$code```";
|
||||
}
|
||||
} elsif ($dewikify_mode eq 'manpage') {
|
||||
$str =~ s/\./\\[char46]/gms; # make sure these can't become control codes.
|
||||
if ($wikitype eq 'mediawiki') {
|
||||
# Dump obvious wikilinks.
|
||||
if (defined $apiprefixregex) {
|
||||
$str =~ s/\s*\[\[($apiprefixregex[a-zA-Z0-9_]+)\]\]\s*/\n.BR $1\n/gms;
|
||||
}
|
||||
|
||||
# links
|
||||
$str =~ s/\[(https?\:\/\/.*?)\s+(.*?)\]/\n.URL "$1" "$2"\n/g;
|
||||
|
||||
# <code></code> is also popular. :/
|
||||
$str =~ s/\s*\<code>(.*?)<\/code>\s*/\n.BR $1\n/gms;
|
||||
|
||||
# bold+italic
|
||||
$str =~ s/\s*'''''(.*?)'''''\s*/\n.BI $1\n/gms;
|
||||
|
||||
# bold
|
||||
$str =~ s/\s*'''(.*?)'''\s*/\n.B $1\n/gms;
|
||||
|
||||
# italic
|
||||
$str =~ s/\s*''(.*?)''\s*/\n.I $1\n/gms;
|
||||
|
||||
# bullets
|
||||
$str =~ s/^\* /\n\\\(bu /gm;
|
||||
} else {
|
||||
die("Unexpected wikitype when converting to manpages\n"); # !!! FIXME: need to handle Markdown wiki pages.
|
||||
}
|
||||
|
||||
if (defined $code) {
|
||||
$code =~ s/\A\n+//gms;
|
||||
$code =~ s/\n+\Z//gms;
|
||||
if ($dewikify_manpage_code_indent) {
|
||||
$str .= "\n.IP\n"
|
||||
} else {
|
||||
$str .= "\n.PP\n"
|
||||
}
|
||||
$str .= ".EX\n$code\n.EE\n.PP\n";
|
||||
}
|
||||
} else {
|
||||
die("Unexpected dewikify_mode\n");
|
||||
}
|
||||
|
||||
#print("\n\nDEWIKIFY CHUNK DONE:\n\n$str\n\n\n");
|
||||
@@ -260,7 +398,7 @@ sub dewikify {
|
||||
}
|
||||
|
||||
sub usage {
|
||||
die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki] [--warn-about-missing]\n\n");
|
||||
die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing]\n\n");
|
||||
}
|
||||
|
||||
usage() if not defined $srcpath;
|
||||
@@ -295,11 +433,13 @@ my %headerfuncslocation = (); # $headerfuncslocation{"SDL_OpenAudio"} -> name
|
||||
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";
|
||||
$incpath .= "/$incsubdir" if $incsubdir ne '';
|
||||
|
||||
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
||||
while (readdir(DH)) {
|
||||
my $dent = $_;
|
||||
next if not $dent =~ /\ASDL.*?\.h\Z/; # just SDL*.h headers.
|
||||
next if not $dent =~ /$selectheaderregex/; # just selected headers.
|
||||
open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n");
|
||||
|
||||
my @contents = ();
|
||||
@@ -449,7 +589,7 @@ opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n");
|
||||
while (readdir(DH)) {
|
||||
my $dent = $_;
|
||||
my $type = '';
|
||||
if ($dent =~ /\ASDL.*?\.(md|mediawiki)\Z/) {
|
||||
if ($dent =~ /\.(md|mediawiki)\Z/) {
|
||||
$type = $1;
|
||||
} else {
|
||||
next; # only dealing with wiki pages.
|
||||
@@ -551,6 +691,7 @@ if ($warn_about_missing) {
|
||||
if ($copy_direction == 1) { # --copy-to-headers
|
||||
my %changed_headers = ();
|
||||
|
||||
$dewikify_mode = 'md';
|
||||
$wordwrap_mode = 'md'; # the headers use Markdown format.
|
||||
|
||||
foreach (keys %headerfuncs) {
|
||||
@@ -676,6 +817,7 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||
foreach (@desclines) {
|
||||
s/\A(\:|\* )//;
|
||||
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
||||
s/\A\/*//;
|
||||
$str .= "\\sa $_\n";
|
||||
}
|
||||
}
|
||||
@@ -740,7 +882,7 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||
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'));
|
||||
die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md') and ($wikitype ne 'manpage'));
|
||||
|
||||
#print("$fn\n"); next;
|
||||
|
||||
@@ -884,7 +1026,7 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||
if ($wikitype eq 'mediawiki') {
|
||||
$sections{'Related Functions'} .= ":[[$sa]]\n";
|
||||
} elsif ($wikitype eq 'md') {
|
||||
$sections{'Related Functions'} .= "* [$sa](/$sa)\n";
|
||||
$sections{'Related Functions'} .= "* [$sa]($sa)\n";
|
||||
} else { die("Expected wikitype '$wikitype'\n"); }
|
||||
}
|
||||
}
|
||||
@@ -1009,6 +1151,216 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||
close(FH);
|
||||
rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n");
|
||||
}
|
||||
|
||||
} elsif ($copy_direction == -2) { # --copy-to-manpages
|
||||
# This only takes from the wiki data, since it has sections we omit from the headers, like code examples.
|
||||
|
||||
my $manpath = "$srcpath/man";
|
||||
mkdir($manpath);
|
||||
$manpath .= "/man3";
|
||||
mkdir($manpath);
|
||||
|
||||
$dewikify_mode = 'manpage';
|
||||
$wordwrap_mode = 'manpage';
|
||||
|
||||
my $introtxt = '';
|
||||
if (0) {
|
||||
open(FH, '<', "$srcpath/LICENSE.txt") or die("Can't open '$srcpath/LICENSE.txt': $!\n");
|
||||
while (<FH>) {
|
||||
chomp;
|
||||
$introtxt .= ".\\\" $_\n";
|
||||
}
|
||||
close(FH);
|
||||
}
|
||||
|
||||
my $gitrev = `cd "$srcpath" ; git rev-list HEAD~..`;
|
||||
chomp($gitrev);
|
||||
|
||||
# !!! FIXME
|
||||
open(FH, '<', "$srcpath/$versionfname") or die("Can't open '$srcpath/$versionfname': $!\n");
|
||||
my $majorver = 0;
|
||||
my $minorver = 0;
|
||||
my $patchver = 0;
|
||||
while (<FH>) {
|
||||
chomp;
|
||||
if (/$versionmajorregex/) {
|
||||
$majorver = int($1);
|
||||
} elsif (/$versionminorregex/) {
|
||||
$minorver = int($1);
|
||||
} elsif (/$versionpatchregex/) {
|
||||
$patchver = int($1);
|
||||
}
|
||||
}
|
||||
close(FH);
|
||||
my $fullversion = "$majorver.$minorver.$patchver";
|
||||
|
||||
foreach (keys %headerfuncs) {
|
||||
my $fn = $_;
|
||||
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
|
||||
my $wikitype = $wikitypes{$fn};
|
||||
my $sectionsref = $wikifuncs{$fn};
|
||||
my $remarks = %$sectionsref{'Remarks'};
|
||||
my $params = %$sectionsref{'Function Parameters'};
|
||||
my $returns = %$sectionsref{'Return Value'};
|
||||
my $version = %$sectionsref{'Version'};
|
||||
my $related = %$sectionsref{'Related Functions'};
|
||||
my $examples = %$sectionsref{'Code Examples'};
|
||||
my $deprecated = %$sectionsref{'Deprecated'};
|
||||
my $brief = %$sectionsref{'[Brief]'};
|
||||
my $decl = $headerdecls{$fn};
|
||||
my $str = '';
|
||||
|
||||
$brief = "$brief";
|
||||
$brief =~ s/\A[\s\n]*\= .*? \=\s*?\n+//ms;
|
||||
$brief =~ s/\A[\s\n]*\=\= .*? \=\=\s*?\n+//ms;
|
||||
$brief =~ s/\A(.*?\.) /$1\n/; # \brief should only be one sentence, delimited by a period+space. Split if necessary.
|
||||
my @briefsplit = split /\n/, $brief;
|
||||
$brief = shift @briefsplit;
|
||||
$brief = dewikify($wikitype, $brief);
|
||||
|
||||
if (defined $remarks) {
|
||||
$remarks = dewikify($wikitype, join("\n", @briefsplit) . $remarks);
|
||||
}
|
||||
|
||||
$str .= $introtxt;
|
||||
|
||||
$str .= ".\\\" This manpage content is licensed under Creative Commons\n";
|
||||
$str .= ".\\\" Attribution 4.0 International (CC BY 4.0)\n";
|
||||
$str .= ".\\\" https://creativecommons.org/licenses/by/4.0/\n";
|
||||
$str .= ".\\\" This manpage was generated from ${projectshortname}'s wiki page for $fn:\n";
|
||||
$str .= ".\\\" $wikiurl/$fn\n";
|
||||
$str .= ".\\\" Generated with SDL/build-scripts/wikiheaders.pl\n";
|
||||
$str .= ".\\\" revision $gitrev\n" if $gitrev ne '';
|
||||
$str .= ".\\\" Please report issues in this manpage's content at:\n";
|
||||
$str .= ".\\\" $bugreporturl\n";
|
||||
$str .= ".\\\" Please report issues in the generation of this manpage from the wiki at:\n";
|
||||
$str .= ".\\\" https://github.com/libsdl-org/SDL/issues/new?title=Misgenerated%20manpage%20for%20$fn\n";
|
||||
$str .= ".\\\" $projectshortname can be found at $projecturl\n";
|
||||
|
||||
# Define a .URL macro. The "www.tmac" thing decides if we're using GNU roff (which has a .URL macro already), and if so, overrides the macro we just created.
|
||||
# This wizadry is from https://web.archive.org/web/20060102165607/http://people.debian.org/~branden/talks/wtfm/wtfm.pdf
|
||||
$str .= ".de URL\n";
|
||||
$str .= '\\$2 \(laURL: \\$1 \(ra\\$3' . "\n";
|
||||
$str .= "..\n";
|
||||
$str .= '.if \n[.g] .mso www.tmac' . "\n";
|
||||
|
||||
$str .= ".TH $fn 3 \"$projectshortname $fullversion\" \"$projectfullname\" \"$projectshortname$majorver FUNCTIONS\"\n";
|
||||
$str .= ".SH NAME\n";
|
||||
|
||||
$str .= "$fn";
|
||||
$str .= " \\- $brief" if (defined $brief);
|
||||
$str .= "\n";
|
||||
|
||||
$str .= ".SH SYNOPSIS\n";
|
||||
$str .= ".nf\n";
|
||||
$str .= ".B #include \\(dq$mainincludefname\\(dq\n";
|
||||
$str .= ".PP\n";
|
||||
|
||||
my @decllines = split /\n/, $decl;
|
||||
foreach (@decllines) {
|
||||
$str .= ".BI \"$_\n";
|
||||
}
|
||||
$str .= ".fi\n";
|
||||
|
||||
if (defined $remarks) {
|
||||
$str .= ".SH DESCRIPTION\n";
|
||||
$str .= $remarks . "\n";
|
||||
}
|
||||
|
||||
if (defined $deprecated) {
|
||||
$str .= ".SH DEPRECATED\n";
|
||||
$str .= dewikify($wikitype, $deprecated) . "\n";
|
||||
}
|
||||
|
||||
if (defined $params) {
|
||||
$str .= ".SH FUNCTION PARAMETERS\n";
|
||||
my @lines = split /\n/, $params;
|
||||
if ($wikitype eq 'mediawiki') {
|
||||
die("Unexpected data parsing MediaWiki table") if (shift @lines ne '{|'); # Dump the '{|' start
|
||||
while (scalar(@lines) >= 3) {
|
||||
my $name = shift @lines;
|
||||
my $desc = shift @lines;
|
||||
my $terminator = shift @lines; # the '|-' or '|}' line.
|
||||
last if ($terminator ne '|-') and ($terminator ne '|}'); # we seem to have run out of table.
|
||||
$name =~ s/\A\|\s*//;
|
||||
$name =~ s/\A\*\*(.*?)\*\*/$1/;
|
||||
$name =~ s/\A\'\'\'(.*?)\'\'\'/$1/;
|
||||
$desc =~ s/\A\|\s*//;
|
||||
$desc = dewikify($wikitype, $desc);
|
||||
#print STDERR "FN: $fn NAME: $name DESC: $desc TERM: $terminator\n";
|
||||
|
||||
$str .= ".TP\n";
|
||||
$str .= ".I $name\n";
|
||||
$str .= "$desc\n";
|
||||
}
|
||||
} else {
|
||||
die("write me");
|
||||
}
|
||||
}
|
||||
|
||||
if (defined $returns) {
|
||||
$str .= ".SH RETURN VALUE\n";
|
||||
$str .= dewikify($wikitype, $returns) . "\n";
|
||||
}
|
||||
|
||||
if (defined $examples) {
|
||||
$str .= ".SH CODE EXAMPLES\n";
|
||||
$dewikify_manpage_code_indent = 0;
|
||||
$str .= dewikify($wikitype, $examples) . "\n";
|
||||
$dewikify_manpage_code_indent = 1;
|
||||
}
|
||||
|
||||
if (defined $version) {
|
||||
$str .= ".SH AVAILABILITY\n";
|
||||
$str .= dewikify($wikitype, $version) . "\n";
|
||||
}
|
||||
|
||||
if (defined $related) {
|
||||
$str .= ".SH SEE ALSO\n";
|
||||
# !!! FIXME: lots of code duplication in all of these.
|
||||
my $v = dewikify($wikitype, $related);
|
||||
my @desclines = split /\n/, $v;
|
||||
my $nextstr = '';
|
||||
foreach (@desclines) {
|
||||
s/\A(\:|\* )//;
|
||||
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
||||
s/\A\/*//;
|
||||
s/\A\.BR\s+//; # dewikify added this, but we want to handle it.
|
||||
s/\A\s+//;
|
||||
s/\s+\Z//;
|
||||
next if $_ eq '';
|
||||
$str .= "$nextstr.BR $_ (3)";
|
||||
$nextstr = ",\n";
|
||||
}
|
||||
$str .= "\n";
|
||||
}
|
||||
|
||||
if (0) {
|
||||
$str .= ".SH COPYRIGHT\n";
|
||||
$str .= "This manpage is licensed under\n";
|
||||
$str .= ".UR https://creativecommons.org/licenses/by/4.0/\n";
|
||||
$str .= "Creative Commons Attribution 4.0 International (CC BY 4.0)\n";
|
||||
$str .= ".UE\n";
|
||||
$str .= ".PP\n";
|
||||
$str .= "This manpage was generated from\n";
|
||||
$str .= ".UR $wikiurl/$fn\n";
|
||||
$str .= "${projectshortname}'s wiki\n";
|
||||
$str .= ".UE\n";
|
||||
$str .= "using SDL/build-scripts/wikiheaders.pl";
|
||||
$str .= " revision $gitrev" if $gitrev ne '';
|
||||
$str .= ".\n";
|
||||
$str .= "Please report issues in this manpage at\n";
|
||||
$str .= ".UR $bugreporturl\n";
|
||||
$str .= "our bugtracker!\n";
|
||||
$str .= ".UE\n";
|
||||
}
|
||||
|
||||
my $path = "$manpath/$_.3.tmp";
|
||||
open(FH, '>', $path) or die("Can't open '$path': $!\n");
|
||||
print FH $str;
|
||||
close(FH);
|
||||
rename($path, "$manpath/$_.3") or die("Can't rename '$path' to '$manpath/$_.3': $!\n");
|
||||
}
|
||||
}
|
||||
|
||||
# end of wikiheaders.pl ...
|
||||
|
Reference in New Issue
Block a user