R/check-uses-roxygen2.R

#' Check whether all documntation has been generated by 'roxygen2'
#'
#' Use of 'roxygen2' to generate package documnetation is mandatory for rOpenSci
#' packages, and is described in detail in [our *Packaging
#' Guide*](https://devguide.ropensci.org/pkg_building.html#roxygen-2-use).
#'
#' @param checks A 'pkgcheck' object with full \pkg{pkgstats} summary and
#' \pkg{goodpractice} results.
#' @return 'TRUE' if all files generated by 'roxygen2', otherwise 'FALSE'
#' @noRd
pkgchk_uses_roxygen2 <- function (checks) {

    rd <- list.files (
        fs::path (checks$pkg$path, "man"),
        pattern = "\\.Rd$",
        full.names = TRUE
    )

    chk <- vapply (rd, function (i) {
        l1 <- readLines (i, n = 1L, encoding = "UTF-8")
        grepl ("Generated by roxygen2", l1, ignore.case = TRUE)
    },
    logical (1),
    USE.NAMES = FALSE
    )

    return (all (chk))
}

output_pkgchk_uses_roxygen2 <- function (checks) {

    out <- list (
        check_pass = checks$checks$uses_roxygen2,
        summary = "",
        print = ""
    ) # no print method

    out$summary <- ifelse (out$check_pass,
        "uses 'roxygen2'.",
        "does not use 'roxygen2'."
    )

    return (out)
}
ropensci-review-tools/pkgcheck documentation built on Nov. 24, 2024, 7:57 p.m.