in starlark/src/values/docs.rs [662:753]
fn globals_docs_work() {
let mut globals_builder = GlobalsBuilder::new();
static RES: GlobalsStatic = GlobalsStatic::new();
RES.populate(add_some_global_value, &mut globals_builder);
let globals = globals_builder.build();
let docs = globals.documentation();
let string_typ = Some(Type {
raw_type: "String".to_owned(),
});
let expected_object = super::Object {
docs: DocString::from_docstring(
DocStringKind::Rust,
"These are where the module docs go\n\nThis is what is passed to users for an object, so be careful\nnot to register two modules for a single object.",
),
members: vec![
(
"func1".to_owned(),
super::Member::Function(super::Function {
docs: DocString::from_docstring(DocStringKind::Rust, "Docs for func1"),
params: vec![Param::Arg {
name: "foo".to_owned(),
docs: DocString::from_docstring(DocStringKind::Rust, "Docs for foo"),
typ: string_typ.clone(),
default_value: None,
}],
ret: Return {
docs: DocString::from_docstring(
DocStringKind::Rust,
"The string 'func1'",
),
typ: string_typ.clone(),
},
}),
),
(
"func2".to_owned(),
super::Member::Function(super::Function {
docs: None,
params: vec![],
ret: Return {
docs: None,
typ: string_typ.clone(),
},
}),
),
(
"func3".to_owned(),
super::Member::Function(super::Function {
docs: DocString::from_docstring(
DocStringKind::Rust,
"A function with only positional arguments.",
),
params: vec![
Param::Arg {
name: "a1".to_owned(),
docs: None,
typ: Some(Type {
raw_type: "i32".to_owned(),
}),
default_value: None,
},
Param::Arg {
name: "a2".to_owned(),
docs: None,
typ: Some(Type {
raw_type: "Option < i32 >".to_owned(),
}),
default_value: Some("None".to_owned()),
},
Param::Arg {
name: "step".to_owned(),
docs: None,
typ: Some(Type {
raw_type: "i32".to_owned(),
}),
// TODO: This should actually show '1'...
default_value: Some("None".to_owned()),
},
],
ret: Return {
docs: None,
typ: string_typ,
},
}),
),
],
};
let expected = DocItem::Object(expected_object);
assert_eq!(expected, docs);
}