mirror of
https://github.com/NixOS/nix
synced 2025-07-07 01:51:47 +02:00
Generate builtins section of the manual
This commit is contained in:
parent
a990f063ff
commit
0f314f3c25
5 changed files with 36 additions and 3 deletions
|
@ -179,11 +179,29 @@ void mainWrapped(int argc, char * * argv)
|
|||
|
||||
NixArgs args;
|
||||
|
||||
if (argc == 2 && std::string(argv[1]) == "dump-args") {
|
||||
if (argc == 2 && std::string(argv[1]) == "__dump-args") {
|
||||
std::cout << args.toJSON().dump() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
if (argc == 2 && std::string(argv[1]) == "__dump-builtins") {
|
||||
EvalState state({}, openStore("ssh://foo.invalid/"));
|
||||
auto res = nlohmann::json::object();
|
||||
auto builtins = state.baseEnv.values[0]->attrs;
|
||||
for (auto & builtin : *builtins) {
|
||||
auto b = nlohmann::json::object();
|
||||
if (builtin.value->type != tPrimOp) continue;
|
||||
auto primOp = builtin.value->primOp;
|
||||
if (!primOp->doc) continue;
|
||||
b["arity"] = primOp->arity;
|
||||
b["args"] = primOp->args;
|
||||
b["doc"] = trim(stripIndentation(primOp->doc));
|
||||
res[(std::string) builtin.name] = std::move(b);
|
||||
}
|
||||
std::cout << res.dump() << "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
Finally printCompletions([&]()
|
||||
{
|
||||
if (completions) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue