Closed nfultz closed 7 years ago
It would be. I haven't particularly solved the issue of how to do that. I think the SOS package provides good insight into how to accomplish the task but I haven't had the time to actually implement that yet.
Specificially... this https://github.com/cran/sos/blob/master/R/findFn2.R
I wouldn't want to break the current ?
by adding my own version in.
I've implemented this in commit https://github.com/Dasonk/docstring/commit/8d6a71bd14a80b9405e80867021dc46f6f69cf1a
This seems to be working well enough for the time being. Right now ?
will only work if the function is defined in the global environment. If a function with docstring is stored in a different environment then you'll need to use docstring
directly instead of relying on ?
to access the docstring help. I don't see this as a major set-back.
square <-function(x){
#' Square a number
#'
#' Calculates the square of the input
#'
#' @param x the input to be squared
#' @export
return(x^2)
}
e <- new.env()
e$test <- square
?e$test # won't work and can't find a way to make `?` work here
docstring(e$test) # also won't work but can fix it by...
docstring(e$test, "test") # works
@nfultz Does this fulfill the use case you were asking for?
If a user-defined function is carrying around a docstring, it would be nice if
?f
showed it.