0

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?

user697473
  • 2,165
  • 1
  • 20
  • 47
  • 1
    Have you read the vignette "Extending roxygen2"? It looks like you could define a "roclet" to do what you want. – user2554330 Dec 17 '19 at 16:18
  • Thank you, @user2554330. I did read the "Extending roxygen2" vignette at your suggestion; I also prowled through the roxygen2 repo. It looks as though creating a new roclet would work, but the process seemed too involved to me. There is a simpler solution for my limited case of changing the package CSS -- I've just posted that solution. – user697473 Dec 26 '19 at 14:24

1 Answers1

0

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.

user697473
  • 2,165
  • 1
  • 20
  • 47