You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using roxygen 2 (//') to document Rcpp functions. As a common practice, functions shared across multiple files are defined in header file with default arguments (reference here). However, roxygen2 comments live in .cpp files (not the header files), where default parameters are not defined (and cannot be defined there even with the same default values, since this is not allowed in C++). In the end, the help page does not show any default parameters. I am wondering how this could be improved.
Example:
In test.h:
# ifndef TEST_CPP
# def TEST_CPP
#include <Rcpp.h>
using namespace Rcpp;
int timesTwo(int x = 0);
#endif
In test.cpp:
//' Multiply a number by two
//'
//' @param x A single integer.
//' @export
// [[Rcpp::export]]
int timesTwo(int x) {
return x * 2;
}
How could I get the help page show timesTwo(x = 0) in the usage section with roxygen2 comments?
The text was updated successfully, but these errors were encountered:
zhuxr11
changed the title
Document Rcpp functions with default arguments that appear in its header file
Document Rcpp functions with default arguments that appear in their header files
May 9, 2023
I am using roxygen 2 (
//'
) to document Rcpp functions. As a common practice, functions shared across multiple files are defined in header file with default arguments (reference here). However, roxygen2 comments live in.cpp
files (not the header files), where default parameters are not defined (and cannot be defined there even with the same default values, since this is not allowed in C++). In the end, the help page does not show any default parameters. I am wondering how this could be improved.Example:
In
test.h
:In
test.cpp
:How could I get the help page show
timesTwo(x = 0)
in the usage section with roxygen2 comments?The text was updated successfully, but these errors were encountered: