Automatically call macro or insert template in every .Rd file

104 Views Asked by At

I am using roxygen to document an R package. I have a macro file, myMacro.Rd, in the "man/macros" subdirectory of the package. The file specifies the \myMacro macro. (The macro inserts a <style> tag into HTML help files to alter the standard CSS in R help files.)

I want to automatically call \myMacro in every .Rd file of the package. That is, I don't want to manually add \myMacro (or anything else) to all of my roxygen code. Instead, I want the addition to be made automatically. Is there a way to do this?

I could achieve the same effect by automatically inserting a Roxygen template into every .Rd file. Is there a way to do that instead?

1

There are 1 best solutions below

0
On

I haven't found a general way to automatically insert a macro call into every .Rd file. But to adjust the CSS for every HTML help page in a package, one need only add a custom R.css file to the /inst/html directory in one's source package. (There is a related post at How to add CSS external files to be used by my R package function?.)

Note: adding a file to /inst/html will lead to a warning when you build your R package.