mirror of
https://github.com/YosysHQ/yosys
synced 2025-06-19 20:33:39 +00:00
cmdref: Drop optiongroups
Linking to optiongroups doesn't add *that* much, and is kind of a pain; meanwhile having the optiongroups adds an extra level of indentation. Instead of options needing to be in an option group, they instead go in either the root node or nested in a usage node. Putting them in a usage node allows for more-or-less the previous behaviour but without making it the default.
This commit is contained in:
parent
a2433ba34b
commit
ebd6d5f85b
7 changed files with 117 additions and 148 deletions
|
@ -34,11 +34,11 @@ Json ContentListing::to_json() {
|
|||
return object;
|
||||
}
|
||||
|
||||
void ContentListing::usage(const string &usage,
|
||||
void ContentListing::usage(const string &text,
|
||||
const source_location location)
|
||||
{
|
||||
log_assert(type.compare("root") == 0);
|
||||
add_content("usage", usage, location);
|
||||
add_content("usage", text, location);
|
||||
}
|
||||
|
||||
void ContentListing::option(const string &text, const string &description,
|
||||
|
@ -62,19 +62,17 @@ void ContentListing::paragraph(const string &text,
|
|||
add_content("text", text, location);
|
||||
}
|
||||
|
||||
ContentListing* ContentListing::open_optiongroup(const string &name,
|
||||
ContentListing* ContentListing::open_usage(const string &text,
|
||||
const source_location location)
|
||||
{
|
||||
log_assert(type.compare("root") == 0);
|
||||
auto optiongroup = new ContentListing("optiongroup", name, location);
|
||||
add_content(optiongroup);
|
||||
return optiongroup;
|
||||
usage(text, location);
|
||||
return back();
|
||||
}
|
||||
|
||||
ContentListing* ContentListing::open_option(const string &text,
|
||||
const source_location location)
|
||||
{
|
||||
log_assert(type.compare("optiongroup") == 0);
|
||||
log_assert(type.compare("root") == 0 || type.compare("usage") == 0);
|
||||
auto option = new ContentListing("option", text, location);
|
||||
add_content(option);
|
||||
return option;
|
||||
|
@ -138,16 +136,15 @@ void PrettyHelp::log_help()
|
|||
for (auto content : _root_listing.get_content()) {
|
||||
if (content->type.compare("usage") == 0) {
|
||||
log_pass_str(content->body, 1, true);
|
||||
} else if (content->type.compare("optiongroup") == 0) {
|
||||
for (auto option : content->get_content()) {
|
||||
log_pass_str(option->body, 1);
|
||||
for (auto text : option->get_content()) {
|
||||
log_pass_str(text->body, 2);
|
||||
log("\n");
|
||||
}
|
||||
log("\n");
|
||||
} else if (content->type.compare("option") == 0) {
|
||||
log_pass_str(content->body, 1);
|
||||
for (auto text : content->get_content()) {
|
||||
log_pass_str(text->body, 2);
|
||||
log("\n");
|
||||
}
|
||||
} else {
|
||||
log_pass_str(content->body, 0, true);
|
||||
log_pass_str(content->body, 0);
|
||||
log("\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public:
|
|||
}
|
||||
|
||||
void usage(
|
||||
const string &usage,
|
||||
const string &text,
|
||||
const source_location location = source_location::current()
|
||||
);
|
||||
void option(
|
||||
|
@ -86,8 +86,8 @@ public:
|
|||
const source_location location = source_location::current()
|
||||
);
|
||||
|
||||
ContentListing* open_optiongroup(
|
||||
const string &name = "",
|
||||
ContentListing* open_usage(
|
||||
const string &text,
|
||||
const source_location location = source_location::current()
|
||||
);
|
||||
ContentListing* open_option(
|
||||
|
|
|
@ -947,13 +947,8 @@ struct HelpPass : public Pass {
|
|||
current_listing->codeblock(current_buffer, "none", null_source);
|
||||
current_buffer = "";
|
||||
}
|
||||
if (current_state == PUState_options || current_state == PUState_optionbody) {
|
||||
current_listing = root_listing->back();
|
||||
} else {
|
||||
current_listing = root_listing->open_optiongroup("", null_source);
|
||||
}
|
||||
current_state = PUState_options;
|
||||
current_listing = current_listing->open_option(stripped_line, null_source);
|
||||
current_listing = root_listing->open_option(stripped_line, null_source);
|
||||
def_strip_count = first_pos;
|
||||
} else {
|
||||
if (current_state == PUState_options) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue