[Rd] how to keep the documents of private functions private
Duncan Murdoch
murdoch.duncan at gmail.com
Sat Aug 25 22:28:40 CEST 2012
On 12-08-24 11:56 AM, Yanming Di wrote:
> First time posting on this forum.
>
> The short version of the question is how to keep the documents of private (unexported) functions private. It seems that the documents of the private functions will be compiled into the user manual even if the corresponding functions are not exported. Is there a solution to this? I want to have documents for these functions for my own use, but I don’t want to release them to distract end users.
You can't easily do that. Some base packages have a topic like
?"grid-internal" where internal documentation is collected, but it is
visible to users.
> To provide some background, a more general question is how to manage unexported (private) functions in an R package. I need to call them during the developing phase or even after the package is released (e.g., for debugging purpose or they may be needed by new functions), but I don’t want to export them (I’d like to keep the number of exported (public) functions to a minimum and present the users with only the functions that they need to know.)
>
> I know I can call private functions by packagename:::fcn(), but that seems a little bit tedious.
You could also attach the environment of an exported function (e.g.
attach(environment(grid::unit)), to put the whole internal environment
on the search list. But I usually use the ::: notation.
Duncan Murdoch
>
> A solution I came up with is to prepare two NAMESPACE files and switch between them. When releasing the codes, use the thin version; when developing the package, use the version that export all functions. That works except if I have documents (Rd files) for the private functions, they will be compiled to the user manual even if the corresponding functions are not exported. Is there a solution around this? (I think I can keep two separate man folders and switch between them, but that seems a little bit tedious).
>
> Thanks.
>
> Yanming
>
>
>
> [[alternative HTML version deleted]]
>
>
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list