diff --git a/.gitignore b/.gitignore index 807ea25..d71de39 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +inst/doc .Rproj.user .Rhistory .RData +.txt \ No newline at end of file diff --git a/DESCRIPTION b/DESCRIPTION index 1d7dbc7..4c67383 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,14 +1,16 @@ Package: dscoemarkdown Title: R Markdown for DSCOE Submissions -Version: 0.0.0.9000 +Version: 0.0.1.0 Authors@R: person("Ian", "Kloo", email = "ian.p.kloo.civ@mail.mil", role = c("aut", "cre")) Description: Create R Markdown documents in the prefered format for the DSCOE website. Depends: - R (>= 2.0.0) + R (>= 3.5.0) License: None Encoding: UTF-8 LazyData: true -RoxygenNote: 5.0.1 +RoxygenNote: 7.1.0 Imports: knitr, rmarkdown +VignetteBuilder: knitr + diff --git a/R/dscoemarkdown_function.R b/R/dscoemarkdown_function.R index 495ef29..28b3e15 100644 --- a/R/dscoemarkdown_function.R +++ b/R/dscoemarkdown_function.R @@ -1,26 +1,65 @@ -#' Run Markdown +#' @title Generate DSCOE markdown #' -#' +#' @description Apply css and footer and build a DSCOE formatted markdown document +#' +#' @param logo a boolean representing whether or not to inclue the DSCOE logo +#' @param disclaimer a boolean representing whether or not to include the disclaimer footer +#' +#' @examples +#' --- +#' #title: "Demo Header" +#' #author: "Ian Kloo" +#' #date: "September 2016" +#' #output: dscoemarkdown::dscoe +#' --- +#' +#' --- +#' #title: "Demo Header" +#' #author: "Ian Kloo" +#' #date: "September 2016" +#' #output: +#' # dscoemarkdown::dscoe: +#' # logo: FALSE +#' # disclaimer: FALSE +#' --- #' #' @export -#' -#' dscoe <- function(logo=TRUE, disclaimer=TRUE) { system <- system.file('',package='dscoemarkdown') - - if(disclaimer == TRUE){ - footer <- paste(system,'/style/disclaimer.html',sep='') - } else if(disclaimer == FALSE){ - footer <- paste(system,'/style/noDisclaimer.html',sep='') - } - - if(logo == TRUE){ - css <- paste(system,'/style/dscoemarkdownLogo.css',sep='') - } else if(logo == FALSE){ - css <- paste(system,'/style/dscoemarkdownNoLogo.css',sep='') + + if(.Platform$OS.type == 'windows'){ + + if(disclaimer == TRUE){ + footer <- paste(system,'/style/disclaimer.html',sep='') + } else if(disclaimer == FALSE){ + footer <- paste(system,'/style/noDisclaimer.html',sep='') + } + + if(logo == TRUE){ + css <- paste(system,'/style/dscoemarkdownLogo.css',sep='') + } else if(logo == FALSE){ + css <- paste(system,'/style/dscoemarkdownNoLogo.css',sep='') + } + + } else if (.Platform$OS.type == "unix") { + + if(disclaimer == TRUE){ + footer <- paste(system,'style/disclaimer.html',sep='') + } else if(disclaimer == FALSE){ + footer <- paste(system,'style/noDisclaimer.html',sep='') + } + + if(logo == TRUE){ + css <- paste(system,'style/dscoeMarkdownLogo.css',sep='') + } else if(logo == FALSE){ + css <- paste(system,'style/dscoeMarkdownNoLogo.css',sep='') + } + } - + + + rmarkdown::html_document(css=css, includes=rmarkdown::includes(after_body=footer)) } diff --git a/README.md b/README.md index 7cc20df..2856636 100644 --- a/README.md +++ b/README.md @@ -13,13 +13,6 @@ require(devtools) devtools::install_github("iankloo/dscoemarkdown") ``` -***There is a known issue with linux users. Until I can get a more elgant fix, you can use the following lines to install the package on linux: - -```{r} -require(devtools) -devtools::install_github("iankloo/dscoemarkdown", ref = 'linux') -``` - If that goes smoothly, you can now include this line in the header of your R Markdown Documents: ```{r} @@ -67,5 +60,5 @@ As it stands, the styling in this package is very basic. If you want to propose ## Example -![alt tag](https://github.com/iankloo/dscoemarkdown/blob/master/dscoeMarkdownExample.png) +![alt tag](./inst/dscoeMarkdownExample.png) diff --git a/dscoemarkdown.Rproj b/dscoemarkdown2.Rproj similarity index 65% rename from dscoemarkdown.Rproj rename to dscoemarkdown2.Rproj index d848a9f..497f8bf 100644 --- a/dscoemarkdown.Rproj +++ b/dscoemarkdown2.Rproj @@ -1,16 +1,20 @@ Version: 1.0 -RestoreWorkspace: No -SaveWorkspace: No +RestoreWorkspace: Default +SaveWorkspace: Default AlwaysSaveHistory: Default EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 Encoding: UTF-8 +RnwWeave: Sweave +LaTeX: pdfLaTeX + AutoAppendNewline: Yes StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source -PackageRoxygenize: rd,collate,namespace diff --git a/dscoeMarkdownExample.png b/inst/dscoeMarkdownExample.png similarity index 100% rename from dscoeMarkdownExample.png rename to inst/dscoeMarkdownExample.png diff --git a/man/dscoe.Rd b/man/dscoe.Rd index f8dcfb1..87d05b4 100644 --- a/man/dscoe.Rd +++ b/man/dscoe.Rd @@ -2,11 +2,34 @@ % Please edit documentation in R/dscoemarkdown_function.R \name{dscoe} \alias{dscoe} -\title{Run Markdown} +\title{Generate DSCOE markdown} \usage{ -dscoe() +dscoe(logo = TRUE, disclaimer = TRUE) +} +\arguments{ +\item{logo}{a boolean representing whether or not to inclue the DSCOE logo} + +\item{disclaimer}{a boolean representing whether or not to include the disclaimer footer} } \description{ -Run Markdown +Apply css and footer and build a DSCOE formatted markdown document } +\examples{ +--- +#title: "Demo Header" +#author: "Ian Kloo" +#date: "September 2016" +#output: dscoemarkdown::dscoe +--- +--- +#title: "Demo Header" +#author: "Ian Kloo" +#date: "September 2016" +#output: + # dscoemarkdown::dscoe: + # logo: FALSE + # disclaimer: FALSE +--- + +} diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/DSCOE-Markdown.Rmd b/vignettes/DSCOE-Markdown.Rmd new file mode 100644 index 0000000..c1f1872 --- /dev/null +++ b/vignettes/DSCOE-Markdown.Rmd @@ -0,0 +1,83 @@ +--- +title: "DSCOE-Markdown" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{DSCOE-Markdown} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +```{r setup} +library(dscoemarkdown) +``` + +# DSCOE Markdown Package + +This package was created for DSCOE products in order to unify formatting. + +Using this package, you can extend knitr to automatically use the DSCOE format. + +## Usage + +You can install this package using the devtools github installer: + +```{r eval=FALSE} +require(devtools) +devtools::install_github("iankloo/dscoemarkdown") +``` + +If that goes smoothly, you can now include this line in the header of your R Markdown Documents: + +```{r eval=FALSE} +output: dscoemarkdown::dscoe +``` + +An example full header is: + +```{r eval=FALSE} +--- +title: "Demo Header" +author: "Ian Kloo" +date: "September 2016" +output: dscoemarkdown::dscoe +--- +``` + +## Styling + +The base styling comes from Edward Tufte's github page. Tufte is known for simple and readable aesthetics, so this was a good place to start. + +This styling is very simple, in that it does not require any javascript libraries (such as jQuery) to do the styling. These libraries make it much more difficult to share/post documents. You may still need to include javascript libraries as part of your work, but at least there won't be any additional libraries needed for styling alone. + +## Options + +You have the option to remove the DSCOE logo and/or the disclaimer. We ask that you leave these on for DSCOE posts, but if you want to use the framework elsewhere, please feel free to remove them. + +By default, both the logo and disclaimer are included. To change this you can specify options like this: + +```{r eval=FALSE} +--- +title: "DSCOE Markdown Example" +author: "Ian Kloo" +date: "September 2016" +output: + dscoemarkdown::dscoe: + logo: FALSE + disclaimer: FALSE +--- +``` + +## Development + +As it stands, the styling in this package is very basic. If you want to propose any changes, make an "issue" or clone the repo and push your own branch. + +## Example + +![alt tag](../inst/dscoeMarkdownExample.png)