diff --git a/R/package.R b/R/package.R index 821144c8c..17c67bd40 100644 --- a/R/package.R +++ b/R/package.R @@ -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 { @@ -191,7 +192,7 @@ read_meta <- function(path, call = caller_env()) { # (<>) Parser 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) @@ -205,6 +206,7 @@ read_meta <- function(path, call = caller_env()) { ) }) } + yaml } diff --git a/tests/testthat/_snaps/package.md b/tests/testthat/_snaps/package.md index 7482d9d7a..4f782273f 100644 --- a/tests/testthat/_snaps/package.md +++ b/tests/testthat/_snaps/package.md @@ -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. diff --git a/tests/testthat/assets/bad-yaml/DESCRIPTION b/tests/testthat/assets/bad-yaml/DESCRIPTION index 3da3a37bf..2329d143b 100644 --- a/tests/testthat/assets/bad-yaml/DESCRIPTION +++ b/tests/testthat/assets/bad-yaml/DESCRIPTION @@ -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", , "hadley@rstudio.com", role = c("aut", "cre")), - person("RStudio", role = c("cph", "fnd")) - ) -RoxygenNote: 6.0.1 -Suggests: - knitr, - rmarkdown +Authors@R: person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), VignetteBuilder: knitr diff --git a/tests/testthat/assets/bad-yaml/_pkgdown.yml b/tests/testthat/assets/bad-yaml/_pkgdown.yml index 159087c1d..01904824d 100644 --- a/tests/testthat/assets/bad-yaml/_pkgdown.yml +++ b/tests/testthat/assets/bad-yaml/_pkgdown.yml @@ -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: >- - Posit