Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
url: https://epiforecasts.io/scoringutils/
template:
math-rendering: katex
bootstrap: 5
bslib:
font_weight_base : 300
Expand Down
41 changes: 41 additions & 0 deletions tests/testthat/test-pkgdown-config.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
test_that("_pkgdown.yml has math-rendering configured", {
config_path <- testthat::test_path("..", "..", "_pkgdown.yml")
skip_if_not(file.exists(config_path), "_pkgdown.yml not found")

lines <- readLines(config_path, warn = FALSE)

has_math_rendering <- any(grepl("^\\s*math-rendering:\\s*(katex|mathjax)\\s*$", lines))
expect_true(
has_math_rendering,
info = "math-rendering must be set to 'katex' or 'mathjax' under template: in _pkgdown.yml"
)
})

test_that("R documentation files with LaTeX formulas exist and are parseable", {
latex_files <- c(
"R/metrics-binary.R",

Check warning on line 16 in tests/testthat/test-pkgdown-config.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-pkgdown-config.R,line=16,col=6,[nonportable_path_linter] Use file.path() to construct portable file paths.
"R/metrics-interval-range.R",

Check warning on line 17 in tests/testthat/test-pkgdown-config.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-pkgdown-config.R,line=17,col=6,[nonportable_path_linter] Use file.path() to construct portable file paths.
"R/metrics-sample.R",

Check warning on line 18 in tests/testthat/test-pkgdown-config.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-pkgdown-config.R,line=18,col=6,[nonportable_path_linter] Use file.path() to construct portable file paths.
"R/metrics-quantile.R"

Check warning on line 19 in tests/testthat/test-pkgdown-config.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-pkgdown-config.R,line=19,col=6,[nonportable_path_linter] Use file.path() to construct portable file paths.
)
pkg_root <- testthat::test_path("..", "..")

# Skip if source files aren't available (e.g., during R CMD check)
skip_if_not(
file.exists(file.path(pkg_root, latex_files[1])),
"Source R/ files not found (likely running in R CMD check)"

Check warning on line 26 in tests/testthat/test-pkgdown-config.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-pkgdown-config.R,line=26,col=6,[nonportable_path_linter] Use file.path() to construct portable file paths.
)

for (file in latex_files) {
full_path <- file.path(pkg_root, file)
expect_true(
file.exists(full_path),
info = paste(file, "should exist")
)
lines <- readLines(full_path, warn = FALSE)
expect_true(
any(grepl("\\\\(eqn|deqn)\\{", lines)),
info = paste(file, "should contain \\eqn{} or \\deqn{} LaTeX formulas")

Check warning on line 38 in tests/testthat/test-pkgdown-config.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=tests/testthat/test-pkgdown-config.R,line=38,col=27,[nonportable_path_linter] Use file.path() to construct portable file paths.
)
}
})
Loading