Skip to content

Commit

Permalink
document global_roclet
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonynorth committed Aug 21, 2023
1 parent 7767090 commit 5d69edc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 2 deletions.
27 changes: 26 additions & 1 deletion R/global_roclet.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
#' Roclet: global
#'
#' @description
#' This roclet automates [utils::globalVariables()] declaration from @global
#' and @autoglobal roxygen tags.
#'
#' Package authors will not typically need to invoke [global_roclet()] directly.
#' Global roclet instances are created by `roxygen2` during [roxygen2::roxygenise()]
#' (or [devtools::document()]).
#'
#' @importFrom roxygen2 roclet
#' @return A [roxygen2::roclet()] instance for declaring [utils::globalVariables()]
#' during [roxygen2::roxygenise()]
#' @export
global_roclet <- function() roxygen2::roclet("global")
#'
#' @examples
#' #' @autoglobal
#' foo <- function(x) {
#' # bar isn't declared -> add to utils::globalVariables()
#' subset(x, bar == 4)
#' }
#'
#' #' @global bar
#' foo <- function(x) {
#' # bar is explicitly defined as a global -> add to utils::globalVariables()
#' subset(x, bar == 4)
#' }
global_roclet <- function() {
roxygen2::roclet("global")
}

#' @importFrom roxygen2 roclet_process
#' @export
Expand Down
24 changes: 23 additions & 1 deletion man/global_roclet.Rd

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

0 comments on commit 5d69edc

Please sign in to comment.