@@ -36,16 +36,15 @@ use json::*;
36
36
pub use error:: { Error , ErrorKind } ;
37
37
38
38
/// 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)
46
39
pub struct Config {
40
+ /// Path to the directory with the `Cargo.toml` file for the crate being analyzed
47
41
manifest_path : PathBuf ,
42
+
43
+ /// Contains the Cargo analysis output for the crate being documented
48
44
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)
49
48
assets : Vec < Asset > ,
50
49
}
51
50
@@ -55,7 +54,7 @@ impl Config {
55
54
///
56
55
/// ## Arguments
57
56
///
58
- /// - manifest_path: The path to the location of `Cargo.toml` of the crate being documented
57
+ /// - ` manifest_path` : The path to the location of `Cargo.toml` of the crate being documented
59
58
pub fn new ( manifest_path : PathBuf , assets : Vec < Asset > ) -> Result < Config > {
60
59
let host = analysis:: AnalysisHost :: new ( analysis:: Target :: Debug ) ;
61
60
@@ -72,8 +71,8 @@ impl Config {
72
71
///
73
72
/// ## Arguments
74
73
///
75
- /// - config: The `Config` struct that contains the data needed to generate the documentation
76
- /// - artifacts: A slice containing what assets should be output at the end
74
+ /// - ` config` : The `Config` struct that contains the data needed to generate the documentation
75
+ /// - ` artifacts` : A slice containing what assets should be output at the end
77
76
pub fn build ( config : & Config , artifacts : & [ & str ] ) -> Result < ( ) > {
78
77
generate_and_load_analysis ( config) ?;
79
78
@@ -122,8 +121,8 @@ pub fn build(config: &Config, artifacts: &[&str]) -> Result<()> {
122
121
///
123
122
/// ## Arguments:
124
123
///
125
- /// - config: Contains data for what needs to be output or used. In this case the path to the
126
- /// `Cargo.toml` file
124
+ /// - ` config` : Contains data for what needs to be output or used. In this case the path to the
125
+ /// `Cargo.toml` file
127
126
fn generate_and_load_analysis ( config : & Config ) -> Result < ( ) > {
128
127
let manifest_path = & config. manifest_path ;
129
128
@@ -147,11 +146,11 @@ fn generate_and_load_analysis(config: &Config) -> Result<()> {
147
146
Ok ( ( ) )
148
147
}
149
148
150
- /// This creates the JSON documentation from the given AnalysisHost.
149
+ /// This creates the JSON documentation from the given ` AnalysisHost` .
151
150
pub fn create_json ( host : & AnalysisHost , crate_name : & str ) -> Result < String > {
152
151
let roots = host. def_roots ( ) ?;
153
152
154
- let id = roots. iter ( ) . find ( |& & ( _, ref name) | name == & crate_name) ;
153
+ let id = roots. iter ( ) . find ( |& & ( _, ref name) | name == crate_name) ;
155
154
let root_id = match id {
156
155
Some ( & ( id, _) ) => id,
157
156
_ => return Err ( ErrorKind :: CrateErr ( crate_name. to_string ( ) ) . into ( ) ) ,
@@ -168,7 +167,7 @@ pub fn create_json(host: &AnalysisHost, crate_name: &str) -> Result<String> {
168
167
169
168
let child_defs: Vec < analysis:: Def > = ids. into_par_iter ( )
170
169
. map ( |id : analysis:: Id | recur ( & id, host) )
171
- . reduce ( || Vec :: new ( ) , |mut a : Vec < analysis:: Def > ,
170
+ . reduce ( Vec :: default , |mut a : Vec < analysis:: Def > ,
172
171
b : Vec < analysis:: Def > | {
173
172
a. extend ( b) ;
174
173
a
@@ -209,7 +208,7 @@ pub fn create_json(host: &AnalysisHost, crate_name: &str) -> Result<String> {
209
208
. attributes ( String :: from ( "docs" ) , root_def. docs ) ;
210
209
211
210
// Insert all of the different types of relationships into this `Document` type only
212
- for ( ty, data) in relationships. into_iter ( ) {
211
+ for ( ty, data) in relationships {
213
212
data_document. relationships ( ty, data) ;
214
213
}
215
214
0 commit comments