Skip to content

Commit

Permalink
fix(leanify): disable leanification during roxygenise (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebffischer authored Nov 29, 2023
1 parent 344f837 commit 796285b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Config/testthat/parallel: true
Encoding: UTF-8
NeedsCompilation: yes
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.2.3.9000
Collate:
'Dictionary.R'
'named_list.R'
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# mlr3misc 0.12.0-9000
# mlr3misc 0.13.0

* Bugfix: disable leanification when `ROXYGEN_PKG` environment variable is set

# mlr3misc 0.13.0

* Updated default environment for `crate()` to `topenv()` (#86).
* Added safe methods for dictionary retrieval (#83)
Expand Down
14 changes: 14 additions & 0 deletions R/leanify.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
#'
#' leanificate_method is called by [leanify_r6] for each function of an [R6] class.
#'
#' Leanification also removes the `"srcref"` attribute of functions (sets it to `NULL`), because
#' 1) it is incorrect and
#' 2) srcrefs can lead to exploding object sizes.
#'
#' However, because `roxgyen2` needs the srcrefs to create the documentation for R6 classes, leanification
#' is skipped during `roxygenize()`, i.e. when the `ROXYGEN_PKG` environment variable is set.
#'
#' @param cls (`R6ClassGenerator`)\cr
#' R6Class object (i.e. R6 object generator) to modify.
#' @param name (`character(1)`)\cr
Expand Down Expand Up @@ -99,6 +106,13 @@ leanify_package = function(pkg_env = parent.frame(), skip_if = function(x) FALSE
assert_environment(pkg_env)
assert_function(skip_if)

# otherwise creation of R6 docs fails
pkg = Sys.getenv("ROXYGEN_PKG")
if (nzchar(pkg)) {
messagef("Skipping leanification of package '%s' during roxygenize.", pkg)
return(NULL)
}

for (varname in names(pkg_env)) {
content = get(varname, envir = pkg_env, inherits = FALSE)
if (R6::is.R6Class(content) && !isTRUE(skip_if(content))) {
Expand Down
4 changes: 2 additions & 2 deletions man/crate.Rd

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

0 comments on commit 796285b

Please sign in to comment.