1use crate::{
2 configuration,
3 safety::{PropertiesAndReason, Property},
4};
5use indexmap::IndexMap;
6use serde::Serialize;
7
8#[derive(Serialize)]
9pub struct Ouput {
10 pub v_fn: IndexMap<String, Vec<OutputProperties>>,
11 pub spec: IndexMap<Box<str>, configuration::Key>,
12}
13
14#[derive(Serialize)]
15pub struct OutputProperties {
16 pub tags: Vec<OutputProperty>,
17 pub desc: Option<Box<str>>,
18 pub doc: Box<str>,
19}
20
21impl OutputProperties {
22 pub fn new(sp: PropertiesAndReason) -> Self {
23 let doc = sp.gen_hover_doc();
24 let tags = sp.tags.into_vec().into_iter().map(OutputProperty::new).collect();
25 OutputProperties { tags, desc: sp.desc, doc }
26 }
27}
28
29#[derive(Serialize)]
30pub struct OutputProperty {
31 pub sp: Property,
32 pub doc: Box<str>,
33}
34
35impl OutputProperty {
36 pub fn new(sp: Property) -> Self {
37 OutputProperty { doc: sp.gen_doc().unwrap_or_default().into(), sp }
38 }
39}