Skip to content

Commit

Permalink
finishing touches before submitting to CRAN
Browse files Browse the repository at this point in the history
  • Loading branch information
daroczig committed Aug 16, 2012
1 parent 868a2d4 commit 60a0e49
Show file tree
Hide file tree
Showing 33 changed files with 114 additions and 114 deletions.
4 changes: 2 additions & 2 deletions INSTALL
Expand Up @@ -15,12 +15,12 @@ Development version of pander

As `pander` is under heavy development I would suggest to try out an up-to-date version, as I would not bother CRAN with frequent releases:

https://github.com/daroczig/pander
https://github.com/rapporter/pander

Installation from GitHub is easy with `devtools` useful function:

library(devtools)
install_github('pander', 'daroczig')
install_github('pander', 'rapporter')

To compile/install from sources on Windows, you would need to install Rtools:

Expand Down
2 changes: 1 addition & 1 deletion R/R5.R
@@ -1,6 +1,6 @@
#' Reporting with Pandoc
#'
#' This \code{R5} reference class can hold bunch of elements (text or R objects) from which it tries to create a Pandoc-style markdown text file. Exporting the report to several formats (like: pdf, docx, odt etc. - see Pandoc's documentation) is also possible, see examples below.
#' This \code{R5} reference class can hold bunch of elements (text or R objects) from which it tries to create a Pandoc's markdown text file. Exporting the report to several formats (like: pdf, docx, odt etc. - see Pandoc's documentation) is also possible, see examples below.
#' @export
#' @examples \dontrun{
#' ## Initialize a new Pandoc object
Expand Down
3 changes: 1 addition & 2 deletions R/S3.R
@@ -1,6 +1,6 @@
#' Generic pander method
#'
#' Prints an R object in pandoc style markdown.
#' Prints an R object in Pandoc's markdown.
#' @param x an R object
#' @param ... optional parameters
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
Expand All @@ -9,7 +9,6 @@
#' \item John MacFarlane (2012): _Pandoc User's Guide_. \url{http://johnmacfarlane.net/pandoc/README.html}
#' \item David Hajage (2011): _ascii. Export R objects to several markup languages._ \url{http://CRAN.R-project.org/package=ascii}
#' }
#' @author Gergely Daróczi
#' @export
#' @aliases pander pander.return pandoc pandoc.return
#' @usage
Expand Down
8 changes: 4 additions & 4 deletions R/brew.R
@@ -1,16 +1,16 @@
#' Brew in pandoc format
#'
#' This function behaves just like \code{brew} except for the \code{<\%=...\%>} tags, where \code{Pandoc.brew} first translate the R object found between the tags to Pandoc markdown before passing to the \code{cat} function.
#' This function behaves just like \code{brew} except for the \code{<\%=...\%>} tags, where \code{Pandoc.brew} first translate the R object found between the tags to Pandoc's markdown before passing to the \code{cat} function.
#'
#' This parser tries to be smart in some ways:
#'
#' \itemize{
#' \item a block (R commands between the tags) could return a value in the middle of the block and do something else without any output in the rest (but only one returned value per block!)
#' \item plots and images are grabbed in the document, rendered to a png file and pander method would result in a Pandoc markdown formatted image link (so the image would be shown/included in the exported document). The images' are put in \code{plots} directory in current \code{getwd()} or to the specified \code{output} file's directory.
#' \item a block (R commands between the tags) could return any value at any part of the block and there are no restrictions about the number of returned R objects
#' \item plots and images are grabbed in the document, rendered to a png file and \code{pander} method would result in a Pandoc's markdown formatted image link (so the image would be shown/included in the exported document). The images are put in \code{plots} directory in current \code{getwd()} or to the specified \code{output} file's directory.
#' \item all warnings/messages and errors are recorded in the blocks and returned in the document as a footnote
#' }
#'
#' Please see my Github page for details (\url{http://daroczig.github.com/pander/#brew-to-pandoc}) and examples (\url{http://daroczig.github.com/pander/#examples}).
#' Please see my Github page for details (\url{http://rapporter.github.com/pander/#brew-to-pandoc}) and examples (\url{http://rapporter.github.com/pander/#examples}).
#' @param file file path of the brew template. As this is passed to \code{readLines}, \code{file} could be an URL too, but not over SSL (for that latter \code{RCurl} would be needed).
#' @param output (optional) file path of the output file
#' @param convert string: format of required output document (besides Pandoc's markdown). Pandoc is called if set via \code{Pandoc.convert} and the converted document could be also opened automatically (see below).
Expand Down
8 changes: 4 additions & 4 deletions R/convert.R
Expand Up @@ -28,8 +28,8 @@ openFileInOS <- function(f) {
#' Converts Pandoc to other format
#'
#' Calling John MacFarlane's great program to convert specified file (see \code{f} parameter below) or character vector {see \code{text} paramater} to other formats like \code{HTML}, \code{pdf}, \code{docx}, \code{odt} etc.
#' @param f Pandoc markdown format file path. If URL is provided then the generated file's path is \code{tempfile()} but please bear in mind that this way only images with absolute path would shown up in the document.
#' @param text Pandoc markdown format character vector. Treated as the content of \code{f} file - so the \code{f} parameter is ignored. The generated file's path is \code{tempfile()}.
#' @param f Pandoc's markdown format file path. If URL is provided then the generated file's path is \code{tempfile()} but please bear in mind that this way only images with absolute path would shown up in the document.
#' @param text Pandoc's markdown format character vector. Treated as the content of \code{f} file - so the \code{f} parameter is ignored. The generated file's path is \code{tempfile()}.
#' @param format required output format. For all possible values here check out Pandoc homepage: \url{http://johnmacfarlane.net/pandoc/}
#' @param open try to open converted document with operating system's default program
#' @param options optionally passed arguments to Pandoc (instead of \code{pander}'s default)
Expand All @@ -42,7 +42,7 @@ openFileInOS <- function(f) {
#' @export
#' @examples \dontrun{
#' Pandoc.convert(text = c('# Demo', 'with a paragraph'))
#' Pandoc.convert('http://daroczig.github.com/pander/minimal.md')
#' Pandoc.convert('http://rapporter.github.com/pander/minimal.md')
#' ## Note: the generated HTML is not showing images with relative path from the above file. Based on that `pdf`, `docx` etc. formats would not work! If you want to convert an online markdown file to other formats with this function, please pre-process the file to have absolute paths instead.
#' }
Pandoc.convert <- function(f, text, format = 'html', open = TRUE, options = '', footer = TRUE, proc.time, portable.html = TRUE) {
Expand Down Expand Up @@ -96,7 +96,7 @@ Pandoc.convert <- function(f, text, format = 'html', open = TRUE, options = '',
## add footer to file
if (footer)
if (!grepl('This report was generated', tail(readLines(f, warn = FALSE), 1)))
cat(sprintf('\n\n-------\nThis report was generated with [R](http://www.r-project.org/) (%s) and [pander](https://github.com/daroczig/pander) (%s)%son %s platform.', sprintf('%s.%s', R.version$major, R.version$minor), packageDescription("pander")$Version, ifelse(missing(proc.time), ' ', sprintf(' in %s sec ', format(proc.time))), R.version$platform), file = f, append = TRUE)
cat(sprintf('\n\n-------\nThis report was generated with [R](http://www.r-project.org/) (%s) and [pander](https://github.com/rapporter/pander) (%s)%son %s platform.', sprintf('%s.%s', R.version$major, R.version$minor), packageDescription("pander")$Version, ifelse(missing(proc.time), ' ', sprintf(' in %s sec ', format(proc.time))), R.version$platform), file = f, append = TRUE)

## set specified dir
wd <- getwd()
Expand Down
25 changes: 13 additions & 12 deletions R/helpers.R
@@ -1,6 +1,6 @@
#' Add trailing and leading blank line
#'
#' Adds a line break before *and* after the character string(s).
#' Adds a line break before \emph{and} after the character string(s).
#' @param x character vector
#' @export
add.blank.lines <- function(x)
Expand Down Expand Up @@ -126,7 +126,7 @@ pandoc.indent <- function(x, level = 0) {

#' Paragraphs
#'
#' Pandoc style paragraph.
#' Pandoc's markdown paragraph.
#' @param x character vector
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
#' @export
Expand Down Expand Up @@ -162,7 +162,7 @@ pandoc.add.formatting <- function(x, f) {

#' Strong emphasis
#'
#' Pandoc style strong emphasis format (e.g. \code{**FOO**}) is added to character string.
#' Pandoc's markdown strong emphasis format (e.g. \code{**FOO**}) is added to character string.
#' @param x character vector
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
#' @export
Expand All @@ -183,7 +183,7 @@ pandoc.strong <- function(...)

#' Emphasis
#'
#' Pandoc style emphasis format (e.g. \code{*FOO*}) is added to character string.
#' Pandoc's markdown emphasis format (e.g. \code{*FOO*}) is added to character string.
#' @param x character vector
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
#' @export
Expand All @@ -204,7 +204,7 @@ pandoc.emphasis <- function(...)

#' Add strikeout
#'
#' Pandoc style strikeout format (e.g. \code{~~FOO~~}) is added to character string.
#' Pandoc's markdown strikeout format (e.g. \code{~~FOO~~}) is added to character string.
#' @param x character vector
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
#' @export
Expand All @@ -225,7 +225,7 @@ pandoc.strikeout <- function(...)

#' Add verbatim
#'
#' Pandoc style verbatim format (e.g. \code{`FOO`}) is added to character string.
#' Pandoc's markdown verbatim format (e.g. \code{`FOO`}) is added to character string.
#' @param x character vector
#' @param style show code \code{inline} or in a separate (\code{indent}ed or \code{delim}ited) block
#' @param attrs (optionally) pass ID, classes and any attribute to the \code{delimited} block
Expand Down Expand Up @@ -266,6 +266,7 @@ pandoc.verbatim <- function(...)


#' Create pandoc link
#' Pandoc's markdown format link.
#' @param url hyperlink
#' @param text link text
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
Expand All @@ -285,7 +286,7 @@ pandoc.link <- function(...)

#' Create pandoc image tags
#'
#' Creates a pandoc style image hyperlink.
#' Creates a Pandoc's markdown format image hyperlink.
#' @param img image path
#' @param caption text
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
Expand All @@ -308,7 +309,7 @@ pandoc.image <- function(...)

#' Footnote
#'
#' Creates a pandoc style footnote.
#' Creates a Pandoc's markdown format footnote.
#' @param x character vector
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
#' @export
Expand All @@ -326,7 +327,7 @@ pandoc.footnote <- function(...)

#' Create horizontal rule
#'
#' Creates a pandoc style horizontal line with trailing and leading newlines.
#' Creates a Pandoc's markdown format horizontal line with trailing and leading newlines.
#' @return By default this function outputs (see: \code{cat}) the result. If you would want to catch the result instead, then call the function ending in \code{.return}.
#' @export
#' @aliases pandoc.horizontal.rule
Expand All @@ -341,7 +342,7 @@ pandoc.horizontal.rule <- function(...)

#' Create header
#'
#' Creates a pandoc/markdown style header with given level.
#' Creates a (Pandoc's) markdown style header with given level.
#' @param x character vector
#' @param level integer
#' @param style atx or setext type of heading
Expand Down Expand Up @@ -383,7 +384,7 @@ pandoc.header <- function(...)

#' Create title block
#'
#' Creates a pandoc style title block with optional author, title and date fields.
#' Creates a Pandoc's markdown style title block with optional author, title and date fields.
#' @param author character vector or semicolon delimited list of authors without line break
#' @param title character vector of lines of title or multiline string with \code{\\n} separators
#' @param date any string fit in one line
Expand Down Expand Up @@ -444,7 +445,7 @@ pandoc.title <- function(...)

#' Create a list
#'
#' Creates a pandoc style list from provided character vector/list.
#' Creates a Pandoc's markdown format list from provided character vector/list.
#' @param elements character vector of strings
#' @param style the required style of the list
#' @param loose adding a newline between elements
Expand Down
4 changes: 2 additions & 2 deletions R/options.R
Expand Up @@ -207,7 +207,7 @@ masked.plots$plot <- masked.plots$barplot <- masked.plots$lines <- masked.plots$
#' @param o option name (string). See below.
#' @param value value to assign (optional)
#' @export
#' @seealso \code{\link{evals.option}}
#' @seealso \code{\link{evalsOptions}}
#' @aliases pander.option
#' @note \code{pander.option} is deprecated and is to be removed in future releases.
#' @examples \dontrun{
Expand Down Expand Up @@ -265,7 +265,7 @@ pander.option <- function(x, ...) {
#' \item \code{cache.time}: number of seconds to limit caching based on \code{proc.time}. If set to \code{0}, all R commands, if set to \code{Inf}, none is cached (despite the \code{cache} parameter).
#' \item \code{cache.copy.images}: copy images to new files if an image is returned from cache? If set to \code{FALSE} (default) the "old" path would be returned.
#' \item \code{classes}: a vector or list of classes which should be returned. If set to \code{NULL} (by default) all R objects will be returned.
#' \item \code{hooks}: list of hooks to be run for given classes in the form of \code{list(class = fn)}. If you would also specify some parameters of the function, a list should be provided in the form of \code{list(fn, param1, param2=NULL)} etc. So the hooks would become \code{list(class1=list(fn, param1, param2=NULL), ...)}. See example below. A default hook can be specified too by setting the class to \code{'default'}. This can be handy if you do not want to define separate methods/functions to each possible class, but automatically apply the default hook to all classes not mentioned in the list. You may also specify only one element in the list like: \code{hooks=list('default' = pander.return)}. Please note, that nor error/warning messages, nor stdout is captured (so: updated) while running hooks!
#' \item \code{hooks}: list of hooks to be run for given classes in the form of \code{list(class = fn)}. If you would also specify some parameters of the function, a list should be provided in the form of \code{list(fn, param1, param2=NULL)} etc. So the hooks would become \code{list(class1=list(fn, param1, param2=NULL), ...)}. See examples of \code{\link{evals}}. A default hook can be specified too by setting the class to \code{'default'}. This can be handy if you do not want to define separate methods/functions to each possible class, but automatically apply the default hook to all classes not mentioned in the list. You may also specify only one element in the list like: \code{hooks=list('default' = pander.return)}. Please note, that nor error/warning messages, nor stdout is captured (so: updated) while running hooks!
#' \item \code{length}: any R object exceeding the specified length will not be returned. The default value (\code{Inf}) does not filter out any R objects.
#' \item \code{output}: a character vector of required returned values. This might be useful if you are only interested in the \code{result}, and do not want to save/see e.g. \code{messages} or \code{print}ed \code{output}. See examples of \code{\link{evals}}.
#' \item \code{graph.unify}: should \code{evals} try to unify the style of (\code{base}, \code{lattice} and \code{ggplot2}) plots? If set to \code{TRUE}, some \code{panderOptions()} would apply. By default this is disabled not to freak out useRs :)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -790,4 +790,4 @@ To use this small lib, just type: `M-x pander-mode` on any document. It might be


-------
This report was generated with [R](http://www.r-project.org/) (2.15.1) and [pander](https://github.com/daroczig/pander) (0.1) in 1.282 sec on x86_64-unknown-linux-gnu platform.
This report was generated with [R](http://www.r-project.org/) (2.15.1) and [pander](https://github.com/rapporter/pander) (0.1) in 1.282 sec on x86_64-unknown-linux-gnu platform.
9 changes: 5 additions & 4 deletions TODO.md
Expand Up @@ -53,7 +53,7 @@
* add option to run code in sandbox:

* RAppArmor: https://github.com/jeroenooms/RAppArmor
* ~~sandboxR: https://github.com/daroczig/sandboxR~~: just provide a sandboxed environment
* ~~sandboxR: https://github.com/rapporter/sandboxR~~: just provide a sandboxed environment

### Image options:

Expand Down Expand Up @@ -108,7 +108,7 @@ Global options for: `lattice`, `ggplot2` and `base` plots

### Required helper functions

* add significance stars
* ~~add significance stars~~
* ~~indent concatenated strings~~: `pandoc.indent`

### Calling Pandoc (converting docs)
Expand Down Expand Up @@ -156,8 +156,9 @@ Global options for: `lattice`, `ggplot2` and `base` plots

### Tests

* **Do that at last!**
* ~~Do that at last!~~
* ~~evals~~
* ~~brew~~
* helper functions

# HTML/JS/CSS issues
Expand All @@ -166,7 +167,7 @@ Global options for: `lattice`, `ggplot2` and `base` plots

# ESS

* integrate (add some Lisp functions/optional key-bindings) `evals`/`pander`/`Pander.brew` - thanks for great ideas [*Michael Lawrence* @ [ESS] mail list](https://stat.ethz.ch/pipermail/ess-help/attachments/20120602/554dfb2f/attachment.pl)
* ~~integrate (add some Lisp functions/optional key-bindings) `evals`/`pander`/`Pander.brew` - thanks for great ideas [*Michael Lawrence* @ [ESS] mail list](https://stat.ethz.ch/pipermail/ess-help/attachments/20120602/554dfb2f/attachment.pl)~~: http://rapporter.github.com/pander/#ess

# Great ideas

Expand Down
2 changes: 1 addition & 1 deletion inst/examples/graphs.brew
Expand Up @@ -31,7 +31,7 @@ There are a bunch of options you might want to check out, these are:

<%=as.list(names(panderOptions())[grepl('^graph', names(panderOptions()))])%>

Find more details on [`pander`'s homepage](http://daroczig.github.com/pander/#pander-options_link).
Find more details on [`pander`'s homepage](http://rapporter.github.com/pander/#pander-options).

# Default options

Expand Down
2 changes: 1 addition & 1 deletion inst/examples/minimal.brew
Expand Up @@ -22,7 +22,7 @@ For example `mtcars`'s first 5 cases look like:

<%=mtcars[1:5, ]%>

As you can see some formatting was added to the returned table and was also split up as the original table would have been too wide to fit on the screen (any `pander`er still using a VT100 terminal?) or standard paper. If you do not like that split up, just set the according [`panderOption`](http://daroczig.github.com/pander/#pander-options_link)!
As you can see some formatting was added to the returned table and was also split up as the original table would have been too wide to fit on the screen (any `pander`er still using a VT100 terminal?) or standard paper. If you do not like that split up, just set the according [`panderOption`](http://rapporter.github.com/pander/#pander-options)!

We could try other R objects too, for example let us check `chisq.test` on some variables of `mtcars`:

Expand Down
2 changes: 1 addition & 1 deletion inst/includes/html/footer.html
@@ -1,3 +1,3 @@
<p align="center">
Design: <a href="http://rapport-package.info/"><i>rapport</i> Development Team</a> &copy; 2012 | Backend: <a href="https://github.com/daroczig/pander">pander</a> | License: <a href="http://www.gnu.org/licenses/agpl.html" target="_blank">AGPL3</a> | Styled with <a href="http://www.getskeleton.com/" target="_blank">skeleton</a>
Design: <a href="http://rapport-package.info/"><i>rapport</i> Development Team</a> &copy; 2012 | Backend: <a href="https://github.com/rapporter/pander">pander</a> | License: <a href="http://www.gnu.org/licenses/agpl.html" target="_blank">AGPL3</a> | Styled with <a href="http://www.getskeleton.com/" target="_blank">skeleton</a>
</p>

0 comments on commit 60a0e49

Please sign in to comment.