Skip to content

Commit

Permalink
export dotify; update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Sep 4, 2024
1 parent f5705c0 commit 56c8a4f
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 8 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Package: dotty
Type: Package
Title: The Unpacking Dot Operator
Version: 0.1.0.9000
Authors@R: c(
Authors@R:
c(
person(
"Kevin", "Ushey",
email = "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ S3method(format,dotty)
S3method(print,dotty)
export(.)
export(destructure)
export(dotify)
importFrom(utils,globalVariables)
importFrom(utils,head)
importFrom(utils,tail)
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

# dotty 0.2.0 (UNRELEASED)

- `dotty::dotify()` is now exported for use by R packages which would
like to use `dotty` internally. (#1)


# dotty 0.1.0

Expand Down
7 changes: 4 additions & 3 deletions R/destructure.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@

#' Destructure an Object
#'
#'
#' `destructure` is primarily used to help define how an
#' object should be prepared, or transformed, prior to a
#' destructuring assignment. This can be relevant for
#' objects which have unique subsetting semantics -- for
#' example, [numeric_version] objects.
#'
#'
#' Packages which would like to define special destructring
#' semantics for certain object classes can implement
#' methods for this class.
#'
#'
#' @param object An \R object.
#' @export
destructure <- function(object) {
UseMethod("destructure")
Expand Down
25 changes: 21 additions & 4 deletions R/dotify.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@

`%||%` <- function(x, y) {
if (is.null(x)) y else x
}

#' Dotify an R Package
#'
#' When using `dotty` within an R package, you might see **NOTE**s during
#' `R CMD check` of the form:
#'
#' ```
#' N checking R code for possible problems (1.8s)
#' <package>: no visible binding for global variable <variable>
#' Undefined global functions or variables:
#' <variable>
#' ```
#'
#' This occurs because the [codetools] package, which is used for static
#' analysis of \R code during `R CMD check`, does not recognize that e.g.
#' `.[apple] <- 42` would create a variable called `apple` in the current
#' scope. Calling `dotty::dotify()` in your package's `.onLoad()` will
#' allow `dotty` to patch `codetools` in a way that will allow it to
#' understand `dotty` usages, and so prevent these `R CMD check` notes
#' from being emitted.
#'
#' @export
dotify <- function() {

# allow us to be disabled if necessary
Expand Down
4 changes: 4 additions & 0 deletions R/utils.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

`%||%` <- function(x, y) {
if (is.null(x)) y else x
}
3 changes: 3 additions & 0 deletions man/destructure.Rd

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

28 changes: 28 additions & 0 deletions man/dotify.Rd

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

0 comments on commit 56c8a4f

Please sign in to comment.