mirror of
https://github.com/YosysHQ/yosys
synced 2026-06-08 01:50:57 +00:00
log_help: Don't reformat codeblocks
This commit is contained in:
parent
ef3b2b0380
commit
aaebce7adc
1 changed files with 23 additions and 19 deletions
|
|
@ -78,7 +78,7 @@ ContentListing* ContentListing::open_option(const string &text,
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MAX_LINE_LEN 80
|
#define MAX_LINE_LEN 80
|
||||||
void log_pass_str(const std::string &pass_str, std::string indent_str, bool leading_newline=false) {
|
void log_body_str(const std::string &pass_str, std::string indent_str, bool leading_newline=false, bool is_formatted=false) {
|
||||||
if (pass_str.empty())
|
if (pass_str.empty())
|
||||||
return;
|
return;
|
||||||
std::istringstream iss(pass_str);
|
std::istringstream iss(pass_str);
|
||||||
|
|
@ -86,26 +86,30 @@ void log_pass_str(const std::string &pass_str, std::string indent_str, bool lead
|
||||||
log("\n");
|
log("\n");
|
||||||
for (std::string line; std::getline(iss, line);) {
|
for (std::string line; std::getline(iss, line);) {
|
||||||
log("%s", indent_str);
|
log("%s", indent_str);
|
||||||
auto curr_len = indent_str.length();
|
if (is_formatted) {
|
||||||
std::istringstream lss(line);
|
log("%s", line);
|
||||||
for (std::string word; std::getline(lss, word, ' ');) {
|
} else {
|
||||||
while (word[0] == '`' && word.back() == '`')
|
auto curr_len = indent_str.length();
|
||||||
word = word.substr(1, word.length()-2);
|
std::istringstream lss(line);
|
||||||
if (curr_len + word.length() >= MAX_LINE_LEN-1) {
|
for (std::string word; std::getline(lss, word, ' ');) {
|
||||||
curr_len = 0;
|
while (word[0] == '`' && word.back() == '`')
|
||||||
log("\n%s", indent_str);
|
word = word.substr(1, word.length()-2);
|
||||||
}
|
if (curr_len + word.length() >= MAX_LINE_LEN-1) {
|
||||||
if (word.length()) {
|
curr_len = 0;
|
||||||
log("%s ", word);
|
log("\n%s", indent_str);
|
||||||
curr_len += word.length() + 1;
|
}
|
||||||
|
if (word.length()) {
|
||||||
|
log("%s ", word);
|
||||||
|
curr_len += word.length() + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void log_pass_str(const std::string &pass_str, int indent=0, bool leading_newline=false) {
|
void log_body(const ContentListing &content, int indent=0, bool leading_newline=false) {
|
||||||
std::string indent_str(indent*4, ' ');
|
std::string indent_str(indent*4, ' ');
|
||||||
log_pass_str(pass_str, indent_str, leading_newline);
|
log_body_str(content.body, indent_str, leading_newline, content.type.compare("code") == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
PrettyHelp *current_help = nullptr;
|
PrettyHelp *current_help = nullptr;
|
||||||
|
|
@ -134,16 +138,16 @@ void PrettyHelp::log_help() const
|
||||||
{
|
{
|
||||||
for (auto &content : _root_listing) {
|
for (auto &content : _root_listing) {
|
||||||
if (content.type.compare("usage") == 0) {
|
if (content.type.compare("usage") == 0) {
|
||||||
log_pass_str(content.body, 1, true);
|
log_body(content, 1, true);
|
||||||
log("\n");
|
log("\n");
|
||||||
} else if (content.type.compare("option") == 0) {
|
} else if (content.type.compare("option") == 0) {
|
||||||
log_pass_str(content.body, 1);
|
log_body(content, 1);
|
||||||
for (auto text : content) {
|
for (auto text : content) {
|
||||||
log_pass_str(text.body, 2);
|
log_body(text, 2);
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log_pass_str(content.body, 0);
|
log_body(content, 0);
|
||||||
log("\n");
|
log("\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue