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> {
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.

View File

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