summaryrefslogtreecommitdiff
path: root/src/options/mkoptions.py
diff options
context:
space:
mode:
authorGereon Kremer <nafur42@gmail.com>2021-10-27 16:27:31 -0700
committerGitHub <noreply@github.com>2021-10-27 23:27:31 +0000
commit5ea33ca829d257d408a242974b28bd6defafff6e (patch)
treeaeb4e828270efaf28237b65d5e2b92fc04f02506 /src/options/mkoptions.py
parent1a9de6eaa2fb9b78581a8195bf3057aaf886a030 (diff)
Add documentation on output tags (#7499)
This PR adds documentation on how users can use -o. After some offline discussion, we decided it makes sense to generate them automatically in mkoptions.py and also include example outputs.
Diffstat (limited to 'src/options/mkoptions.py')
-rw-r--r--src/options/mkoptions.py38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/options/mkoptions.py b/src/options/mkoptions.py
index 7288ede51..70eb138cc 100644
--- a/src/options/mkoptions.py
+++ b/src/options/mkoptions.py
@@ -817,6 +817,38 @@ def generate_sphinx_help(modules):
################################################################################
+# sphinx documentation for --output @ docs/output_tags_generated.rst
+
+
+def generate_sphinx_output_tags(modules, src_dir, build_dir):
+ """Render help for the --output option for sphinx."""
+ base = next(filter(lambda m: m.id == 'base', modules))
+ opt = next(filter(lambda o: o.name == 'outputTag', base.options))
+
+ # The programoutput extension has weird semantics about the cwd:
+ # https://sphinxcontrib-programoutput.readthedocs.io/en/latest/#usage
+ cwd = '/' + os.path.relpath(build_dir, src_dir)
+
+ res = []
+ for name,info in opt.mode.items():
+ info = info[0]
+ if 'description' not in info:
+ continue
+ res.append('{} (``-o {}``)'.format(name, info['name']))
+ res.append('~' * len(res[-1]))
+ res.append('')
+ res.append(info['description'])
+ if 'example-file' in info:
+ res.append('')
+ res.append('.. command-output:: bin/cvc5 -o {} ../test/regress/{}'.format(info['name'], info['example-file']))
+ res.append(' :cwd: {}'.format(cwd))
+ res.append('')
+ res.append('')
+
+ return '\n'.join(res)
+
+
+################################################################################
# main code generation for individual modules
@@ -843,7 +875,7 @@ def codegen_module(module, dst_dir, tpls):
# main code generation
-def codegen_all_modules(modules, build_dir, dst_dir, tpls):
+def codegen_all_modules(modules, src_dir, build_dir, dst_dir, tpls):
"""Generate code for all option modules."""
short, cmdline_opts, parseinternal = generate_parsing(modules)
help_common, help_others = generate_cli_help(modules)
@@ -851,6 +883,8 @@ def codegen_all_modules(modules, build_dir, dst_dir, tpls):
if os.path.isdir('{}/docs/'.format(build_dir)):
write_file('{}/docs/'.format(build_dir), 'options_generated.rst',
generate_sphinx_help(modules))
+ write_file('{}/docs/'.format(build_dir), 'output_tags_generated.rst',
+ generate_sphinx_output_tags(modules, src_dir, build_dir))
data = {
# options/options.h
@@ -1045,7 +1079,7 @@ def mkoptions_main():
# Generate code
for module in modules:
codegen_module(module, dst_dir, module_tpls)
- codegen_all_modules(modules, build_dir, dst_dir, global_tpls)
+ codegen_all_modules(modules, src_dir, build_dir, dst_dir, global_tpls)
# Generate output file to signal cmake when this script was run last
open(os.path.join(dst_dir, 'options/options.stamp'), 'w').write('')
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback