add collapse example

This commit is contained in:
Darren Schroeder 2024-06-19 19:37:26 -05:00
parent 3417306e57
commit f2c2e9d24d
2 changed files with 27 additions and 11 deletions

View File

@ -187,7 +187,10 @@ impl Command for Table {
}),
Value::test_record(record! {
"a" => Value::test_int(3),
"b" => Value::test_int(4),
"b" => Value::test_list(vec![
Value::test_int(4),
Value::test_int(4),
])
}),
])),
},

View File

@ -296,15 +296,28 @@ fn get_documentation(
}
if let Some(result) = &example.result {
let mut table_expand_call = Call::new(Span::unknown());
table_expand_call.add_named((
Spanned {
item: "expand".to_string(),
span: Span::unknown(),
},
None,
None,
));
let mut table_call = Call::new(Span::unknown());
if *&example.example.ends_with("--collapse") {
// collapse the result
table_call.add_named((
Spanned {
item: "collapse".to_string(),
span: Span::unknown(),
},
None,
None,
))
} else {
// expand the result
table_call.add_named((
Spanned {
item: "expand".to_string(),
span: Span::unknown(),
},
None,
None,
))
}
let table = engine_state
.find_decl("table".as_bytes(), &[])
.and_then(|decl_id| {
@ -313,7 +326,7 @@ fn get_documentation(
.run(
engine_state,
stack,
&table_expand_call,
&table_call,
PipelineData::Value(result.clone(), None),
)
.ok()