mirror of https://github.com/YosysHQ/yosys.git
log_help: {add,push,pop}_content helpers
This commit is contained in:
parent
40d22adb36
commit
e447713921
|
@ -102,7 +102,7 @@ void PrettyHelp::usage(const string &usage,
|
||||||
log("\n");
|
log("\n");
|
||||||
break;
|
break;
|
||||||
case LISTING:
|
case LISTING:
|
||||||
_current_listing->add_content("usage", usage, location);
|
add_content("usage", usage, location);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_abort();
|
log_abort();
|
||||||
|
@ -121,7 +121,7 @@ void PrettyHelp::option(const string &text, const string &description,
|
||||||
log("\n");
|
log("\n");
|
||||||
break;
|
break;
|
||||||
case LISTING:
|
case LISTING:
|
||||||
_current_listing->add_content("text", description, location);
|
add_content("text", description, location);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_abort();
|
log_abort();
|
||||||
|
@ -139,7 +139,7 @@ void PrettyHelp::codeblock(const string &code, const string &language,
|
||||||
log("%s\n", code.c_str());
|
log("%s\n", code.c_str());
|
||||||
break;
|
break;
|
||||||
case LISTING:
|
case LISTING:
|
||||||
_current_listing->add_content("code", code, location);
|
add_content("code", code, location);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_abort();
|
log_abort();
|
||||||
|
@ -156,7 +156,7 @@ void PrettyHelp::paragraph(const string &text,
|
||||||
log("\n");
|
log("\n");
|
||||||
break;
|
break;
|
||||||
case LISTING:
|
case LISTING:
|
||||||
_current_listing->add_content("text", text, location);
|
add_content("text", text, location);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_abort();
|
log_abort();
|
||||||
|
@ -171,8 +171,7 @@ void PrettyHelp::open_optiongroup(const string &name,
|
||||||
case LOG:
|
case LOG:
|
||||||
break;
|
break;
|
||||||
case LISTING:
|
case LISTING:
|
||||||
_current_listing->add_content("optiongroup", name, location);
|
push_content("optiongroup", name, location);
|
||||||
_current_listing = _current_listing->content.back();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_abort();
|
log_abort();
|
||||||
|
@ -189,8 +188,7 @@ void PrettyHelp::open_option(const string &text,
|
||||||
log_pass_str(text, _current_indent);
|
log_pass_str(text, _current_indent);
|
||||||
break;
|
break;
|
||||||
case LISTING:
|
case LISTING:
|
||||||
_current_listing->add_content("option", text, location);
|
push_content("option", text, location);
|
||||||
_current_listing = _current_listing->content.back();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_abort();
|
log_abort();
|
||||||
|
@ -211,8 +209,7 @@ void PrettyHelp::close(int levels)
|
||||||
for (int i=0; i<levels; i++) {
|
for (int i=0; i<levels; i++) {
|
||||||
_current_indent--;
|
_current_indent--;
|
||||||
log_assert(_current_indent >= 0);
|
log_assert(_current_indent >= 0);
|
||||||
_current_listing = _current_listing->parent;
|
pop_content();
|
||||||
log_assert(_current_listing != nullptr);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -78,6 +78,18 @@ private:
|
||||||
int _current_indent = 0;
|
int _current_indent = 0;
|
||||||
ContentListing _root_listing;
|
ContentListing _root_listing;
|
||||||
ContentListing *_current_listing;
|
ContentListing *_current_listing;
|
||||||
|
|
||||||
|
void add_content(string type, string body, source_location location) {
|
||||||
|
_current_listing->add_content(type, body, location);
|
||||||
|
}
|
||||||
|
void push_content(string type, string body, source_location location) {
|
||||||
|
add_content(type, body, location);
|
||||||
|
_current_listing = _current_listing->content.back();
|
||||||
|
}
|
||||||
|
void pop_content() {
|
||||||
|
_current_listing = _current_listing->parent;
|
||||||
|
log_assert(_current_listing != nullptr);
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
PrettyHelp(Mode mode = LOG);
|
PrettyHelp(Mode mode = LOG);
|
||||||
~PrettyHelp();
|
~PrettyHelp();
|
||||||
|
|
Loading…
Reference in New Issue