Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide the documentation of helper functions?

Tags:

r

I'm maintaining a package that has a number of helper functions documented with .rd files. As they are not exported, they are not easily accessible by users - this is good. However, they still show up in the index of package help files.

Is there a way to have documentation removed from the index so that it does not clutter it, but still accessible via help?

like image 853
sebastian-c Avatar asked Sep 08 '15 12:09

sebastian-c


2 Answers

There's a field in the Rd file you can add called keywords. Most keywords don't do anything except help you search for functions with one notable exception: internal. Marking a function with the internal keyword removes it from the index. According to the roxygen2 vignette:

@keywords keyword1 keyword2 ... to add standardised keywords. Keywords are optional, but if present, must be taken from the predefined list replicated in the keywords vignette. Keywords are not very useful, except for @keywords internal. Using the internal keyword removes all functions in the associated .Rd file from the documentation index and disables some of their automated tests. A common use case is to both export a function (using @export) and marking it as internal. That way, advanced users can access a function that new users would be confused about if they were to see it in the index.

Adding @keywords internal to the roxygen comments will give the desired result.

like image 148
sebastian-c Avatar answered Nov 16 '22 01:11

sebastian-c


A little bump for people experiencing @keywords internal not working;

I made the mistake of mixing up ??PACKAGENAME and help(package="PACKAGENAME"). Because of this I was left confused why I still saw the documentation of the internals. ?? loads ALL documentation of your package and is not neccesarily the user help index.

Very basic mistake, but there ya go.

like image 33
Berghopper Avatar answered Nov 16 '22 01:11

Berghopper