feat(tvix/eval): Add docstrings as documentation for builtins

Add a new `documentation: Option<&'static str>` field to Builtin, and
populate it in the `#[builtins]` macro with the docstring of the builtin
function, if any.

Change-Id: Ic68fdf9b314d15a780731974234e2ae43f6a44b0
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7205
Tested-by: BuildkiteCI
Reviewed-by: tazjin <tazjin@tvl.su>
This commit is contained in:
Griffin Smith 2022-11-06 10:46:56 -05:00 committed by grfn
parent a1015ba1d7
commit 76d7671c8a
5 changed files with 54 additions and 2 deletions

View file

@ -918,6 +918,7 @@ fn placeholders() -> Vec<Builtin> {
name: "value",
},
],
None,
|mut args: Vec<Value>, vm: &mut VM| {
vm.emit_warning(WarningKind::NotImplemented("builtins.addErrorContext"));
Ok(args.pop().unwrap())
@ -929,6 +930,7 @@ fn placeholders() -> Vec<Builtin> {
strict: true,
name: "s",
}],
None,
|mut args: Vec<Value>, vm: &mut VM| {
vm.emit_warning(WarningKind::NotImplemented(
"builtins.unsafeDiscardStringContext",
@ -942,6 +944,7 @@ fn placeholders() -> Vec<Builtin> {
strict: true,
name: "attrs",
}],
None,
|args: Vec<Value>, vm: &mut VM| {
vm.emit_warning(WarningKind::NotImplemented("builtins.derivation"));