Skip to content

Commit

Permalink
check_documentation() yields a more informational error message when …
Browse files Browse the repository at this point in the history
…devtools::document() changed files

relevant for #67
  • Loading branch information
ThierryO committed Sep 21, 2021
1 parent 7811b84 commit ef53c5a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 10 additions & 1 deletion R/check_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ tidy_desc <- function(x = ".") {

unchanged_repo <- function(repo, old_status) {
current_status <- status(repo)
identical(
ok <- identical(
current_status$staged,
old_status$staged
) &&
Expand All @@ -186,6 +186,15 @@ unchanged_repo <- function(repo, old_status) {
current_status$untracked,
old_status$untracked
)
new_files <- unlist(current_status)
old_files <- unlist(old_status)
changes <- c(
new_files[!new_files %in% old_files], old_files[!old_files %in% new_files]
)
attr(ok, "files") <- sprintf(
"changed files:\n%s", paste(changes, collapse = "\n")
)
return(ok)
}

#' Check the license of a package
Expand Down
10 changes: 7 additions & 3 deletions R/check_documentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,15 @@ check_documentation <- function(x = ".") {
repo <- repository(x$get_path)
status_before <- status(repo)
document(x$get_path)
detect_changes <- unchanged_repo(repo, status_before)
si <- session_info(pkgs = "roxygen2")
doc_error <- c(
doc_error,
"Missing documentation. Run `devtools::document()`"[
!unchanged_repo(repo, status_before)
]
sprintf(
"Running `devtools::document()` with roxygen2 %s %s",
si$packages$loadedversion[si$packages$package == "roxygen2"],
attr(detect_changes, "files")
)[!detect_changes]
)

if (file_test("-f", file.path(x$get_path, "README.Rmd"))) {
Expand Down

0 comments on commit ef53c5a

Please sign in to comment.