Skip to content

Commit 776e629

Browse files
committed
document struct fields on themselves
1 parent 84c6d8c commit 776e629

File tree

2 files changed

+22
-27
lines changed

2 files changed

+22
-27
lines changed

src/json.rs

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,48 +44,44 @@ const DATA_SIZE: usize = 1;
4444
/// }
4545
/// }
4646
/// ]
47-
///}
48-
///```
49-
///
50-
/// ## Fields
51-
///
52-
/// - `data`: The top level crate information and documentation
53-
/// - `included`: The rest of the crate information and documentation
47+
/// }
48+
/// ```
5449
#[derive(Serialize, Debug)]
5550
pub struct Documentation {
51+
/// The top level crate information and documentation
5652
data: Option<Document>,
53+
54+
/// The rest of the crate information and documentation
5755
included: Option<Vec<Document>>,
5856
}
5957

6058
/// A sub type of the `Documentation` struct. It contains the majority of the data. It can be used
6159
/// for both the `data` and `included` field in the serialized JSON.
62-
///
63-
/// ## Fields
64-
///
65-
/// - `ty`: The type of the the item (e.g. "crate", "function", "enum", etc.)
66-
/// - `id`: The unique identifier associated with this item
67-
/// - `attributes`: The attributes associated with the item like documentation or it's name
68-
/// - `relationships`: An optional field used to show the relationship between the crate to the
69-
/// otheritems in the crate
7060
#[derive(Serialize, Debug)]
7161
pub struct Document {
7262
#[serde(rename = "type")]
63+
/// The type of the item (e.g. "crate", "function", "enum", etc.)
7364
ty: String,
65+
66+
/// The unique identifier associated with this item
7467
id: String,
68+
69+
/// The attributes associated with the item, like documentation or its name
7570
attributes: HashMap<String, String>,
71+
72+
/// An optional field used to show the relationship between the crate to the other items in the
73+
/// crate
7674
relationships: Option<HashMap<String, HashMap<String, Vec<Data>>>>,
7775
}
7876

7977
/// Used to populate the `relationships` `data` field in the serialized JSON
80-
///
81-
/// ## Fields
82-
///
83-
/// - `ty`: The type of the the item (e.g. "crate", "function", "enum", etc.)
84-
/// - `id`: The unique identifier associated with this item
8578
#[derive(Serialize, Debug)]
8679
pub struct Data {
8780
#[serde(rename = "type")]
81+
/// The type of the item (e.g. "crate", "function", "enum", etc.)
8882
ty: String,
83+
84+
/// The unique identifier associated with this item
8985
id: String,
9086
}
9187

src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,15 @@ use json::*;
3636
pub use error::{Error, ErrorKind};
3737

3838
/// A structure that contains various fields that hold data in order to generate doc output.
39-
///
40-
/// ## Fields
41-
///
42-
/// - `manifest_path`: Path to the directory with the `Cargo.toml` file for the crate being analyzed
43-
/// - `host`: Contains the Cargo analysis output for the crate being documented
44-
/// - `assets`: Contains all of the `Asset`s that will be output at the end (e.g. JSON, CSS, HTML
45-
/// and/or JS)
4639
pub struct Config {
40+
/// Path to the directory with the `Cargo.toml` file for the crate being analyzed
4741
manifest_path: PathBuf,
42+
43+
/// Contains the Cargo analysis output for the crate being documented
4844
host: analysis::AnalysisHost,
45+
46+
/// Contains all of the `Asset`s that will be output at the end (e.g. JSON, CSS, HTML and/or
47+
/// JS)
4948
assets: Vec<Asset>,
5049
}
5150

0 commit comments

Comments
 (0)