MCPcopy Create free account
hub / github.com/DFHack/dfhack / parse_args

Function parse_args

docs/build.py:45–78  ·  view source on GitHub ↗
(source_args)

Source from the content-addressed store, hash-verified

43 return args, forward_args
44
45def parse_args(source_args):
46 def output_format(s):
47 if s in OUTPUT_FORMATS:
48 return s
49 raise ValueError
50
51 parser = argparse.ArgumentParser(usage='%(prog)s [{} ...] [options] [--] [sphinx_options]'.format('|'.join(OUTPUT_FORMATS.keys())), description='''
52 DFHack wrapper around sphinx-build.
53
54 Any unrecognized options are passed directly to sphinx-build, as well as any
55 options following a '--' argument, if specified.
56 ''')
57 parser.add_argument('format', nargs='*', type=output_format, action='append',
58 help='Documentation format(s) to build - choose from {}'.format(', '.join(OUTPUT_FORMATS.keys())))
59 parser.add_argument('-E', '--clean', action='store_true',
60 help='Re-read all input files')
61 parser.add_argument('--sphinx', type=str, default=os.environ.get('SPHINX', 'sphinx-build'),
62 help='Sphinx executable to run [environment variable: SPHINX; default: "sphinx-build"]')
63 parser.add_argument('-j', '--jobs', type=str, default=os.environ.get('JOBS', 'auto'),
64 help='Number of Sphinx threads to run [environment variable: JOBS; default: "auto"]')
65 parser.add_argument('-q', '--quiet', action='store_true',
66 help='Disable most output on stdout (also passed to sphinx-build)')
67 parser.add_argument('--debug', action='store_true',
68 help='Log commands that are run, etc.')
69 parser.add_argument('--offline', action='store_true',
70 help='Disable network connections')
71 args, forward_args = _parse_known_args(parser, source_args)
72
73 # work around weirdness with list args
74 args.format = args.format[0]
75 if not args.format:
76 args.format = ['html']
77
78 return args, forward_args
79
80if __name__ == '__main__':
81 os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

Callers 1

build.pyFile · 0.85

Calls 3

_parse_known_argsFunction · 0.85
formatMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected