Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

roxygen2 - Create private helper functions in R packages

I'm currently co-developing an open source package on github, with the eventual goal of pushing to CRAN. We have written a number of functions, all documented with roxygen2 and all with the @export tag, so that they are populated in the NAMESPACE.

For example a function would be pkgname::foo(), and a helper function called by foo would be pkgname::foo_helper(). The pkgname::foo_helper() is purely internal i.e. its only purpose is to help with some computation in pkgname::foo(), and is not the focus of our package, but pkgname::foo() is.

In this example we would like to convert the pkgname::foo_helper() functions to "private", as defined by the following criteria:

  1. The pkgname::foo_helper() should by default not appear in the pkgdown>References section, only pkgname::foo() should appear
  2. The pkgname::foo_helper() function should be fully visible on github i.e. not hidden
  3. The pkgname::foo_helper() functions should be accessible to the R user by running pkgname::foo_helper(), if they want to play with it in R directly.

What is the best way to make pkgname::foo_helper() "private" in the above sense.

Also, if we wanted to hide pkgname::foo_helper() in R (so user is not distracted by this helper), what would we change to make them private in this sense?

I assumed that adding a "." at the start of the function name achieves this, but felt there would be more to it. I was concerned about the implications of removing the @export tag in roxygen, especially if other internal package functions relied on these helper functions.

Any help on this is appreciated.

Note: this question is cross-posted here, but has not received any responses after many views, hence posting here for more visibility.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...