Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Rcpp functions with default arguments that appear in their header files #1265

Closed
zhuxr11 opened this issue May 9, 2023 · 3 comments

Comments

@zhuxr11
Copy link

zhuxr11 commented 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:

# 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?

@zhuxr11 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
@Enchufa2
Copy link
Member

Enchufa2 commented May 9, 2023

Sorry, but we can't help with that. This is a question for roxygen2, which is the package that handles such doc comments.

@eddelbuettel
Copy link
Member

Agreed, and suggest we close this here. Rcpp plays the hand it was dealt. I sometimes write

//' @param x A single integer with default value of zero.

but that is of course manual.

@eddelbuettel
Copy link
Member

Closing for inactivity, and, as stated, more-or-less being at the wrong repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants