1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 13:41:15 +02:00

Allow 'nix' subcommands to provide docs in Markdown format

This commit is contained in:
Eelco Dolstra 2020-08-20 12:21:46 +02:00
parent 3c4f8c9175
commit dc2f278c95
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
8 changed files with 68 additions and 40 deletions

View file

@ -359,12 +359,14 @@ nlohmann::json Command::toJSON()
for (auto & example : examples()) {
auto ex = nlohmann::json::object();
ex["description"] = example.description;
ex["command"] = example.command;
ex["command"] = chomp(stripIndentation(example.command));
exs.push_back(std::move(ex));
}
auto res = Args::toJSON();
res["examples"] = std::move(exs);
auto s = doc();
if (s != "") res.emplace("doc", stripIndentation(s));
return res;
}