Struct doku::json::AutoComments [−][src]
Expand description
Determines which auto-comments - hints, so to say - should get displayed.
Sometimes Doku is able to automatically infer certain properties about a type and provide a dedicated hint such as “this field is optional”. This struct allows to configure whether you’d like for such comments to be printed or not.
Fields
array_size: boolWhen set, displays hints for arrays of known sizes:
use doku::Document;
#[derive(Document)]
struct Person {
friends: [String; 3],
}
let fmt = doku::json::Formatting {
auto_comments: doku::json::AutoComments {
array_size: true,
..Default::default()
},
..Default::default()
};
let doc = doku::to_json_fmt::<Person>(&fmt);
doku::assert_doc!(r#"
{
// Must contain exactly 3 elements
"friends": [
"string",
/* ... */
]
}
"#, doc);optional: boolWhen set, displays hints for optional values:
use doku::Document;
#[derive(Document)]
struct Person {
friend: Option<String>,
}
let fmt = doku::json::Formatting {
auto_comments: doku::json::AutoComments {
optional: true,
..Default::default()
},
..Default::default()
};
let doc = doku::to_json_fmt::<Person>(&fmt);
doku::assert_doc!(r#"
{
// Optional
"friend": "string"
}
"#, doc);Implementations
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for AutoComments
impl Send for AutoComments
impl Sync for AutoComments
impl Unpin for AutoComments
impl UnwindSafe for AutoComments
Blanket Implementations
Mutably borrows from an owned value. Read more