expand docgen/default.cfg.template substitutions
Move to a "substs" hash in docgen which contains pairs of strings
to substitute. Populate @GAME@, @GAME_UPPER@ and @CFGFILE@ based
on the game supplied via -g.
Make the corresponding substitutions in default.cfg.template. Now
all of {default,heretic,hexen,strife}.cfg.5 are correct for the
respective game.
This commit is contained in:
parent
f515c88a96
commit
32ccfe015a
2 changed files with 35 additions and 33 deletions
|
|
@ -1,22 +1,22 @@
|
||||||
.TH default.cfg 5
|
.TH @CFGFILE@ 5
|
||||||
.SH NAME
|
.SH NAME
|
||||||
default.cfg \- @PACKAGE_NAME@ configuration file
|
@CFGFILE@ \- @PACKAGE_SHORTNAME@ @GAME_UPPER@ configuration file
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.PP
|
.PP
|
||||||
\fIdefault.cfg\fR
|
\fI@CFGFILE@\fR
|
||||||
is the configuration file for \fB@PROGRAM_SPREFIX@\-doom\fR(6). The configuration
|
is the configuration file for \fB@PROGRAM_SPREFIX@\-@GAME@\fR(6). The configuration
|
||||||
options stored in the file are the same as those stored in the
|
options stored in the file are the same as those stored in the
|
||||||
original DOS Vanilla Doom.
|
original DOS Vanilla @GAME_UPPER@.
|
||||||
Extra @PACKAGE_NAME@-specific options are stored in a separate
|
Extra @PACKAGE_SHORTNAME@ @GAME_UPPER@-specific options are stored in a separate
|
||||||
configuration file, \fB@PROGRAM_SPREFIX@\-doom.cfg\fR.
|
configuration file, \fB@PROGRAM_SPREFIX@\-@GAME@.cfg\fR.
|
||||||
.PP
|
.PP
|
||||||
\fIdefault.cfg\fR is normally stored in the user's home directory,
|
\fI@CFGFILE@\fR is normally stored in the user's home directory,
|
||||||
as \fI~/.local/share/@PROGRAM_SPREFIX@\-doom/default.cfg\fR. The path can be
|
as \fI~/.local/share/@PROGRAM_SPREFIX@\-@GAME@/@CFGFILE@\fR. The path can be
|
||||||
overridden using the \fBXDG_DATA_HOME\fR environment variable (see the XDG
|
overridden using the \fBXDG_DATA_HOME\fR environment variable (see the XDG
|
||||||
Base Directory Specification).
|
Base Directory Specification).
|
||||||
.PP
|
.PP
|
||||||
The \fB@PROGRAM_SPREFIX@\-setup\fR(6) tool provides a simple to use front-end
|
The \fB@PROGRAM_SPREFIX@\-@GAME@\-setup\fR(6) tool provides a simple to use front-end
|
||||||
for editing \fIdefault.cfg\fR.
|
for editing \fI@CFGFILE@\fR.
|
||||||
.br
|
.br
|
||||||
.SH FILE FORMAT
|
.SH FILE FORMAT
|
||||||
The file is a plain-text file, consisting of a list of configuration
|
The file is a plain-text file, consisting of a list of configuration
|
||||||
|
|
@ -49,7 +49,7 @@ indicating "false" and a non-zero value indicating "true".
|
||||||
@content
|
@content
|
||||||
|
|
||||||
.SH SEE ALSO
|
.SH SEE ALSO
|
||||||
\fB@PROGRAM_SPREFIX@\-doom\fR(6),
|
\fB@PROGRAM_SPREFIX@\-@GAME@\fR(6),
|
||||||
\fB@PROGRAM_SPREFIX@\-doom.cfg\fR(5),
|
\fB@PROGRAM_SPREFIX@\-@GAME@.cfg\fR(5),
|
||||||
\fB@PROGRAM_SPREFIX@\-setup\fR(6)
|
\fB@PROGRAM_SPREFIX@\-@GAME@\-setup\fR(6)
|
||||||
|
|
||||||
|
|
|
||||||
40
man/docgen
40
man/docgen
|
|
@ -430,7 +430,7 @@ def process_files(path):
|
||||||
|
|
||||||
process_file(path)
|
process_file(path)
|
||||||
|
|
||||||
def print_template(template_file, program_prefix, package_name, package_shortname, content):
|
def print_template(template_file, substs, content):
|
||||||
f = io.open(template_file, encoding='UTF-8')
|
f = io.open(template_file, encoding='UTF-8')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
@ -440,18 +440,16 @@ def print_template(template_file, program_prefix, package_name, package_shortnam
|
||||||
filename = match.group(1)
|
filename = match.group(1)
|
||||||
filename = os.path.join(os.path.dirname(template_file),
|
filename = os.path.join(os.path.dirname(template_file),
|
||||||
filename)
|
filename)
|
||||||
print_template(filename, program_prefix, package_name, package_shortname, content)
|
print_template(filename, substs, content)
|
||||||
else:
|
else:
|
||||||
line = line.replace("@content", content)
|
line = line.replace("@content", content)
|
||||||
line = line.replace("@PROGRAM_SPREFIX@", program_prefix)
|
for k,v in substs.items():
|
||||||
line = line.replace("@PACKAGE_NAME@", package_name)
|
line = line.replace(k,v)
|
||||||
if package_shortname:
|
|
||||||
line = line.replace("@PACKAGE_SHORTNAME@", package_shortname)
|
|
||||||
stdout(line.rstrip().encode('UTF-8') + b'\n')
|
stdout(line.rstrip().encode('UTF-8') + b'\n')
|
||||||
finally:
|
finally:
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def manpage_output(targets, program_prefix, package_name, package_shortname, template_file):
|
def manpage_output(targets, substs, template_file):
|
||||||
|
|
||||||
content = ""
|
content = ""
|
||||||
|
|
||||||
|
|
@ -460,7 +458,7 @@ def manpage_output(targets, program_prefix, package_name, package_shortname, tem
|
||||||
|
|
||||||
content = content.replace("-", "\\-")
|
content = content.replace("-", "\\-")
|
||||||
|
|
||||||
print_template(template_file, program_prefix, package_name, package_shortname, content)
|
print_template(template_file, substs, content)
|
||||||
|
|
||||||
def wiki_output(targets, template):
|
def wiki_output(targets, template):
|
||||||
read_wikipages()
|
read_wikipages()
|
||||||
|
|
@ -468,23 +466,23 @@ def wiki_output(targets, template):
|
||||||
for t in targets:
|
for t in targets:
|
||||||
stdout(t.wiki_output().encode('UTF-8') + b'\n')
|
stdout(t.wiki_output().encode('UTF-8') + b'\n')
|
||||||
|
|
||||||
def plaintext_output(targets, program_prefix, package_name, package_shortname, template_file):
|
def plaintext_output(targets, substs, template_file):
|
||||||
|
|
||||||
content = ""
|
content = ""
|
||||||
|
|
||||||
for t in targets:
|
for t in targets:
|
||||||
content += t.plaintext_output() + "\n"
|
content += t.plaintext_output() + "\n"
|
||||||
|
|
||||||
print_template(template_file, program_prefix, package_name, package_shortname, content)
|
print_template(template_file, substs, content)
|
||||||
|
|
||||||
def completion_output(targets, program_prefix, package_name, package_shortname, template_file):
|
def completion_output(targets, substs, template_file):
|
||||||
|
|
||||||
content = ""
|
content = ""
|
||||||
|
|
||||||
for t in targets:
|
for t in targets:
|
||||||
content += t.completion_output() + "\n"
|
content += t.completion_output() + "\n"
|
||||||
|
|
||||||
print_template(template_file, program_prefix, package_name, package_shortname, content)
|
print_template(template_file, substs, content)
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print("Usage: %s [-V] [-c tag] [-g game] -n program_name -s package_name [ -z shortname ] ( -m | -w | -p ) <dir>..." \
|
print("Usage: %s [-V] [-c tag] [-g game] -n program_name -s package_name [ -z shortname ] ( -m | -w | -p ) <dir>..." \
|
||||||
|
|
@ -510,17 +508,15 @@ output_function = None
|
||||||
template = None
|
template = None
|
||||||
doc_config_file = None
|
doc_config_file = None
|
||||||
match_game = None
|
match_game = None
|
||||||
program_prefix = None
|
substs = {}
|
||||||
package_name = None
|
|
||||||
package_shortname = None
|
|
||||||
|
|
||||||
for opt in opts:
|
for opt in opts:
|
||||||
if opt[0] == "-n":
|
if opt[0] == "-n":
|
||||||
program_prefix = opt[1]
|
substs["@PROGRAM_SPREFIX@"] = opt[1]
|
||||||
if opt[0] == "-s":
|
if opt[0] == "-s":
|
||||||
package_name = opt[1]
|
substs["@PACKAGE_NAME@"] = opt[1]
|
||||||
if opt[0] == "-z":
|
if opt[0] == "-z":
|
||||||
package_shortname = opt[1]
|
substs["@PACKAGE_SHORTNAME@"] = opt[1]
|
||||||
if opt[0] == "-m":
|
if opt[0] == "-m":
|
||||||
output_function = manpage_output
|
output_function = manpage_output
|
||||||
template = opt[1]
|
template = opt[1]
|
||||||
|
|
@ -538,6 +534,12 @@ for opt in opts:
|
||||||
doc_config_file = opt[1]
|
doc_config_file = opt[1]
|
||||||
elif opt[0] == "-g":
|
elif opt[0] == "-g":
|
||||||
match_game = opt[1]
|
match_game = opt[1]
|
||||||
|
substs["@GAME@"] = opt[1]
|
||||||
|
substs["@GAME_UPPER@"] = opt[1].title()
|
||||||
|
if "doom" == opt[1]:
|
||||||
|
substs["@CFGFILE@"] = "default.cfg"
|
||||||
|
else:
|
||||||
|
substs["@CFGFILE@"] = opt[1] + ".cfg"
|
||||||
|
|
||||||
if output_function == None or len(args) < 1:
|
if output_function == None or len(args) < 1:
|
||||||
usage()
|
usage()
|
||||||
|
|
@ -562,5 +564,5 @@ else:
|
||||||
|
|
||||||
# Generate the output
|
# Generate the output
|
||||||
|
|
||||||
output_function(documentation_targets, program_prefix, package_name, package_shortname, template)
|
output_function(documentation_targets, substs, template)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue