Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix idempotency of roxygenize() for packages using multi-line @rawNamespace #1573

Merged
merged 10 commits into from
Jan 22, 2024
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
MichaelChirico committed Jan 14, 2024
commit cadbcf25ce79a90e37e1e92c72d1c9793ccc59a9
2 changes: 1 addition & 1 deletion R/namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ update_namespace_imports <- function(base_path) {

# Here we hand roll parsing and tokenisation from roxygen2 primitives so
# we can filter tags that we know don't require package code.
namespace_imports <- function(base_path = ".") {
namespace_imports <- function(base_path = ".") {
paths <- package_files(base_path)
parsed <- lapply(paths, parse, keep.source = TRUE)
srcrefs <- lapply(parsed, utils::getSrcref)
Expand Down
8 changes: 7 additions & 1 deletion tests/testthat/test-namespace.R
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,13 @@ test_that("can extract non-imports from namespace preserving source", {
"export(b)"
)
path <- withr::local_tempfile(lines = lines)
expect_equal(namespace_exports(path), lines[c(1:3, 5)])
expect_equal(
namespace_exports(path),
c(
paste(lines[1:3], collapse = "\n"),
lines[5L]
)
)
})

test_that("Invalid imports throw a helpful error", {
Expand Down