mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-22 19:35:37 +00:00
wikiheaders: Bridge README files in the docs directory to wiki.
Fixes #6026. (cherry picked from commit 2506676f34dc9d3e64ab7bbd9c947b8c13364913)
This commit is contained in:
parent
c0fb092425
commit
a48bb80ea0
|
@ -2,6 +2,7 @@ projectfullname = SDL2
|
||||||
projectshortname = SDL2
|
projectshortname = SDL2
|
||||||
incsubdir = include
|
incsubdir = include
|
||||||
wikisubdir = SDL2
|
wikisubdir = SDL2
|
||||||
|
readmesubdir = docs
|
||||||
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
|
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
|
||||||
mainincludefname = SDL.h
|
mainincludefname = SDL.h
|
||||||
versionfname = include/SDL_version.h
|
versionfname = include/SDL_version.h
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use warnings;
|
use warnings;
|
||||||
use strict;
|
use strict;
|
||||||
use Text::Wrap;
|
use Text::Wrap;
|
||||||
|
use File::Copy;
|
||||||
|
|
||||||
$Text::Wrap::huge = 'overflow';
|
$Text::Wrap::huge = 'overflow';
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ my $projectfullname = 'Simple Directmedia Layer';
|
||||||
my $projectshortname = 'SDL';
|
my $projectshortname = 'SDL';
|
||||||
my $wikisubdir = '';
|
my $wikisubdir = '';
|
||||||
my $incsubdir = 'include';
|
my $incsubdir = 'include';
|
||||||
|
my $readmesubdir = undef;
|
||||||
my $apiprefixregex = undef;
|
my $apiprefixregex = undef;
|
||||||
my $versionfname = 'include/SDL_version.h';
|
my $versionfname = 'include/SDL_version.h';
|
||||||
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
||||||
|
@ -22,6 +24,7 @@ my $wikiurl = 'https://wiki.libsdl.org';
|
||||||
my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new';
|
my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new';
|
||||||
my $srcpath = undef;
|
my $srcpath = undef;
|
||||||
my $wikipath = undef;
|
my $wikipath = undef;
|
||||||
|
my $wikireadmesubdir = 'README';
|
||||||
my $warn_about_missing = 0;
|
my $warn_about_missing = 0;
|
||||||
my $copy_direction = 0;
|
my $copy_direction = 0;
|
||||||
my $optionsfname = undef;
|
my $optionsfname = undef;
|
||||||
|
@ -71,6 +74,7 @@ if (defined $optionsfname) {
|
||||||
$projectshortname = $val, next if $key eq 'projectshortname';
|
$projectshortname = $val, next if $key eq 'projectshortname';
|
||||||
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
||||||
$incsubdir = $val, next if $key eq 'incsubdir';
|
$incsubdir = $val, next if $key eq 'incsubdir';
|
||||||
|
$readmesubdir = $val, next if $key eq 'readmesubdir';
|
||||||
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
|
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
|
||||||
$versionminorregex = $val, next if $key eq 'versionminorregex';
|
$versionminorregex = $val, next if $key eq 'versionminorregex';
|
||||||
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
|
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
|
||||||
|
@ -493,6 +497,12 @@ my %headerfuncshasdoxygen = (); # $headerfuncschunk{"SDL_OpenAudio"} -> 1 if t
|
||||||
my $incpath = "$srcpath";
|
my $incpath = "$srcpath";
|
||||||
$incpath .= "/$incsubdir" if $incsubdir ne '';
|
$incpath .= "/$incsubdir" if $incsubdir ne '';
|
||||||
|
|
||||||
|
my $wikireadmepath = "$wikipath/$wikireadmesubdir";
|
||||||
|
my $readmepath = undef;
|
||||||
|
if (defined $readmesubdir) {
|
||||||
|
$readmepath = "$srcpath/$readmesubdir";
|
||||||
|
}
|
||||||
|
|
||||||
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
||||||
while (readdir(DH)) {
|
while (readdir(DH)) {
|
||||||
my $dent = $_;
|
my $dent = $_;
|
||||||
|
@ -1004,6 +1014,19 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
|
rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined $readmepath) {
|
||||||
|
if ( -d $wikireadmepath ) {
|
||||||
|
mkdir($readmepath); # just in case
|
||||||
|
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
|
||||||
|
while (readdir(DH)) {
|
||||||
|
my $dent = $_;
|
||||||
|
if ($dent =~ /\A(.*?)\.md\Z/) { # we only bridge Markdown files here.
|
||||||
|
copy("$wikireadmepath/$dent", "$readmepath/README-$dent") or die("failed to copy '$wikireadmepath/$dent' to '$readmepath/README-$dent': $!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(DH);
|
||||||
|
}
|
||||||
|
}
|
||||||
} elsif ($copy_direction == -1) { # --copy-to-wiki
|
} elsif ($copy_direction == -1) { # --copy-to-wiki
|
||||||
|
|
||||||
if (defined $changeformat) {
|
if (defined $changeformat) {
|
||||||
|
@ -1333,6 +1356,35 @@ if ($copy_direction == 1) { # --copy-to-headers
|
||||||
rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n");
|
rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (defined $readmepath) {
|
||||||
|
if ( -d $readmepath ) {
|
||||||
|
mkdir($wikireadmepath); # just in case
|
||||||
|
opendir(DH, $readmepath) or die("Can't opendir '$readmepath': $!\n");
|
||||||
|
while (readdir(DH)) {
|
||||||
|
my $dent = $_;
|
||||||
|
if ($dent =~ /\AREADME\-(.*?\.md)\Z/) { # we only bridge Markdown files here.
|
||||||
|
my $wikifname = $1;
|
||||||
|
copy("$readmepath/$dent", "$wikireadmepath/$wikifname") or die("failed to copy '$readmepath/$dent' to '$wikireadmepath/$wikifname': $!\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(DH);
|
||||||
|
|
||||||
|
open(FH, '>', "$wikireadmepath/FrontPage.md") or die("Can't open '$wikireadmepath/FrontPage.md': $!\n");
|
||||||
|
print FH "# All READMEs available here\n\n";
|
||||||
|
|
||||||
|
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
|
||||||
|
while (readdir(DH)) {
|
||||||
|
my $dent = $_;
|
||||||
|
if ($dent =~ /\A(.*?)\.(mediawiki|md)\Z/) {
|
||||||
|
my $wikiname = $1;
|
||||||
|
print FH "- [$wikiname]($wikiname)\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir(DH);
|
||||||
|
close(FH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} elsif ($copy_direction == -2) { # --copy-to-manpages
|
} 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.
|
# This only takes from the wiki data, since it has sections we omit from the headers, like code examples.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue