From murdoch.duncan at gmail.com  Sat Aug 25 22:28:40 2012
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Sat, 25 Aug 2012 16:28:40 -0400
Subject: [Rd] how to keep the documents of private functions private
In-Reply-To: <8CE91B9EC5614EEC8917892689AD94C0@science.oregonstate.edu>
References: <8CE91B9EC5614EEC8917892689AD94C0@science.oregonstate.edu>
Message-ID: <50393578.8090400@gmail.com>

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
>



[Rd] how to keep the documents of private functions private
Duncan Murdoch