Skip to content

Commit

Permalink
Fix #262 and other R CMD check issues
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed Aug 6, 2024
1 parent 0450078 commit 0ed25c3
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 20 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ ByteCompile: true
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
SystemRequirements: pandoc (>= 1.18) - http://pandoc.org
Config/testthat/parallel: true
Config/testthat/edition: 2
14 changes: 11 additions & 3 deletions R/chunk-header.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,19 @@ chunk_header_contains <- function(header, option){
#' "needs_trans = TRUE" then the text in `option` will be added with a
#' preceeding comma and space, at the end of the list of options that is
#' already present:
#' ```{r example, eval = !fr()}`
#'
#' ```
#' eval = !fr()
#' ```
#'
#' would become
#' ```{r example, eval = !fr(), needs_trans = TRUE}`
#'
#' ```
#' eval = !fr(), needs_trans = TRUE
#' ```
#'
#' If `header` is not matched by the regular expression used by knitr for
#' beginning chunks [knitr::all_patterns$md$chunk.begin] then a
#' beginning chunks `knitr::all_patterns$md$chunk.begin` then a
#' warning will be issued and `header` will be returned.
#' If `option` already exists in `header` and `ovr` is `TRUE`, it will be
#' overwritten with the new `option` value
Expand Down
4 changes: 2 additions & 2 deletions R/csasdown.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
#' PDF or Word format. The package is based on Chester Ismay's thesisdown
#' package and Ben Marwick's huskydown package.
#'
#' @docType package
#' @name csasdown
#' @keywords internal
"_PACKAGE"
NULL

# hack because I can't suppress this package data warning!?
if(getRversion() >= "2.15.1")
utils::globalVariables(c("region_info", ".x", ".y",
"fn", "num_lines", "post_num",
Expand Down
5 changes: 2 additions & 3 deletions R/set-citations.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#' must have a YAML option called 'french' set to either 'true' or 'false'
#' @param verbose Logical. If `TRUE`, print messages
#'
#' @return
#' @export
set_citations <- function(fn = get_index_filename(
system.file("rmarkdown",
Expand All @@ -32,15 +31,15 @@ set_citations <- function(fn = get_index_filename(

if(fr()){
if(!length(ca_ind)){
warning("You are missing the `citation_english:` tag in your YAML file:\n",
message("You are missing the `citation_english:` tag in your YAML file:\n",
fn, ". This citation is required when you build in French as it ",
"is set to the other language citation on page 2 of ",
"the document")
return(invisible())
}
}else{
if(!length(cf_ind)){
warning("You are missing the `citation_french:` tag in your YAML file:\n",
message("You are missing the `citation_french:` tag in your YAML file:\n",
fn, ". This citation is required when you build in English as it ",
"is set to the other language citation on page 2 of ",
"the document")
Expand Down
1 change: 1 addition & 0 deletions inst/rmarkdown/templates/manureport/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ french_abstract: |
# both be absent from all tables. If it is missing or any other value than
# `false`, it will be assumed to be `true`
show_continued_text: true
citation_french: ""
output:
csasdown::manureport_pdf:
french: false
Expand Down
1 change: 1 addition & 0 deletions inst/rmarkdown/templates/techreport/skeleton/skeleton.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ french_abstract: |
# with `csas_table()` that cross page boundaries. If `false`, these will
# both be absent from all tables. If it is missing or any other value than
# `false`, it will be assumed to be `true`
citation_french: ""
show_continued_text: true
output:
csasdown::techreport_pdf:
Expand Down
15 changes: 14 additions & 1 deletion man/chunk_header_add.Rd

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

1 change: 1 addition & 0 deletions man/csasdown.Rd

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

8 changes: 4 additions & 4 deletions tests/testthat/test-fix-envs.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_that("fix_envs() works", {
en_region_ind <- grep("^\\s*region:", rmd)
rmd[en_region_ind] <- paste0("region: ", fr_region)
writeLines(rmd, "index.Rmd")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists("_book/sr-english.pdf"))
expect_true(file.exists("_book/sr-english.tex"))
tex <- readLines("_book/sr-english.tex")
Expand All @@ -46,7 +46,7 @@ test_that("fix_envs() works", {
rmd_after <- rmd[(french_abs_ind - 1):length(rmd)]
rmd <- c(rmd_prev, "abstract:", rmd_after)
writeLines(rmd, "index.Rmd")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists("_book/resdoc-english.pdf"))
expect_true(file.exists("_book/resdoc-english.tex"))

Expand All @@ -72,7 +72,7 @@ test_that("fix_envs() works", {
prepub_ind <- grep("prepub", rmd)
rmd[prepub_ind] <- " prepub: true"
writeLines(rmd, "index.Rmd")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists("_book/sr-english.pdf"))
expect_true(file.exists("_book/sr-english.tex"))

Expand Down Expand Up @@ -115,7 +115,7 @@ test_that("fix_envs() works", {
ind <- grep("include_section_nums:", rmd)
rmd[ind] <- " include_section_nums: false"
writeLines(rmd, "index.Rmd")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists("_book/resdoc-english.pdf"))
expect_true(file.exists("_book/resdoc-english.tex"))

Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-render-manureport.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ expect_message(csasdown::check_yaml(type = "manureport", verbose = TRUE),
test_that("csasdown::render generates the PDF of the manureport", {
csasdown::set_french(val = FALSE)
csasdown:::set_render_type(doc_type = "pdf")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists(file.path(testing_path, "_book",
"manureport-english.pdf")))
})
Expand All @@ -30,7 +30,7 @@ test_that("csasdown::render generates the PDF of the manureport", {
test_that("csasdown::render generates the .docx of the manureport", {
csasdown::set_french(val = FALSE)
csasdown:::set_render_type(doc_type = "word")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists(file.path(testing_path, "_book",
"manureport-english.docx")))
})
Expand Down Expand Up @@ -89,7 +89,7 @@ test_that("csasdown::render detects cover page missing", {
ind <- grep("line_nums_mod:", rmd)
rmd[ind] <- " line_nums_mod: 1"
writeLines(rmd, "index.Rmd")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists(file.path(testing_path, "_book",
"manureport-english.pdf")))
expect_true(file.exists(file.path(testing_path,
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-render-techreport.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ expect_message(csasdown::check_yaml(type = "techreport", verbose = TRUE),
test_that("csasdown::render generates the PDF of the techreport", {
csasdown::set_french(val = FALSE)
csasdown:::set_render_type(doc_type = "pdf")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists(file.path(testing_path, "_book",
"techreport-english.pdf")))
})
Expand All @@ -30,7 +30,7 @@ test_that("csasdown::render generates the PDF of the techreport", {
test_that("csasdown::render generates the .docx of the techreport", {
csasdown::set_french(val = FALSE)
csasdown:::set_render_type(doc_type = "word")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists(file.path(testing_path, "_book",
"techreport-english.docx")))
})
Expand Down Expand Up @@ -102,7 +102,7 @@ test_that("csasdown::render detects cover page missing", {
ind <- grep("line_nums_mod:", rmd)
rmd[ind] <- " line_nums_mod: 1"
writeLines(rmd, "index.Rmd")
csasdown::render()
csasdown::render(suppress_warnings = TRUE)
expect_true(file.exists(file.path(testing_path, "_book",
"techreport-english.pdf")))
expect_true(file.exists(file.path(testing_path,
Expand Down

0 comments on commit 0ed25c3

Please sign in to comment.