Skip to content

Commit

Permalink
Simplify test files and revert ws change
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy committed May 19, 2024
1 parent 4661e5b commit ae00cad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
4 changes: 3 additions & 1 deletion R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ pkgdown_config_path <- function(path) {

read_meta <- function(path, call = caller_env()) {
path <- pkgdown_config_path(path)

if (is.null(path)) {
yaml <- list()
} else {
Expand All @@ -191,7 +192,7 @@ read_meta <- function(path, call = caller_env()) {
# (<<path>>) Parser error: <<parsing error>>
yaml_err <- conditionMessage(e)
# extract parsing error from original error (i.e. remove the path)
parsing_error <- sub("[^\\)]+\\)\\s", "", yaml_err)
parsing_error <- sub("[^\\)]+\\)\\s?", "", yaml_err)
# Extract path from original error
path_yaml <- regmatches(yaml_err, m = regexpr("\\(([^\\)]+)\\)", yaml_err))
path_yaml <- gsub("\\(([^\\)]+)\\)", "\\1", path_yaml)
Expand All @@ -205,6 +206,7 @@ read_meta <- function(path, call = caller_env()) {
)
})
}

yaml
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/package.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
Condition
Error in `as_pkgdown()`:
x Could not parse the config file.
! Parser error: while parsing a block mapping at line 1, column 1 did not find expected key at line 9, column 3
! Scanner error: mapping values are not allowed in this context at line 2, column 8
i Edit 'assets/bad-yaml/_pkgdown.yml' to fix the problem.

12 changes: 1 addition & 11 deletions tests/testthat/assets/bad-yaml/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
Package: kittens
Version: 1.0.0
Title: A test package
Description: A longer statement about the package.
Authors@R: c(
person("Hadley", "Wickham", , "[email protected]", role = c("aut", "cre")),
person("RStudio", role = c("cph", "fnd"))
)
RoxygenNote: 6.0.1
Suggests:
knitr,
rmarkdown
Authors@R: person("Hadley", "Wickham", , "[email protected]", role = c("aut", "cre")),
VignetteBuilder: knitr
10 changes: 0 additions & 10 deletions tests/testthat/assets/bad-yaml/_pkgdown.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
url: https://pkgdown.r-lib.org

home:
title: Build websites for R packages

authors:
Jay Hesselberth:
href: https://hesselberthlab.org
Maëlle Salmon:
href: https://masalmon.eu
Hadley Wickham:
href: http://hadley.nz
Posit Software, PBC:
href: https://www.posit.co
html: >-
<img src='https://www.tidyverse.org/posit-logo.svg' alt='Posit' width='62' height='16' style="margin-bottom: 3px;" />

0 comments on commit ae00cad

Please sign in to comment.