Search code examples
rpackagedocumentationroxygen2

Skip parameters from package documentation without warning


I have created an R package and have set a generic with a few parameters having default values set to NULL. These parameters are not to be provided by the user and so I'd like to skip them from the documentation (using roxygen2) but not result in getting warnings in R CMD check.

An example:

#' Do that with myFoo...
#' 
#' `myFoo` ...
#' 
#' `myFoo` description...
#' 
#' @param object An object of myBar class
#' @param a A numeric value...
#' 
#' @return Smth
#' 
#' @name myFoo
#' @export
#' 
methods::setGeneric("myFoo", function(object, a, b=NULL, c=NULL) standard("myFoo"))


# User level
methods::setMethod(f="myFoo",
    signature=signature(object="myBar", a="numeric"),
    function(object, a, b, c){

            Some checks...

            b <- smth
            c <- smth

            return(myFoo(object@myBarItem, a, b, c))
    }
)


# For "iternal" use
methods::setMethod(f="myFoo",
    signature=signature(object="myBar2", a="numeric", b="character", c="matrix"),
    function(object, a, b, c){

            Smth

            return(someValue)
    }
)

Solution

  • The addition of @rdname and @aliases have solved the issue, as it seems.

    #' Do that with myFoo...
    #' 
    #' `myFoo` ...
    #' 
    #' `myFoo` description...
    #' 
    #' @param object An object of myBar class
    #' @param a A numeric value...
    #' 
    #' @return Smth
    #'
    #' @name myFoo
    #' @rdname myFoo
    #' @export
    #'
    #' @aliases myFoo,myBar,numeric,ANY,ANY-method
    #' myFoo,myBar2,numeric,character,matrix-method
    #' 
    #' @importFrom methods setGeneric setMethod
    #'
    methods::setGeneric("myFoo", function(object, a, b=NULL, c=NULL) standard("myFoo"))
    
    
    # User level
    methods::setMethod(f="myFoo",
        signature=signature(object="myBar", a="numeric"),
        function(object, a, b, c){
    
                Some checks...
    
                b <- smth
                c <- smth
    
                return(myFoo(object@myBarItem, a, b, c))
        }
    )
    
    
    # For "iternal" use
    methods::setMethod(f="myFoo",
        signature=signature(object="myBar2", a="numeric", b="character", c="matrix"),
        function(object, a, b, c){
    
                Smth
    
                return(someValue)
        }
    )