Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions R/document.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#' }
#' @param cran_check Run CRAN compliance checks (DESCRIPTION quoting,
#' web service links, code issues, missing examples). Default TRUE.
#' @param silent Operate less verbose without messages. Default FALSE.
#' @return Invisibly returns a list with:
#' - rd_files: character vector of generated Rd file paths
#' - namespace: path to NAMESPACE file (or NULL if mode="none")
Expand Down Expand Up @@ -41,7 +42,7 @@
#' }
document <- function(path = ".",
namespace = c("overwrite", "append", "none"),
cran_check = TRUE) {
cran_check = TRUE, silent = FALSE) {
namespace <- match.arg(namespace)

# Validate path
Expand All @@ -56,30 +57,32 @@ document <- function(path = ".",
}

# Parse all R files
message("Parsing R files...")
if (!silent) message("Parsing R files...")
blocks <- parse_package(path)

if (length(blocks) == 0) {
message("No documentation blocks found.")
if (!silent) message("No documentation blocks found.")
return(invisible(list(rd_files = character(), namespace = NULL)))
}

message("Found ", length(blocks), " documentation block(s).")
if (!silent) message("Found ", length(blocks), " documentation block(s).")

# Generate Rd files
message("Generating Rd files...")
rd_files <- generate_all_rd(blocks, path)
message("Generated ", length(rd_files), " Rd file(s).")
if (!silent) message("Generating Rd files...")
rd_files <- generate_all_rd(blocks, path, silent)
if (!silent) message("Generated ", length(rd_files), " Rd file(s).")

# Generate NAMESPACE
ns_file <- NULL
if (namespace != "none") {
message("Generating NAMESPACE...")
if (!silent) message("Generating NAMESPACE...")
ns_content <- generate_namespace(blocks)
ns_file <- write_namespace(ns_content, path, namespace)
message("Updated NAMESPACE.")
if (!silent) message("Updated NAMESPACE.")
}

if (!silent) message("Leaving DESCRIPTION alone as one should.")

invisible(list(rd_files = rd_files, namespace = ns_file))
}

Expand Down
7 changes: 4 additions & 3 deletions R/rd.R
Original file line number Diff line number Diff line change
Expand Up @@ -669,9 +669,10 @@ generate_rd_grouped <- function(topic, entries, all_tags,
#'
#' @param blocks List of documentation blocks from parse_package().
#' @param path Package root path.
#' @param silent Boolean flag whether operation whould be silent
#' @return Character vector of generated file paths.
#' @keywords internal
generate_all_rd <- function(blocks, path = ".") {
generate_all_rd <- function(blocks, path = ".", silent = FALSE) {
generated <- character()

# Find package-defined S3 generics for proper \method{}{} usage formatting
Expand Down Expand Up @@ -776,7 +777,7 @@ generate_all_rd <- function(blocks, path = ".") {
formal_names <- block$formals$names
undoc <- setdiff(formal_names, names(tags$params))
undoc <- setdiff(undoc, "...")
if (length(undoc) > 0) {
if (length(undoc) > 0 && !silent) {
warning("Undocumented parameters in ", tags$name, ": ",
paste(undoc, collapse = ", "),
call. = FALSE)
Expand All @@ -795,7 +796,7 @@ generate_all_rd <- function(blocks, path = ".") {
formal_names <- entry$block$formals$names
undoc <- setdiff(formal_names, names(entry$tags$params))
undoc <- setdiff(undoc, "...")
if (length(undoc) > 0) {
if (length(undoc) > 0 && !silent) {
warning("Undocumented parameters in ", entry$tags$name, ": ",
paste(undoc, collapse = ", "),
call. = FALSE)
Expand Down
4 changes: 3 additions & 1 deletion man/document.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
\title{Generate Documentation for an R Package}
\usage{
document(path = ".", namespace = c("overwrite", "append", "none"),
cran_check = TRUE)
cran_check = TRUE, silent = FALSE)
}
\arguments{
\item{path}{Path to package root directory. Default is current directory.}
Expand All @@ -18,6 +18,8 @@ document(path = ".", namespace = c("overwrite", "append", "none"),

\item{cran_check}{Run CRAN compliance checks (DESCRIPTION quoting,
web service links, code issues, missing examples). Default TRUE.}

\item{silent}{Operate less verbose without messages. Default FALSE.}
}
\value{
Invisibly returns a list with:
Expand Down
4 changes: 3 additions & 1 deletion man/generate_all_rd.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
\alias{generate_all_rd}
\title{Generate All Rd Files for a Package}
\usage{
generate_all_rd(blocks, path = ".")
generate_all_rd(blocks, path = ".", silent = FALSE)
}
\arguments{
\item{blocks}{List of documentation blocks from parse_package().}

\item{path}{Package root path.}

\item{silent}{Boolean flag whether operation whould be silent}
}
\value{
Character vector of generated file paths.
Expand Down