Skip to content

Commit

Permalink
Code cleanup and document()
Browse files Browse the repository at this point in the history
  • Loading branch information
juba committed Dec 4, 2015
1 parent d303f38 commit dc2d808
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 76 deletions.
13 changes: 8 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@ Package: rmdformats
Maintainer: Julien Barnier <[email protected]>
Authors@R: c(person("Julien", "Barnier", email="[email protected]",
role=c("aut","cre")))
Version: 0.1.1
Date: 2014-11-03
Version: 0.1
Date: 2015-12-04
License: GPL (>= 2)
Encoding: UTF-8
Title: HTML output formats for RMarkdown documents
Title: HTML Output Formats and Templates for RMarkdown Documents
Description: HTML formats and templates for RMarkdown documents, with some extra
features such as automatic table of contents and lightboxed figures.
features such as automatic table of contents, lightboxed figures, dynamic
crosstab helper.
Imports:
questionr,
knitr,
rmarkdown,
htmltools
Suggests:
questionr
URL: https://github.com/juba/rmdformats
RoxygenNote: 5.0.1
5 changes: 3 additions & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Generated by roxygen2 (4.1.0): do not edit by hand
# Generated by roxygen2: do not edit by hand

S3method(print,pilltabs)
export(create.doc)
export(html_clean)
export(html_docco)
export(knit_print.pilltabs)
export(pilltabs)
import(htmltools)
import(rmarkdown)
importFrom(htmltools,htmlDependency)
importFrom(knitr,asis_output)
importFrom(knitr,kable)
importFrom(knitr,opts_knit)
importFrom(questionr,chisq.residuals)
importFrom(questionr,cprop)
importFrom(questionr,rprop)
17 changes: 7 additions & 10 deletions R/html_clean.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
#' "zenburn", "haddock", and "textmate". Pass \code{NULL} to prevent syntax
#' highlighting.
#' @param ... Additional function arguments passed to R Markdown \code{\link{html_document}}
#'
#' @return R Markdown output format to pass to \code{\link{render}}
#'
#' @examples
#' \dontrun{
#'
Expand All @@ -21,10 +19,9 @@
#' render("input.Rmd", html_clean())
#'
#' }
#'
#' @export
#' @import rmarkdown
#' @import htmltools
#' @importFrom htmltools htmlDependency
#' @export


html_clean <- function(fig_width = 6,
Expand All @@ -48,7 +45,7 @@ html_clean <- function(fig_width = 6,
"--variable", paste0("mathjax-url:", rmarkdown:::default_mathjax()))

rmarkdown::html_document(
template=system.file("templates/html_clean/default.html", package="rmdformats"),
template = system.file("templates/html_clean/default.html", package = "rmdformats"),
extra_dependencies = extra_dependencies,
fig_width = fig_width,
fig_height = fig_height,
Expand All @@ -64,23 +61,23 @@ html_clean <- function(fig_width = 6,
html_dependency_jquery_ui <- function() {
htmltools::htmlDependency(name = "jquery-ui",
version = "1.10.4",
src = system.file("templates/jquery-ui-1.10.4", package="rmdformats"),
src = system.file("templates/jquery-ui-1.10.4", package = "rmdformats"),
script = "jquery-ui-1.10.4.custom.min.js")
}

# create an html dependency for tocify
html_dependency_tocify <- function() {
htmltools::htmlDependency(name = "tocify",
version = "1.9.0",
src = system.file("templates/tocify-1.9.0", package="rmdformats"),
src = system.file("templates/tocify-1.9.0", package = "rmdformats"),
script = "jquery.tocify.min.js")
}

# create an html dependency for Maginfic popup
html_dependency_magnific_popup <- function() {
htmltools::htmlDependency(name = "magnific-popup",
version = "0.9.9",
src = system.file("templates/magnific-popup-0.9.9", package="rmdformats"),
src = system.file("templates/magnific-popup-0.9.9", package = "rmdformats"),
script = "jquery.magnific-popup.min.js",
stylesheet = "magnific-popup.css")
}
Expand All @@ -89,7 +86,7 @@ html_dependency_magnific_popup <- function() {
html_dependency_clean <- function() {
htmltools::htmlDependency(name = "clean",
version = "0.1",
src = system.file("templates/html_clean", package="rmdformats"),
src = system.file("templates/html_clean", package = "rmdformats"),
script = "clean.js",
stylesheet = "clean.css")
}
16 changes: 5 additions & 11 deletions R/html_docco.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,15 @@
#' "zenburn", "haddock", and "textmate". Pass \code{NULL} to prevent syntax
#' highlighting.
#' @param ... Additional function arguments passed to R Markdown \code{\link{html_document}}
#'
#' @return R Markdown output format to pass to \code{\link{render}}
#'
#' @examples
#' \dontrun{
#'
#' library(rmdformats)
#'
#' render("input.Rmd", html_docco())
#'
#' }
#'
#' @export
#' @import rmarkdown
#' @import htmltools
#' @importFrom htmltools htmlDependency
#' @export

html_docco <- function(fig_width = 6,
fig_height = 6,
Expand All @@ -45,7 +39,7 @@ html_docco <- function(fig_width = 6,
"--variable", paste0("mathjax-url:", rmarkdown:::default_mathjax()))

rmarkdown::html_document(
template=system.file("templates/html_docco/default.html", package="rmdformats"),
template = system.file("templates/html_docco/default.html", package = "rmdformats"),
extra_dependencies = extra_dependencies,
fig_width = fig_width,
fig_height = fig_height,
Expand All @@ -62,7 +56,7 @@ html_docco <- function(fig_width = 6,
html_dependency_magnific_popup <- function() {
htmltools::htmlDependency(name = "magnific-popup",
version = "0.9.9",
src = system.file("templates/magnific-popup-0.9.9", package="rmdformats"),
src = system.file("templates/magnific-popup-0.9.9", package = "rmdformats"),
script = "jquery.magnific-popup.min.js",
stylesheet = "magnific-popup.css")
}
Expand All @@ -71,7 +65,7 @@ html_dependency_magnific_popup <- function() {
html_dependency_docco <- function() {
htmltools::htmlDependency(name = "docco",
version = "0.1",
src = system.file("templates/html_docco", package="rmdformats"),
src = system.file("templates/html_docco", package = "rmdformats"),
script = "docco.js",
stylesheet = "docco.css")
}
8 changes: 6 additions & 2 deletions R/pilltabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
#' @return
#' No value is returned.
#' @author Julien Barnier <julien.barnier@@ens-lyon.fr>
#' @export
#' @importFrom questionr cprop rprop chisq.residuals
#' @importFrom knitr kable asis_output
#' @importFrom questionr cprop rprop chisq.residuals
#' @export


pilltabs <- function(tab, count=TRUE, rows=TRUE, cols=TRUE, chisq=TRUE, resid=TRUE, row.names=TRUE) {

if (!requireNamespace("questionr", quietly = TRUE))
stop("the questionr package is needed for the pilltabs() function to work. Please install it.",
call. = FALSE)

res <- list()

if (count) res[["count"]] <- kable(tab, output=FALSE, row.names=row.names)
Expand Down
5 changes: 0 additions & 5 deletions R/rmdformats-package.R

This file was deleted.

2 changes: 1 addition & 1 deletion man/create.doc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/html_clean.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions man/html_docco.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/pilltabs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 0 additions & 11 deletions man/rmdformats.Rd

This file was deleted.

Loading

0 comments on commit dc2d808

Please sign in to comment.