908cebf35c
Having a multi-line docstring yields multiple doc-attributes in order, however we were previously discarding all but the first one. This reduces them into a single string instead, which can then be displayed as multi-line documentation. Change-Id: I1f237956cdea2e4c746d3f13744e0373c1c645a6 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7594 Reviewed-by: grfn <grfn@gws.fyi> Autosubmit: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
38 lines
850 B
Rust
38 lines
850 B
Rust
pub use tvix_eval::internal;
|
|
pub use tvix_eval::Value;
|
|
use tvix_eval_builtin_macros::builtins;
|
|
|
|
#[builtins]
|
|
mod builtins {
|
|
use tvix_eval::internal::VM;
|
|
use tvix_eval::{ErrorKind, Value};
|
|
|
|
/// Test docstring.
|
|
///
|
|
/// It has multiple lines!
|
|
#[builtin("identity")]
|
|
pub fn builtin_identity(_vm: &mut VM, x: Value) -> Result<Value, ErrorKind> {
|
|
Ok(x)
|
|
}
|
|
|
|
#[builtin("tryEval")]
|
|
pub fn builtin_try_eval(_: &mut VM, #[lazy] _x: Value) -> Result<Value, ErrorKind> {
|
|
todo!()
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn builtins() {
|
|
let builtins = builtins::builtins();
|
|
assert_eq!(builtins.len(), 2);
|
|
|
|
let identity = builtins.iter().find(|b| b.name() == "identity").unwrap();
|
|
assert_eq!(
|
|
identity.documentation(),
|
|
Some(
|
|
r#" Test docstring.
|
|
|
|
It has multiple lines!"#
|
|
)
|
|
);
|
|
}
|