ComputationalProteomicsUnit / maker

Makefile for R packages
GNU General Public License v3.0
31 stars 5 forks source link

a .makerrc chunk #12

Closed lbraglia closed 9 years ago

lbraglia commented 9 years ago

Hi,

these are a few quick'n dirty targets from my .makerrc that could be useful IMHO (spell checking of documentation, testing with codetools, and other doc-related misc targets); tell me if you're maybe interested in one or more of them

# Codetools option for checkUsage: comma separated value pairs
# (eg a=TRUE, b=FALSE)
CODETOOLS_OPTIONS := "all=TRUE"

# Spelling
MAKER_PAGER := less
ASPELL_MASTER_DICT := en_US
ASPELL_EXTRA_DICT := en_GB
ASPELL_COMMAND_PRE := ${R} --vanilla --quiet -e "library(tools); 
ASPELL_COMMAND_POST := ('"$(PKG)"', control = c('--master="$(ASPELL_MASTER_DICT)"', '--add-extra-dicts="$(ASPELL_EXTRA_DICT)"'), dictionaries = Sys.glob(file.path(R.home('share'), 'dictionaries', '*.rds')))" 
ASPELL_RD_FUN := aspell_package_Rd_files
ASPELL_VIGNETTE_FUN := aspell_package_vignettes
ASPELL_C_FUN := aspell_package_C_files
ASPELL_R_FUN := aspell_package_R_files
ASPELL_RD_COMMAND := ${ASPELL_COMMAND_PRE}${ASPELL_RD_FUN}${ASPELL_COMMAND_POST}
ASPELL_VIGNETTE_COMMAND := ${ASPELL_COMMAND_PRE}${ASPELL_VIGNETTE_FUN}${ASPELL_COMMAND_POST}
ASPELL_C_COMMAND := ${ASPELL_COMMAND_PRE}${ASPELL_C_FUN}${ASPELL_COMMAND_POST}
ASPELL_R_COMMAND := ${ASPELL_COMMAND_PRE}${ASPELL_R_FUN}${ASPELL_COMMAND_POST}

# --------------------------------------------------------------------

# devtools::document stuff
document: clean
    ${R} -e "library(devtools); document('"$(PKG)"')";
document-rd: clean
    ${R} -e "library(devtools); document('"$(PKG)"', roclets='rd')";
document-clean: clean
    ${R} -e "library(devtools); document('"$(PKG)"', clean=TRUE)";
document-rd-clean: clean
    ${R} -e "library(devtools); document('"$(PKG)"', roclets='rd', clean=TRUE)";

# roxygen2::roxygenize with clean option
roxygen-clean: clean
    ${R} -e "library(roxygen2); roxygenize('"$(PKG)"', clean=TRUE)";
roxygen-rd-clean: clean
    ${R} -e "library(roxygen2); roxygenize('"$(PKG)"', roclets='rd', clean=TRUE)";

# Spell checking (assuming Aspell)
.aspell-rd:
    ${ASPELL_RD_COMMAND}
.aspell-vignette: 
    ${ASPELL_VIGNETTE_COMMAND}
.aspell-r: 
    ${ASPELL_R_COMMAND}
.aspell-c: 
    ${ASPELL_C_COMMAND}

aspell-rd: 
    make .aspell-rd | ${MAKER_PAGER}
aspell-vignette: 
    make .aspell-vignette | $(MAKER_PAGER)
aspell-r: 
    make .aspell-r | $(MAKER_PAGER)
aspell-c: 
    make .aspell-c | $(MAKER_PAGER)

aspell-all:
    (make .aspell-rd ; make .aspell-vignette; make .aspell-r; make .aspell-c) | $(MAKER_PAGER)

# check-codetools: a check with the most rigorous functions code
# analysis (a NOTE is risen, false positives are possible, but
# anyhow useful), see codetools::checkUsage,
# http://cran.r-project.org/doc/manuals/r-release/R-ints.html#Tools
# and http://stackoverflow.com/questions/10017702/
# 
# CODETOOLS_OPTIONS are however overwritten by variable set in
# ~/.R/check.Renviron if both are present
check-codetools: 
    export _R_CHECK_CODETOOLS_PROFILE_=$(CODETOOLS_OPTIONS) && make check PKG=$(PKG)

Bye, Luca

sgibb commented 9 years ago

Dear Luca,

thanks for sharing your .makerrc. @lgatto maybe we should create a wiki to collect usefull .makerrc entries? (e.g. using R devel #11, add spell checking #12, ...) @lbraglia isn't the document and roxygen stuff the same?

Best wishes,

Sebastian

lgatto commented 9 years ago

@lgatto maybe we should create a wiki to collect usefull .makerrc entries?

+1

Wiki or may be as a section in README, so it also exists as an maker installation.

lbraglia commented 9 years ago

I've read somewhere (probably in hadley's doc) that document is for "more complex packages", but i can't find the link anymore, unfortunately. More follow up here (i hope)...

http://stackoverflow.com/questions/25104108/

[EDIT] i add below the important bits from SO

Roxygen does a live analysis of your source code: it loads all the code in your package, so it can create documentation using values in an R environment, not just source code. However, simulating package loading is rather tricky to do in general, so there are two ways to do it with roxygen:

roxygen2::roxygenise() just sources all files in the R/ directory

devtools::document() sources all files in the R/ directory, compiles source code in the src/ directory, loads data in the data/ directory and generally does an accurate job of simulating package loading.

If you have a simple package, you can use roxygenise(), but for anything more complicated, I recommend that you use document().

lbraglia commented 9 years ago

Hi,

in the meantime I add a few targets useful for continuous integration with r-travis (unix building) and r-appveyor (win building and deployment, example here).

GITHUB_USER := lbraglia

# Continuous integration
.travis:
        wget https://raw.githubusercontent.com/craigcitro/r-travis/master/sample.travis.yml -O  $(PKG)/.travis.yml

ci-add-travis: .travis
        echo "[![Build Status](https://travis-ci.org/$(GITHUB_USER)/$(PKG).svg)](https://travis-ci.org/$(GITHUB_USER)/$(PKG))" >> $(PKG)/README.md
        echo '^\.travis\.yml' >> $(PKG)/.Rbuildignore

.appveyor:
        wget https://raw.githubusercontent.com/krlmlr/r-appveyor/master/sample.appveyor.yml -O  $(PKG)/appveyor.yml
        wget https://raw.githubusercontent.com/krlmlr/r-appveyor/master/.gitattributes -O  $(PKG)/.gitattributes

ci-add-appveyor: .appveyor
        echo '^appveyor\.yml' >> $(PKG)/.Rbuildignore
        @ echo ;
        @ echo "   Now you can add a badge to your README.md  " ;
        @ echo "   Go to https://ci.appveyor.com/project/$(GITHUB_USER)/$(PKG)/settings/badges  " ;

HTH, Luca

lbraglia commented 9 years ago

Alternatively additional rules/tips'n tricks/ecc could be placed in the sample .makerrc ... that helps to keep README succinct (verbose comments to explain the targets could be placed in .makerrc as well) but exists in a standard installation

lgatto commented 9 years ago

I would suggest we have a way to document new recipes to avoid overcrowding the README.md or main Makefile. I have created a new RECIPES.md to do that. People can then copy/paste into their .makerc.

@lbraglia, could you add and document your recipes from this issue and close it?

lbraglia commented 9 years ago

@lgatto, sure!

lgatto commented 9 years ago

Thanks!