Attribute for defining examples (#23)
This commit is contained in:
parent
19b9bef395
commit
e259955809
4 changed files with 88 additions and 3 deletions
|
@ -16,7 +16,7 @@ pub struct Attrs {
|
|||
pub title: Option<String>,
|
||||
pub description: Option<String>,
|
||||
pub deprecated: bool,
|
||||
// TODO pub example: Option<syn::Path>,
|
||||
pub examples: Vec<syn::Path>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
@ -111,6 +111,12 @@ impl Attrs {
|
|||
}
|
||||
}
|
||||
|
||||
Meta(NameValue(m)) if m.path.is_ident("example") => {
|
||||
if let Ok(fun) = parse_lit_into_path(errors, attr_type, "example", &m.lit) {
|
||||
self.examples.push(fun)
|
||||
}
|
||||
}
|
||||
|
||||
Meta(_meta_item) => {
|
||||
// TODO uncomment this for 0.8.0 (breaking change)
|
||||
// https://github.com/GREsau/schemars/issues/18
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue