Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/check/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn check(
warn_ignored_files(diags, file_path, excluded, ignored);
forbid_font_files(diags, file_path);
exclude_large_files(diags, file_path, excluded, metadata.len());
exclude_examples_and_tests(diags, file_path, excluded);
exclude_examples_and_tests(diags, manifest, file_path, excluded);
link_manuals(diags, readme, file_path, excluded);
}
}
Expand Down Expand Up @@ -167,8 +167,19 @@ fn exclude_large_files(
)
}

fn exclude_examples_and_tests(diags: &mut Diagnostics, path: PackagePath<&Path>, excluded: bool) {
if excluded {
fn exclude_examples_and_tests(
diags: &mut Diagnostics,
manifest: &Manifest,
path: PackagePath<&Path>,
excluded: bool,
) {
// Don't exclude template files, even if they contain "example" or "test" in their name.
let in_template_dir = || {
manifest
.template_path()
.is_some_and(|dir| path.full().starts_with(dir.full()))
};
if excluded || in_template_dir() {
return;
}

Expand Down
6 changes: 6 additions & 0 deletions src/check/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ pub struct Manifest {
pub template: Option<Spanned<Template>>,
}

impl Manifest {
pub fn template_path(&self) -> Option<&PackagePath> {
Some(&self.template.as_ref()?.path.as_ref()?.val)
}
}

#[derive(Debug, Clone)]
pub struct Package {
pub entrypoint: Spanned<PackagePath>,
Expand Down
1 change: 1 addition & 0 deletions tests/local/sixth/0.1.0/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
totally an MIT license
3 changes: 3 additions & 0 deletions tests/local/sixth/0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# sixth

:)
Empty file added tests/local/sixth/0.1.0/lib.typ
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions tests/local/sixth/0.1.0/typst.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "sixth"
version = "0.1.0"
description = "Useless package"
authors = ["Some Person"]
entrypoint = "lib.typ"
license = "MIT"

[template]
thumbnail = "missing.png"
path = "template"
entrypoint = "example.typ"
6 changes: 6 additions & 0 deletions tests/ref/local+sixth+0.1.0.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
error[manifest/template/thumbnail/not-found]: This file does not exist.
┌─ typst.toml:10:12
│
10 │ thumbnail = "missing.png"
│ ^^^^^^^^^^^^^

Loading