1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00

Trim option descriptions

This removes unintended blank lines in Markdown when the description
is a multiline string literal.
This commit is contained in:
Eelco Dolstra 2022-09-13 16:58:32 +02:00
parent b56906aae0
commit d365cced4f
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
2 changed files with 4 additions and 4 deletions

View file

@ -216,7 +216,7 @@ nlohmann::json Args::toJSON()
if (flag->shortName) if (flag->shortName)
j["shortName"] = std::string(1, flag->shortName); j["shortName"] = std::string(1, flag->shortName);
if (flag->description != "") if (flag->description != "")
j["description"] = flag->description; j["description"] = trim(flag->description);
j["category"] = flag->category; j["category"] = flag->category;
if (flag->handler.arity != ArityAny) if (flag->handler.arity != ArityAny)
j["arity"] = flag->handler.arity; j["arity"] = flag->handler.arity;
@ -237,7 +237,7 @@ nlohmann::json Args::toJSON()
} }
auto res = nlohmann::json::object(); auto res = nlohmann::json::object();
res["description"] = description(); res["description"] = trim(description());
res["flags"] = std::move(flags); res["flags"] = std::move(flags);
res["args"] = std::move(args); res["args"] = std::move(args);
auto s = doc(); auto s = doc();
@ -379,7 +379,7 @@ nlohmann::json MultiCommand::toJSON()
auto j = command->toJSON(); auto j = command->toJSON();
auto cat = nlohmann::json::object(); auto cat = nlohmann::json::object();
cat["id"] = command->category(); cat["id"] = command->category();
cat["description"] = categories[command->category()]; cat["description"] = trim(categories[command->category()]);
j["category"] = std::move(cat); j["category"] = std::move(cat);
cmds[name] = std::move(j); cmds[name] = std::move(j);
} }

View file

@ -325,7 +325,7 @@ void mainWrapped(int argc, char * * argv)
std::cout << "attrs\n"; break; std::cout << "attrs\n"; break;
} }
for (auto & s : *completions) for (auto & s : *completions)
std::cout << s.completion << "\t" << s.description << "\n"; std::cout << s.completion << "\t" << trim(s.description) << "\n";
} }
}); });