Allow adding of new args through overrides in man generator
This commit is contained in:
parent
91bd428c22
commit
6900c4f9a1
@ -39,12 +39,12 @@ def format_groff(k, v, arg=None, typ='arg'):
|
|||||||
|
|
||||||
class DocEntry:
|
class DocEntry:
|
||||||
|
|
||||||
def __init__(self, *args, argvalue=None, typ='arg'):
|
def __init__(self, *args, typ='arg'):
|
||||||
self.flags = args
|
self.flags = args
|
||||||
self.v = argvalue
|
|
||||||
self.render = self.get_empty
|
self.render = self.get_empty
|
||||||
self.groff = None
|
self.groff = None
|
||||||
self.typ = typ
|
self.typ = typ
|
||||||
|
self.v = None
|
||||||
|
|
||||||
|
|
||||||
def __check_line_default(self, m):
|
def __check_line_default(self, m):
|
||||||
@ -68,6 +68,10 @@ class DocEntry:
|
|||||||
self.groff = v
|
self.groff = v
|
||||||
|
|
||||||
|
|
||||||
|
def set_groff_argvalue(self, argvalue):
|
||||||
|
self.v = '\\fI' + argvalue + '\\fP'
|
||||||
|
|
||||||
|
|
||||||
def get_groff(self):
|
def get_groff(self):
|
||||||
v = self.groff
|
v = self.groff
|
||||||
if v == None:
|
if v == None:
|
||||||
@ -113,10 +117,19 @@ class DocGenerator:
|
|||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
def override_arg(self, k, v, args):
|
def set_arg(self, k, v, flags, argvalue=None):
|
||||||
|
o = DocEntry(*flags)
|
||||||
|
o.set_groff_argvalue(argvalue)
|
||||||
|
o.set_groff(v)
|
||||||
|
self.docs[k] = o
|
||||||
|
|
||||||
|
|
||||||
|
def override_arg(self, k, v, args, argvalue=None):
|
||||||
o = self.docs[k]
|
o = self.docs[k]
|
||||||
#g.docs[v[0]].groff = v[1].rstrip()
|
#g.docs[v[0]].groff = v[1].rstrip()
|
||||||
o.set_groff(v)
|
o.set_groff(v)
|
||||||
|
if argvalue != None:
|
||||||
|
o.set_groff_argvalue(argvalue)
|
||||||
l = len(args)
|
l = len(args)
|
||||||
if l > 0:
|
if l > 0:
|
||||||
o.flags = []
|
o.flags = []
|
||||||
@ -147,16 +160,19 @@ class DocGenerator:
|
|||||||
self.docs['vv'] = o
|
self.docs['vv'] = o
|
||||||
|
|
||||||
if self.arg_flags & Flag.CONFIG:
|
if self.arg_flags & Flag.CONFIG:
|
||||||
o = DocEntry('-c', '--config', argvalue='config_dir')
|
o = DocEntry('-c', '--config')
|
||||||
o.set_groff('Load configuration files from given directory. All files with an .ini extension will be loaded, of which all must contain valid ini file data.')
|
o.set_groff('Load configuration files from given directory. All files with an .ini extension will be loaded, of which all must contain valid ini file data.')
|
||||||
|
o.set_groff_argvalue('config_dir')
|
||||||
self.docs['c'] = o
|
self.docs['c'] = o
|
||||||
|
|
||||||
o = DocEntry('-n', '--namespace', argvalue='namespace')
|
o = DocEntry('-n', '--namespace')
|
||||||
o.set_groff('Load given configuration namespace. Configuration will be loaded from the immediate configuration subdirectory with the same name.')
|
o.set_groff('Load given configuration namespace. Configuration will be loaded from the immediate configuration subdirectory with the same name.')
|
||||||
|
o.set_groff_argvalue('namespace')
|
||||||
self.docs['n'] = o
|
self.docs['n'] = o
|
||||||
|
|
||||||
o = DocEntry('--dumpconfig', argvalue='format')
|
o = DocEntry('--dumpconfig')
|
||||||
o.set_groff('Output configuration settings rendered from environment and inputs. Valid arguments are \\fIini\\fP for ini file output, and \\fIenv\\fP for environment variable output. See \\fBCONFIGURATION\\fP.')
|
o.set_groff('Output configuration settings rendered from environment and inputs. Valid arguments are \\fIini\\fP for ini file output, and \\fIenv\\fP for environment variable output. See \\fBCONFIGURATION\\fP.')
|
||||||
|
o.set_groff_argvalue('format')
|
||||||
self.docs['dumpconfig'] = o
|
self.docs['dumpconfig'] = o
|
||||||
|
|
||||||
|
|
||||||
@ -204,8 +220,9 @@ class DocGenerator:
|
|||||||
|
|
||||||
|
|
||||||
if self.arg_flags & Flag.CHAIN_SPEC:
|
if self.arg_flags & Flag.CHAIN_SPEC:
|
||||||
o = DocEntry('-i', '--chain-spec', argvalue='chain_spec')
|
o = DocEntry('-i', '--chain-spec')
|
||||||
o.set_groff('Chain specification string, in the format <engine>:<fork>:<chain_id>:<common_name>. Example: "evm:london:1:ethereum".')
|
o.set_groff('Chain specification string, in the format <engine>:<fork>:<chain_id>:<common_name>. Example: "evm:london:1:ethereum".')
|
||||||
|
o.set_groff_argvalue('chain_spec')
|
||||||
self.docs['i'] = o
|
self.docs['i'] = o
|
||||||
self.envs['i'] = 'RPC_CREDENTIALS'
|
self.envs['i'] = 'RPC_CREDENTIALS'
|
||||||
|
|
||||||
@ -223,13 +240,15 @@ class DocGenerator:
|
|||||||
|
|
||||||
|
|
||||||
if self.arg_flags & Flag.KEY_FILE:
|
if self.arg_flags & Flag.KEY_FILE:
|
||||||
o = DocEntry('-y', '--key-path', argvalue='path')
|
o = DocEntry('-y', '--key-path')
|
||||||
o.set_groff('Path to signing key.')
|
o.set_groff('Path to signing key.')
|
||||||
|
o.set_groff_argvalue('path')
|
||||||
self.docs['y'] = o
|
self.docs['y'] = o
|
||||||
self.envs['y'] = 'WALLET_KEY_FILE'
|
self.envs['y'] = 'WALLET_KEY_FILE'
|
||||||
|
|
||||||
o = DocEntry('--passphrase-file', argvalue='path')
|
o = DocEntry('--passphrase-file')
|
||||||
o.set_groff('Path to file containing password to unlock key file')
|
o.set_groff('Path to file containing password to unlock key file')
|
||||||
|
o.set_groff_argvalue('path')
|
||||||
self.docs['passphrasefile'] = o
|
self.docs['passphrasefile'] = o
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,20 +118,23 @@ def apply_override(g, override_dir):
|
|||||||
s = f.readline()
|
s = f.readline()
|
||||||
if len(s) == 0:
|
if len(s) == 0:
|
||||||
break
|
break
|
||||||
v = s.split('\t', maxsplit=2)
|
v = s.split('\t', maxsplit=4)
|
||||||
fargs = None
|
fargs = None
|
||||||
try:
|
try:
|
||||||
fargs = v[2].rstrip().split(',')
|
fargs = v[2].rstrip().split(',')
|
||||||
except IndexError:
|
except IndexError:
|
||||||
fargs = []
|
fargs = []
|
||||||
g.override_arg(v[0], v[1], fargs)
|
argvalue = None
|
||||||
|
if len(v) == 4:
|
||||||
|
argvalue = v[3]
|
||||||
|
try:
|
||||||
|
g.override_arg(v[0], v[1], fargs, argvalue=argvalue)
|
||||||
|
except KeyError:
|
||||||
|
logg.info('adding not previously registered key {} flags: {}'.format(v[0], ','.join(fargs)))
|
||||||
|
g.set_arg(v[0], v[1], fargs, argvalue=argvalue)
|
||||||
f.close()
|
f.close()
|
||||||
return g
|
return g
|
||||||
|
|
||||||
g = apply_override(g, args.source_dir)
|
|
||||||
|
|
||||||
ge = EnvDocGenerator(flags, override=args.overrides_env_dir)
|
|
||||||
ge.process()
|
|
||||||
|
|
||||||
def get_head(tool_name, source_dir):
|
def get_head(tool_name, source_dir):
|
||||||
header_file = os.path.join(source_dir, tool_name + '.head.groff')
|
header_file = os.path.join(source_dir, tool_name + '.head.groff')
|
||||||
@ -169,6 +172,11 @@ def get_custom(tool_name, source_dir):
|
|||||||
return custom
|
return custom
|
||||||
|
|
||||||
|
|
||||||
|
g = apply_override(g, args.source_dir)
|
||||||
|
|
||||||
|
ge = EnvDocGenerator(flags, override=args.overrides_env_dir)
|
||||||
|
ge.process()
|
||||||
|
|
||||||
head = get_head(toolname, args.source_dir)
|
head = get_head(toolname, args.source_dir)
|
||||||
examples = get_examples(toolname, args.source_dir)
|
examples = get_examples(toolname, args.source_dir)
|
||||||
custom = get_custom(toolname, args.source_dir)
|
custom = get_custom(toolname, args.source_dir)
|
||||||
|
Loading…
Reference in New Issue
Block a user