@@ -28,6 +28,14 @@ use crate::util::{self, paths, validate_package_name, Config, IntoUrl};
28
28
mod targets;
29
29
use self :: targets:: targets;
30
30
31
+ /// Loads a `Cargo.toml` from a file on disk.
32
+ ///
33
+ /// This could result in a real or virtual manifest being returned.
34
+ ///
35
+ /// A list of nested paths is also returned, one for each path dependency
36
+ /// within the manfiest. For virtual manifests, these paths can only
37
+ /// come from patched or replaced dependencies. These paths are not
38
+ /// canonicalized.
31
39
pub fn read_manifest (
32
40
path : & Path ,
33
41
source_id : SourceId ,
@@ -121,6 +129,12 @@ fn do_read_manifest(
121
129
}
122
130
}
123
131
132
+ /// Attempts to parse a string into a [`toml::Value`]. This is not specific to any
133
+ /// particular kind of TOML file.
134
+ ///
135
+ /// The purpose of this wrapper is to detect invalid TOML which was previously
136
+ /// accepted and display a warning to the user in that case. The `file` and `config`
137
+ /// parameters are only used by this fallback path.
124
138
pub fn parse ( toml : & str , file : & Path , config : & Config ) -> CargoResult < toml:: Value > {
125
139
let first_error = match toml. parse ( ) {
126
140
Ok ( ret) => return Ok ( ret) ,
@@ -176,7 +190,12 @@ type TomlBenchTarget = TomlTarget;
176
190
#[ derive( Clone , Debug , Serialize ) ]
177
191
#[ serde( untagged) ]
178
192
pub enum TomlDependency {
193
+ /// In the simple format, only a version is specified, eg.
194
+ /// `package = "<version>"`
179
195
Simple ( String ) ,
196
+ /// The simple format is equivalent to a detailed dependency
197
+ /// specifying only a version, eg.
198
+ /// `package = { version = "<version>" }`
180
199
Detailed ( DetailedTomlDependency ) ,
181
200
}
182
201
@@ -243,6 +262,7 @@ pub struct DetailedTomlDependency {
243
262
public : Option < bool > ,
244
263
}
245
264
265
+ /// This type is used to deserialize `Cargo.toml` files.
246
266
#[ derive( Debug , Deserialize , Serialize ) ]
247
267
#[ serde( rename_all = "kebab-case" ) ]
248
268
pub struct TomlManifest {
@@ -847,6 +867,9 @@ struct Context<'a, 'b> {
847
867
}
848
868
849
869
impl TomlManifest {
870
+ /// Prepares the manfiest for publishing.
871
+ // - Path and git components of dependency specifications are removed.
872
+ // - License path is updated to point within the package.
850
873
pub fn prepare_for_publish (
851
874
& self ,
852
875
ws : & Workspace < ' _ > ,
@@ -1489,6 +1512,7 @@ impl TomlManifest {
1489
1512
Ok ( patch)
1490
1513
}
1491
1514
1515
+ /// Returns the path to the build script if one exists for this crate.
1492
1516
fn maybe_custom_build (
1493
1517
& self ,
1494
1518
build : & Option < StringOrBool > ,
0 commit comments