3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-08-04 10:20:24 +00:00

log_help: Json dumpable

Current modes are `LOG` and `LISTING`, which `log()` and store for conversion to json respectively.
Add `ContentListing` listing struct to (recursively) contain help data for conversion to a json object to be exported and used elsewhere (e.g. the docs).
Rather than formatting as rst we can just export with type information and do the conversion at the destination (i.e. in the python code which loads the domain for autodoc).
Implement `PrettyHelp::has_content()`.
Provide `PrettyHelp::get_content()` which returns a read-only list of the current content.
`PrettyHelp` constructor takes optional `Mode` enum to define format of help content.
Updates `PrettyHelp` methods to use a switch case for checking current mode, calling `log_abort()` in the default case (i.e. unsupported mode).
This commit is contained in:
Krystine Sherwin 2025-07-21 10:34:12 +12:00
parent ae3514adfd
commit d4498acea7
No known key found for this signature in database
3 changed files with 164 additions and 29 deletions

View file

@ -822,7 +822,7 @@ struct HelpPass : public Pass {
auto title = pass->short_help;
auto experimental_flag = pass->experimental_flag;
auto cmd_help = PrettyHelp();
auto cmd_help = PrettyHelp(PrettyHelp::Mode::LISTING);
auto has_pretty_help = pass->help_v2();
if (!has_pretty_help) {
@ -919,7 +919,10 @@ struct HelpPass : public Pass {
// write to json
json.name(name.c_str()); json.begin_object();
json.entry("title", title);
// json.entry("content", cmd_help);
json.name("content"); json.begin_array();
for (auto content : cmd_help.get_content())
json.value(content->to_json());
json.end_array();
json.entry("experimental_flag", experimental_flag);
json.end_object();
}