简体   繁体   中英

How to build API documentation for an R package in RStudio?

I'm working on a very recent Windows 10 build, RStudio 1.3.959 and I've just installed the latest MikTex.

I'm trying to put together an R package using RStudio. I can build the package and the Function documentation comments are being converted into /man/*.Rd files. These are then successfully displayed when one executes ?function_name in the RStudio console window.

Unfortunately, I'm having very little luck building the PDF package API documentation (not to be mistaken as the vignette; which I can build). I've looked over a good few tutorials but they all stop short of instructing how one builds the final PDF API document that one expects with every R package.

I've tried: Build[Windows]->More->Document ... which execute devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette'))

Build[Windows]->More->Build Source Package ... which executes devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette')) followed by devtools::build(binary = TRUE, args = c('--preclean'))

Build[Windows]->More->Build Binary Package ... which executes devtools::document(roclets = c('rd', 'collate', 'namespace', 'vignette')) followed by devtools::build(binary = TRUE, args = c('--preclean'))

All three function as expected but still no final package manual pdf file.

Doing some digging on Stack I noticed someone used the command:

devtools::build_manual()

I'm convinced this is what I need. However, when I execute that line of code I get the error:

Converting Rd files to LaTeX ...
Warning in sys2(makeindex, shQuote(idxfile)) : '"makeindex"' not found
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,  : 
  unable to run 'makeindex' on 'Rd2.idx'
Warning in sys2(makeindex, shQuote(idxfile)) : '"makeindex"' not found
Error in texi2dvi(file = file, pdf = TRUE, clean = clean, quiet = quiet,  : 
  unable to run 'makeindex' on 'Rd2.idx'
Error in running tools::texi2pdf()
Error: Failed to build manual

Which has left me none the wiser, although it's quite clear that something's a bit upset by the absence of makeindex. Help is much appreciated.

If I understand correctly, you mean the standard reference manual. For example ggplot2 reference manual . In my experience, this is thrown together by CRAN when you submit. All the manual is (as far as I can tell) a collection of things that a well documented package should have, such as a DESCRIPTION file, a NAMESPACE file, and the various .RD files for actual documentation.

Even when looking at the public github for ggplot2 we see that they do not have the manual in their repository. Additionally, there isn't any evidence in their .git*ignore files to suggest they made the manual themselves.

However, if you want to make this yourself devtools::build_manual() is the correct function call.

I was able to make the manual with a preexisting package on github. I would suggest trying to reinstall your devtools package and make sure there are no warnings or errors. It may be helpful to run a session as administrator to insure things get installed correctly.

Good luck!


I am using R version 3.4 with RStudio 1.1.453 on MacOS High Serra.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM