@@ -28,6 +28,14 @@ use crate::util::{self, paths, validate_package_name, Config, IntoUrl};
2828mod targets;
2929use self :: targets:: targets;
3030
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.
3139pub fn read_manifest (
3240 path : & Path ,
3341 source_id : SourceId ,
@@ -121,6 +129,12 @@ fn do_read_manifest(
121129 }
122130}
123131
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.
124138pub fn parse ( toml : & str , file : & Path , config : & Config ) -> CargoResult < toml:: Value > {
125139 let first_error = match toml. parse ( ) {
126140 Ok ( ret) => return Ok ( ret) ,
@@ -176,7 +190,12 @@ type TomlBenchTarget = TomlTarget;
176190#[ derive( Clone , Debug , Serialize ) ]
177191#[ serde( untagged) ]
178192pub enum TomlDependency {
193+ /// In the simple format, only a version is specified, eg.
194+ /// `package = "<version>"`
179195 Simple ( String ) ,
196+ /// The simple format is equivalent to a detailed dependency
197+ /// specifying only a version, eg.
198+ /// `package = { version = "<version>" }`
180199 Detailed ( DetailedTomlDependency ) ,
181200}
182201
@@ -243,6 +262,7 @@ pub struct DetailedTomlDependency {
243262 public : Option < bool > ,
244263}
245264
265+ /// This type is used to deserialize `Cargo.toml` files.
246266#[ derive( Debug , Deserialize , Serialize ) ]
247267#[ serde( rename_all = "kebab-case" ) ]
248268pub struct TomlManifest {
@@ -847,6 +867,9 @@ struct Context<'a, 'b> {
847867}
848868
849869impl 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.
850873 pub fn prepare_for_publish (
851874 & self ,
852875 ws : & Workspace < ' _ > ,
@@ -1489,6 +1512,7 @@ impl TomlManifest {
14891512 Ok ( patch)
14901513 }
14911514
1515+ /// Returns the path to the build script if one exists for this crate.
14921516 fn maybe_custom_build (
14931517 & self ,
14941518 build : & Option < StringOrBool > ,
0 commit comments