-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dchiu911/use-ymlthis
Use ymlthis
- Loading branch information
Showing
17 changed files
with
127 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
export(git_ignore_outputs) | ||
export(use_references) | ||
export(use_rsf) | ||
importFrom(magrittr,"%>%") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
# rsf 0.1.0.9001 | ||
# rsf 0.2.0 | ||
|
||
## API changes | ||
|
||
* Use the `ymlthis` package for writing YAML | ||
|
||
## LaTeX changes | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @importFrom magrittr %>% | ||
## usethis namespace: end | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ use_rsf <- function(path, ...) { | |
write_index(path) | ||
write_src(path) | ||
write_preamble(path) | ||
write_gitignore(path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,17 @@ | ||
# _bookdown.yml | ||
#' Write `_bookdown.yml` | ||
#' @noRd | ||
write_bookdown_yml <- function(path, params) { | ||
bookdown_yml <- c( | ||
list( | ||
book_filename = paste(basename(path), "RSF", sep = "_"), | ||
rmd_subdir = "src", | ||
before_chapter_script = "src/utils.R" | ||
), | ||
params | ||
) | ||
yaml::write_yaml( | ||
x = bookdown_yml, | ||
file = file.path(path, "_bookdown.yml") | ||
bookdown_yml <- rlang::exec( | ||
ymlthis::yml_bookdown_opts, | ||
.yml = ymlthis::yml_empty(), | ||
book_filename = paste(basename(path), "RSF", sep = "_"), | ||
before_chapter_script = "src/utils.R", | ||
rmd_subdir = "src", | ||
!!!params | ||
) | ||
# TODO: quiet arg not passed | ||
tmp <- utils::capture.output(ymlthis::use_bookdown_yml(bookdown_yml, path, quiet = TRUE)) | ||
# TODO: extra final line return | ||
tmp_path <- gsub(".*'(.*)'.*", "\\1", tmp) | ||
writeLines(utils::head(readLines(tmp_path), -1), tmp_path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#' Write `.gitignore` | ||
#' @noRd | ||
write_gitignore <- function(path) { | ||
writeLines( | ||
c(".Rproj.user", ".Rhistory", ".RData", ".Ruserdata"), | ||
file.path(path, ".gitignore") | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
# index.Rmd | ||
#' Write `index.Rmd` | ||
#' @noRd | ||
write_index <- function(path) { | ||
index_yml <- list( | ||
title = paste(basename(path), "Report of Statistical Findings", sep = ": "), | ||
author = whoami::fullname(fallback = "Author"), | ||
date = "`r Sys.Date()`", | ||
site = "bookdown::bookdown_site", | ||
documentclass = "report", | ||
geometry = "margin=1in", | ||
`biblio-style` = "apalike", | ||
`link-citations` = TRUE, | ||
colorlinks = TRUE, | ||
lot = TRUE, | ||
lof = TRUE | ||
) | ||
index_yml <- gsub("\n$", "", yaml::as.yaml(index_yml)) | ||
writeLines(text = c("---", index_yml, "---\n\n# Preface {-}"), | ||
con = file.path(path, "index.Rmd")) | ||
index_yml <- ymlthis::yml_empty() %>% | ||
ymlthis::yml_title(paste(basename(path), | ||
"Report of Statistical Findings", sep = ": ")) %>% | ||
ymlthis::yml() %>% | ||
ymlthis::yml_bookdown_site() %>% | ||
ymlthis::yml_latex_opts( | ||
documentclass = "report", | ||
geometry = "margin=1in", | ||
colorlinks = TRUE, | ||
lof = TRUE, | ||
lot = TRUE, | ||
biblio_style = "apalike" | ||
) %>% | ||
ymlthis::yml_citations(link_citations = TRUE) | ||
writeLines( | ||
text = c(utils::capture.output(print(index_yml)), "\n# Preface {-}"), | ||
con = file.path(path, "index.Rmd") | ||
) # TODO: use_rmarkdown() forces index.Rmd to open, use_index_rmd doesn't pass body param | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
# _output.yml | ||
#' Write `_output.yml` | ||
#' @noRd | ||
write_output_yml <- function(path) { | ||
output_yml <- list( | ||
`bookdown::gitbook` = list( | ||
output_yml <- ymlthis::yml_output( | ||
.yml = ymlthis::yml_empty(), | ||
bookdown::gitbook( | ||
lib_dir = "assets", | ||
split_by = "chapter+number" | ||
), | ||
`bookdown::pdf_book` = list( | ||
bookdown::pdf_book( | ||
keep_tex = TRUE, | ||
includes = list( | ||
in_header = "preamble.tex" | ||
) | ||
includes = ymlthis::includes2(in_header = "preamble.tex") | ||
) | ||
) | ||
yaml::write_yaml( | ||
x = output_yml, | ||
file = file.path(path, "_output.yml") | ||
) | ||
# TODO: quiet arg not passed | ||
tmp <- utils::capture.output(ymlthis::use_output_yml(output_yml, path, quiet = TRUE)) | ||
# TODO: extra final line return | ||
tmp_path <- gsub(".*'(.*)'.*", "\\1", tmp) | ||
writeLines(utils::head(readLines(tmp_path), -1), tmp_path) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,8 @@ | ||
## Resubmission | ||
|
||
This is a resubmission. In this version I have: | ||
|
||
* Renamed installed file '.gitignore to 'gitignore' so it can be found in examples | ||
* Removed package 'here' from Imports | ||
* Used files from inst/extdata for examples | ||
* Improved documentation for use_rsf() | ||
* Ensured examples are executable by adding conditional checks | ||
* Reset the working directory at the end of examples | ||
* Wrapped 'bookdown' and 'YAML' in Description | ||
* Replaced dontrun{} with donttest{} in examples | ||
* Written to tempdir() in examples | ||
|
||
## Test environments | ||
* local OS X install, R 3.5.3 | ||
* ubuntu 14.04 (on travis-ci), R 3.5.3 | ||
* win-builder (devel and release) | ||
* local macOS install, R 3.5.3 | ||
* ubuntu 16.04 (on travis-ci), R-devel, R 3.6.1 | ||
* win-builder (devel) | ||
|
||
## R CMD check results | ||
|
||
0 errors | 0 warnings | 1 note | ||
|
||
* This is a new release. | ||
0 errors | 0 warnings | 0 notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
book_filename: RSF | ||
output_dir: reports | ||
rmd_subdir: src | ||
before_chapter_script: src/utils.R | ||
rmd_subdir: src | ||
output_dir: reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
--- | ||
title: 'Report of Statistical Findings' | ||
author: Derek Chiu | ||
date: '`r Sys.Date()`' | ||
date: '`r format(Sys.Date())`' | ||
site: bookdown::bookdown_site | ||
documentclass: report | ||
geometry: margin=1in | ||
colorlinks: true | ||
lof: true | ||
lot: true | ||
biblio-style: apalike | ||
link-citations: yes | ||
colorlinks: yes | ||
lot: yes | ||
lof: yes | ||
link-citations: true | ||
--- | ||
|
||
# Preface {-} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters