Skip to content

Commit

Permalink
Check that roxygen2 generates Rd files and NAMESPACE
Browse files Browse the repository at this point in the history
Requested in #2
  • Loading branch information
ThierryO committed Jul 9, 2020
1 parent 565e815 commit b146c0d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

export(check_cran)
export(check_description)
export(check_documentation)
export(check_lintr)
export(check_package)
export(checklist)
Expand Down
21 changes: 21 additions & 0 deletions R/check_documentation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#' Check the documentation
#' @inheritParams read_checklist
#' @export
check_documentation <- function(x = ".") {
if (!inherits(x, "Checklist") || !"checklist" %in% x$get_checked) {
x <- read_checklist(x = x)
}
rd_files <- c(
file.path(x$get_path, "NAMESPACE"),
list.files(
file.path(x$get_path, "man"), pattern = "Rd$", full.names = TRUE
)
)
start <- vapply(rd_files, readLines, character(1), n = 1)
ok <- grepl("roxygen2", start) & grepl("do not edit by hand", start)
doc_error <- sprintf(
"Documentation in %s not generated by `roxygen2`", rd_files[!ok]
)
x$add_error(doc_error, "documentation")
return(x)
}
3 changes: 3 additions & 0 deletions R/check_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ check_package <- function(x = ".", fail = !interactive()) {
cat("Checking description\n")
x <- check_description(x)

cat("Checking documentation\n")
x <- check_documentation(x)

print(x)
if (!x$fail) {
cat("\nNo problems found. Good job!\n\n")
Expand Down
4 changes: 3 additions & 1 deletion R/checklist_class.R
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ checklist <- R6Class(
},
#' @field fail A logical indicating if all checks passed.
fail = function() {
required_checks <- c("checklist", "DESCRIPTION", "lintr", "R CMD check")
required_checks <- c(
"checklist", "DESCRIPTION", "lintr", "R CMD check", "documentation"
)
stopifnot(all(private$checked %in% required_checks))
errors <- vapply(private$errors, length, integer(1))
any(!required_checks %in% private$checked) ||
Expand Down
15 changes: 15 additions & 0 deletions man/check_documentation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b146c0d

Please sign in to comment.