refactor(toml): Rely on resolved documentation

This commit is contained in:
Ed Page 2024-03-19 13:50:33 -05:00
parent 5b5f64460b
commit c62a559d82
2 changed files with 16 additions and 8 deletions

View file

@ -214,6 +214,13 @@ impl TomlPackage {
pub fn resolved_homepage(&self) -> Result<Option<&String>, UnresolvedError> { pub fn resolved_homepage(&self) -> Result<Option<&String>, UnresolvedError> {
self.homepage.as_ref().map(|v| v.resolved()).transpose() self.homepage.as_ref().map(|v| v.resolved()).transpose()
} }
pub fn resolved_documentation(&self) -> Result<Option<&String>, UnresolvedError> {
self.documentation
.as_ref()
.map(|v| v.resolved())
.transpose()
}
} }
/// An enum that allows for inheriting keys from a workspace in a Cargo.toml. /// An enum that allows for inheriting keys from a workspace in a Cargo.toml.

View file

@ -574,6 +574,12 @@ pub fn to_real_manifest(
.map(|value| field_inherit_with(value, "homepage", || inherit()?.homepage())) .map(|value| field_inherit_with(value, "homepage", || inherit()?.homepage()))
.transpose()? .transpose()?
.map(manifest::InheritableField::Value); .map(manifest::InheritableField::Value);
package.documentation = package
.documentation
.clone()
.map(|value| field_inherit_with(value, "documentation", || inherit()?.documentation()))
.transpose()?
.map(manifest::InheritableField::Value);
let rust_version = package let rust_version = package
.resolved_rust_version() .resolved_rust_version()
@ -882,10 +888,9 @@ pub fn to_real_manifest(
.expect("previously resolved") .expect("previously resolved")
.cloned(), .cloned(),
documentation: package documentation: package
.documentation .resolved_documentation()
.clone() .expect("previously resolved")
.map(|mw| field_inherit_with(mw, "documentation", || inherit()?.documentation())) .cloned(),
.transpose()?,
readme: readme_for_package( readme: readme_for_package(
package_root, package_root,
package package
@ -937,10 +942,6 @@ pub fn to_real_manifest(
links: package.links.clone(), links: package.links.clone(),
rust_version: rust_version.clone(), rust_version: rust_version.clone(),
}; };
package.documentation = metadata
.documentation
.clone()
.map(|documentation| manifest::InheritableField::Value(documentation));
package.readme = metadata package.readme = metadata
.readme .readme
.clone() .clone()