mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-05 19:08:12 +00:00
wikiheaders: Generate a current list of supported environment variables.
Fixes #13827.
This commit is contained in:
@@ -31,3 +31,11 @@ quickreftitle = SDL3 API Quick Reference
|
||||
quickrefurl = https://libsdl.org/
|
||||
quickrefdesc = The latest version of this document can be found at https://wiki.libsdl.org/SDL3/QuickReference
|
||||
quickrefmacroregex = \A(SDL_PLATFORM_.*|SDL_.*_INTRINSICS|SDL_Atomic...Ref|SDL_assert.*?|SDL_COMPILE_TIME_ASSERT|SDL_arraysize|SDL_Swap[BL]E\d\d|SDL_[a-z]+_cast)\Z
|
||||
|
||||
envvarenabled = 1
|
||||
envvartitle = SDL3 Environment Variables
|
||||
envvardesc = SDL3 can be controlled by the user, externally, with environment variables. They are all operate exactly like the [hints you can get and set programmatically](CategoryHints), but named without the `_HINT` part (so `"SDL_HINT_A"` would be environment variable `"SDL_A"`).\n\nThis list matches the latest in SDL3's revision control.
|
||||
envvarsymregex = \ASDL_HINT_(.*)\Z
|
||||
envvarsymreplace = SDL_$1
|
||||
|
||||
|
||||
|
@@ -58,6 +58,11 @@ my $quickreftitle = undef;
|
||||
my $quickrefurl = undef;
|
||||
my $quickrefdesc = undef;
|
||||
my $quickrefmacroregex = undef;
|
||||
my $envvarenabled = 0;
|
||||
my $envvartitle = 'Environment Variables';
|
||||
my $envvardesc = undef;
|
||||
my $envvarsymregex = undef;
|
||||
my $envvarsymreplace = undef;
|
||||
my $changeformat = undef;
|
||||
my $manpath = undef;
|
||||
my $gitrev = undef;
|
||||
@@ -137,6 +142,11 @@ if (defined $optionsfname) {
|
||||
$quickrefurl = $val, next if $key eq 'quickrefurl';
|
||||
$quickrefdesc = $val, next if $key eq 'quickrefdesc';
|
||||
$quickrefmacroregex = $val, next if $key eq 'quickrefmacroregex';
|
||||
$envvarenabled = int($val), next if $key eq 'envvarenabled';
|
||||
$envvartitle = $val, next if $key eq 'envvartitle';
|
||||
$envvardesc = $val, next if $key eq 'envvardesc';
|
||||
$envvarsymregex = $val, next if $key eq 'envvarsymregex';
|
||||
$envvarsymreplace = $val, next if $key eq 'envvarsymreplace';
|
||||
}
|
||||
}
|
||||
close(OPTIONS);
|
||||
@@ -1034,6 +1044,55 @@ sub generate_quickref {
|
||||
}
|
||||
|
||||
|
||||
sub generate_envvar_wiki_page {
|
||||
my $briefsref = shift;
|
||||
my $path = shift;
|
||||
|
||||
return if not $envvarenabled or not defined $envvarsymregex or not defined $envvarsymreplace;
|
||||
|
||||
my $replace = "\"$envvarsymreplace\"";
|
||||
my $tmppath = "$path.tmp";
|
||||
open(my $fh, '>', $tmppath) or die("Can't open '$tmppath': $!\n");
|
||||
|
||||
print $fh "<!-- DO NOT EDIT THIS PAGE ON THE WIKI. IT WILL BE OVERWRITTEN BY WIKIHEADERS AND CHANGES WILL BE LOST! -->\n\n";
|
||||
print $fh "# $envvartitle\n\n";
|
||||
|
||||
if (defined $envvardesc) {
|
||||
my $desc = "$envvardesc";
|
||||
$desc =~ s/\\n/\n/g; # replace "\n" strings with actual newlines.
|
||||
print $fh "$desc\n\n";
|
||||
}
|
||||
|
||||
print $fh "## Environment Variable List\n\n";
|
||||
|
||||
foreach (sort keys %headersyms) {
|
||||
my $sym = $_;
|
||||
next if $headersymstype{$sym} != 2; # not a #define? skip it.
|
||||
my $hint = "$_";
|
||||
next if not $hint =~ s/$envvarsymregex/$replace/ee;
|
||||
|
||||
my $brief = $$briefsref{$sym};
|
||||
if (not defined $brief) {
|
||||
$brief = '';
|
||||
} else {
|
||||
$brief = "$brief";
|
||||
chomp($brief);
|
||||
my $thiswikitype = defined $wikitypes{$sym} ? $wikitypes{$sym} : 'md'; # default to MarkDown for new stuff.
|
||||
$brief = ": " . dewikify($thiswikitype, $brief);
|
||||
}
|
||||
print $fh "- [$hint]($sym)$brief\n";
|
||||
}
|
||||
|
||||
print $fh "\n";
|
||||
|
||||
close($fh);
|
||||
|
||||
rename($tmppath, $path) or die("Can't rename '$tmppath' to '$path': $!\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
my $incpath = "$srcpath";
|
||||
$incpath .= "/$incsubdir" if $incsubdir ne '';
|
||||
|
||||
@@ -2733,6 +2792,11 @@ __EOF__
|
||||
generate_quickref(\%briefs, "$wikipath/QuickReference.md", 0);
|
||||
generate_quickref(\%briefs, "$wikipath/QuickReferenceNoUnicode.md", 1);
|
||||
}
|
||||
|
||||
if ($envvarenabled and defined $envvarsymregex and defined $envvarsymreplace) {
|
||||
generate_envvar_wiki_page(\%briefs, "$wikipath/EnvironmentVariables.md");
|
||||
}
|
||||
|
||||
} 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.
|
||||
|
||||
|
Reference in New Issue
Block a user