markdownRule: Rule for building text documents from Markdown files

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/markdownRule.R

Description

This rule is for execution of Markdown rendering in order to create text file of various supported formats such as (PDF, DOCX, etc.).

Usage

1
2
markdownRule(target, script, depends = NULL, format = "all",
  params = list(), task = "all")

Arguments

target

Name of the output file to be created

script

Name of the markdown file to be rendered

depends

A vector of file names that the markdown script depends on, or NULL.

format

Requested format of the result. Parameter is passed as format argument to rmarkdown::render(). Allowed values are: 'all', 'html_document', 'pdf_document', 'word_document', 'odt_document', 'rtf_document', or 'md_document'.

params

A list of R values that become available within the script in a params variable.

task

A character vector of parent task names. The mechanism of tasks allows to group rules. Anything different from 'all' will cause creation of a new task depending on the given rule. Executing make taskname will then force building of this rule.

Details

This rule executes the following command in a separate R process: params <- params; rmarkdown::render(script, output_format=format, output_file=target)

That is, parameters given in the params argument are stored into the global variable and then the script is rendered with rmarkdown. That is, the re-generation of the Makefile with any change to params will not cause the re-execution of the recipe unless any other script dependencies change.

Issuing make clean from the shell causes removal of all files specified in target parameter.

Value

Instance of S3 class rmake.rule

Author(s)

Michal Burda

See Also

rule(), makefile(), rRule()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
r <- markdownRule(target='report.pdf',
                  script='report.Rmd',
                  depends=c('data1.csv', 'data2.csv'))

# generate the content of a makefile (as character vector)
makefile(list(r))

# generate to file
tmp <- tempdir()
makefile(list(r), file.path(tmp, "Makefile"))

rmake documentation built on May 1, 2019, 10:37 p.m.