11

So I'm trying to use roxygen2 to document my code. Unfortunately my supervisor felt it was cluttered having so many functions in the global environment. So I've been told to hide them away in sub environments. This seems to be stopping roxygen detecting them correctly. Minimal example below.

my_env <- new.env()

#' test
#' 
#' more test
#' 
#' @return none
my_env$my_func <- function(){}
environment(my_env$my_func) <- my_env

I'm using the Document() command in devtools to build the documentation. However I just keep getting the error "Warning: min_examp.R:8: Missing name". Given I don't think I'm going to be allowed to put the functions back the way they were before hiding them does anyone have any suggestions about how to get roxygen to detect my functions?

Peter Clark
  • 161
  • 1
  • 5

3 Answers3

6

roxygen2 can't find the name of your function.

Provide a name to your function like so

#' @name name_of_your_function
stevec
  • 41,291
  • 27
  • 223
  • 311
3

I was finally able to fix this by doing the following

my_env <- new.env()

#' my title
#' 
#' @name my_env$my_func
#' 
#' @usage my_env$my_func()
#' 
#' more test
#' 
#' @return none
my_env$my_func <- function(){}
environment(my_env$my_func) <- my_env
Peter Clark
  • 161
  • 1
  • 5
-1

I was able to fix the issue by testing if all functions in the R folder can be run without error. Any buggy functions related to your "min_examp.R" are likely to generate the MISSING NAME error.

yzhang
  • 1
  • 1