doku/printers/json/formatting/doc_comments.rs
1use crate::*;
2
3/// Determines if doc-comments should get displayed.
4#[derive(Clone, Debug, Serialize, Deserialize)]
5#[serde(deny_unknown_fields)]
6pub enum DocComments {
7 /// Shows doc-comments:
8 ///
9 /// ```
10 /// use doku::Document;
11 ///
12 /// #[derive(Document)]
13 /// struct Person {
14 /// /// First name
15 /// /// (aka forename)
16 /// name: String,
17 /// }
18 ///
19 /// let fmt = doku::json::Formatting {
20 /// doc_comments: doku::json::DocComments::Visible,
21 /// ..Default::default()
22 /// };
23 ///
24 /// let doc = doku::to_json_fmt::<Person>(&fmt);
25 ///
26 /// doku::assert_doc!(r#"
27 /// {
28 /// // First name
29 /// // (aka forename)
30 /// "name": "string"
31 /// }
32 /// "#, doc);
33 /// ```
34 ///
35 /// Please note that doc-comments are only the ones starting with _three_
36 /// slashes.
37 Visible,
38
39 /// Hides doc-comments:
40 ///
41 /// ```
42 /// use doku::Document;
43 ///
44 /// #[derive(Document)]
45 /// struct Person {
46 /// /// First name
47 /// /// (aka forename)
48 /// name: String,
49 /// }
50 ///
51 /// let fmt = doku::json::Formatting {
52 /// doc_comments: doku::json::DocComments::Hidden,
53 /// ..Default::default()
54 /// };
55 ///
56 /// let doc = doku::to_json_fmt::<Person>(&fmt);
57 ///
58 /// doku::assert_doc!(r#"
59 /// {
60 /// "name": "string"
61 /// }
62 /// "#, doc);
63 /// ```
64 Hidden,
65}
66
67impl Default for DocComments {
68 fn default() -> Self {
69 Self::Visible
70 }
71}