mirror of
https://github.com/typst/typst
synced 2025-07-27 14:27:56 +08:00
Merge c9cf6bab92e5d08f4f42dc9ce2da579bf0fbe7e2 into 78355421ad73fdcbe93b4acca890b439c4b6f98d
This commit is contained in:
commit
fa41e1e07d
@ -143,6 +143,16 @@ pub struct PackageInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PackageManifest {
|
impl PackageManifest {
|
||||||
|
/// Create a new package manifest with the given package info.
|
||||||
|
pub fn new(package: PackageInfo) -> Self {
|
||||||
|
PackageManifest {
|
||||||
|
package,
|
||||||
|
template: None,
|
||||||
|
tool: ToolInfo::default(),
|
||||||
|
unknown_fields: UnknownFields::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Ensure that this manifest is indeed for the specified package.
|
/// Ensure that this manifest is indeed for the specified package.
|
||||||
pub fn validate(&self, spec: &PackageSpec) -> Result<(), EcoString> {
|
pub fn validate(&self, spec: &PackageSpec) -> Result<(), EcoString> {
|
||||||
if self.package.name != spec.name {
|
if self.package.name != spec.name {
|
||||||
@ -173,6 +183,44 @@ impl PackageManifest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TemplateInfo {
|
||||||
|
/// Create a new template info with only required fields.
|
||||||
|
pub fn new(path: impl Into<EcoString>, entrypoint: impl Into<EcoString>) -> Self {
|
||||||
|
TemplateInfo {
|
||||||
|
path: path.into(),
|
||||||
|
entrypoint: entrypoint.into(),
|
||||||
|
thumbnail: None,
|
||||||
|
unknown_fields: UnknownFields::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PackageInfo {
|
||||||
|
/// Create a new package info with only required fields.
|
||||||
|
pub fn new(
|
||||||
|
name: impl Into<EcoString>,
|
||||||
|
version: PackageVersion,
|
||||||
|
entrypoint: impl Into<EcoString>,
|
||||||
|
) -> Self {
|
||||||
|
PackageInfo {
|
||||||
|
name: name.into(),
|
||||||
|
version,
|
||||||
|
entrypoint: entrypoint.into(),
|
||||||
|
authors: vec![],
|
||||||
|
categories: vec![],
|
||||||
|
compiler: None,
|
||||||
|
description: None,
|
||||||
|
disciplines: vec![],
|
||||||
|
exclude: vec![],
|
||||||
|
homepage: None,
|
||||||
|
keywords: vec![],
|
||||||
|
license: None,
|
||||||
|
repository: None,
|
||||||
|
unknown_fields: BTreeMap::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Identifies a package.
|
/// Identifies a package.
|
||||||
#[derive(Clone, Eq, PartialEq, Hash)]
|
#[derive(Clone, Eq, PartialEq, Hash)]
|
||||||
pub struct PackageSpec {
|
pub struct PackageSpec {
|
||||||
@ -535,22 +583,11 @@ mod tests {
|
|||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
Ok(PackageManifest {
|
Ok(PackageManifest {
|
||||||
package: PackageInfo {
|
package: PackageInfo::new(
|
||||||
name: "package".into(),
|
"package",
|
||||||
version: PackageVersion { major: 0, minor: 1, patch: 0 },
|
PackageVersion { major: 0, minor: 1, patch: 0 },
|
||||||
entrypoint: "src/lib.typ".into(),
|
"src/lib.typ"
|
||||||
authors: vec![],
|
),
|
||||||
license: None,
|
|
||||||
description: None,
|
|
||||||
homepage: None,
|
|
||||||
repository: None,
|
|
||||||
keywords: vec![],
|
|
||||||
categories: vec![],
|
|
||||||
disciplines: vec![],
|
|
||||||
compiler: None,
|
|
||||||
exclude: vec![],
|
|
||||||
unknown_fields: BTreeMap::new(),
|
|
||||||
},
|
|
||||||
template: None,
|
template: None,
|
||||||
tool: ToolInfo { sections: BTreeMap::new() },
|
tool: ToolInfo { sections: BTreeMap::new() },
|
||||||
unknown_fields: BTreeMap::new(),
|
unknown_fields: BTreeMap::new(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user