Skip to content

Commit 4043ada

Browse files
committed
Check for messages from roxygen2, rather than warnings
1 parent 1bf87ac commit 4043ada

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

inst/hooks/exported/parsable-roxygen.R

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,23 @@
22
files <- commandArgs(trailing = TRUE)
33

44
out <- lapply(files, function(path) {
5+
56
tryCatch(
6-
roxygen2::parse_file(path, env = NULL),
7-
warning = function(w) {
8-
cat(c("Roxygen commentary in file ", path, " is not parsable. Full context:\n"))
9-
stop(conditionMessage(w), call. = FALSE)
10-
},
7+
# Capture any messages from roxygen2:::warn_roxy()
8+
msg <- capture.output(
9+
roxygen2::parse_file(path, env = NULL),
10+
type = "message"
11+
),
12+
13+
# In case we encounter a more general file parsing problem
1114
error = function(e) {
1215
cat(c("File ", path, " is not parsable. Full context:\n"))
1316
stop(conditionMessage(e), call. = FALSE)
1417
}
1518
)
19+
20+
if (length(msg) > 0) {
21+
cat(c("Roxygen commentary in file ", path, " is not parsable. Full context:\n"))
22+
stop(paste0(msg, collapse = "\n"), call. = FALSE)
23+
}
1624
})

0 commit comments

Comments
 (0)