rrcpproxygen2roxygenrcpp11

Rcpp share same roxygen between two functions


Consider the following functions:

//' Provides some stuff AB
//' @param a integer that responsible for stuff A
//' @param b integer that responsible for stuff B
//' @export
// [[Rcpp::export]]
NumericVector foo1(int a, int b)
{
   //some code
}

//' Provides some stuff AC
//' @param a integer that responsible for stuff A
//' @param c integer that responsible for stuff C
//' @export
// [[Rcpp::export]]
NumericVector foo2(int a, int c)
{
   //some code
}

Note that parameter a description should be the same for foo1 and foo2. I have many functions where a parameter description should be provided in the same way. I don't whant to copy-past a parameter's description every time I need it for every function separately. Is it possible to specify a description ones and apply it to all functions my Rcpp package provides?

Will be very greatfull for help!


Solution

  • Thanks to Dirk Eddelbuettel I have found the answer:

    //' @name sharable
    //' @rdname sharable
    //' @param a integer that responsible for stuff A
    //' @export
    
    //' Provides some stuff AB
    //' @rdname sharable
    //' @param b integer that responsible for stuff B
    //' @export
    // [[Rcpp::export]]
    NumericVector foo1(int a, int b)
    {
       //some code
    }
    
    //' Provides some stuff AC
    //' @rdname sharable
    //' @param c integer that responsible for stuff C
    //' @export
    // [[Rcpp::export]]
    NumericVector foo2(int a, int c)
    {
       //some code
    }