fdschneider / caspr

Cellular Automata for Spatial Pressure in R
MIT License
4 stars 0 forks source link

build and add manual.pdf #33

Closed fdschneider closed 9 years ago

fdschneider commented 9 years ago

We should build and upload the manual (i.e. the complete documentation of all functions) as a separate pdf file for download. Is there an automated workflow for package distribution on Github that builds the documentation?

alexgenin commented 9 years ago

Good question. A quick search provides this result but you have to install the package first. We could automate that with a shell script maybe.

Another option might be to retrieve it from R-forge once caspr actually builds without errors there.

fdschneider commented 9 years ago

Well, that workaround on stackoverflow looks promising but it did produce the following error on my PC:

pack <- "name_of_your_package"
path <- find.package(pack)
system(paste(shQuote(file.path(R.home("bin"), "R")),
    "CMD", "Rd2pdf", shQuote(path)))
Hmm ... looks like a package
Converting parsed Rd's to LaTeX ..
Creating pdf output from LaTeX ...
Warning: running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texi2dvi.exe"  --pdf "Rd2.tex" --max-iterations=20 -I "C:/R/R-32~1.2/share/texmf/tex/latex" -I "C:/R/R-32~1.2/share/texmf/bibtex/bst"' had status 1
Error : running 'texi2dvi' on 'Rd2.tex' failed

LaTeX errors:
!pdfTeX error: pdflatex.EXE (file ts1-zi4r): Font ts1-zi4r at 540 not found
 ==> Fatal error occurred, no output PDF file produced!

Warning: running command '"C:\PROGRA~1\MIKTEX~1.9\miktex\bin\x64\texi2dvi.exe"  --pdf "Rd2.tex" --max-iterations=20 -I "C:/R/R-32~1.2/share/texmf/tex/latex" -I "C:/R/R-32~1.2/share/texmf/bibtex/bst"' had status 1
Error : running 'texi2dvi' on 'Rd2.tex' failed

LaTeX errors:
!pdfTeX error: pdflatex.EXE (file ts1-zi4r): Font ts1-zi4r at 540 not found
 ==> Fatal error occurred, no output PDF file produced!

Error in running tools::texi2pdf()
Warning message:
running command '"C:/R/R-32~1.2/bin/x64/R" CMD Rd2pdf "C:/R/R-3.2.2/library/caspr"' had status 1 

Looks like I am missing some dependencies for the pdf conversion. I think this can be solved. Will investigate. Does this work in Linux environment?

If I run 'check package' in RStudio (= devtools::check, i guess ) the full package including the manual is built in a separate directory and the pdf can be copied manually into the inst/doc/ directory. Thats fine for now I guess.

fdschneider commented 9 years ago

Nice! I found how to fix that missing font error for windows in this post. Now the pdf is supposed to be created by running R CMD Rd2pdf caspr from command line. The extra option -o defines output file name. Thus I modified the R Script:

pack <- "caspr"
path <- find.package(pack)
wd <- getwd()
system(paste0(shQuote(file.path(R.home("bin"), "R")), 
   " CMD", " Rd2pdf --force -o ", wd ,"/inst/doc/caspr-manual.pdf ", 
   shQuote(path))
)