diff --git a/.Rbuildignore b/.Rbuildignore index 179f6c2cb5cfafd3228a9b3488fe8bd40c9924b2..2610bc20c3e6676e292a2e591edafaa657517553 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -14,3 +14,4 @@ ^_pkgdown\.yml$ ^docs$ ^pkgdown$ +^\.devcontainer$ diff --git a/R/render_report.R b/R/render_report.R index e62d237f88d13ad58474101c54edbda73f09d244..a80b31682a0404583d9ea12db9072cb9bf510cde 100644 --- a/R/render_report.R +++ b/R/render_report.R @@ -24,9 +24,6 @@ render_report <- function(input, cfg_bookdown <- yaml::read_yaml(file.path(input, "_bookdown.yml")) unlink(file.path(input, paste0(cfg_bookdown$book_filename, ".*"))) - dir.create(output_dir, - recursive = TRUE, - showWarnings = FALSE) attached_packages <- (.packages()) bookdown::render_book(input, output_format = output_format, diff --git a/R/render_reports.R b/R/render_reports.R index dbf8fc24de1a0025e2d8c14d607d9fd58997fac2..62011a18ab99486e5b1f1fb16688d11587a9bf3a 100644 --- a/R/render_reports.R +++ b/R/render_reports.R @@ -16,7 +16,7 @@ #' render_reports <- function(reports_dir = file.path(pkgload::pkg_path(), "reports"), reports = list.dirs(reports_dir, full.names = FALSE, recursive = FALSE), - publish_dir = "../../public/reports", + publish_dir = file.path(dirname(reports_dir), "public/reports"), ...) { options(knitr.duplicate.label = 'allow') diff --git a/R/utils.R b/R/utils.R index 37297ac88fab7170a1a020c23016975f2cab0d27..f4865bc1ec077df36eb9ab43774693b733c59015 100644 --- a/R/utils.R +++ b/R/utils.R @@ -31,11 +31,23 @@ pkg_sys <- function( #' @export #' #' @examples -#' purge_string("Là chaîne pl€ine dé &#/* $péciaux", "_") +#' \dontrun{ +#' # Download some funny UTF-8 string +#' tmp <- tempfile() +#' download.file( +#' file.path("https://raw.githubusercontent.com", +#' "bits/UTF-8-Unicode-Test-Documents", +#' "master/UTF-8_sequence_unseparated", +#' "utf8_sequence_0-0xff_assigned_printable_unseparated.txt", tmp) +#' ) +#' txt_utf8 <- readLines(tmp) +#' txt_utf8 +#' purge_string(txt_utf8) +#' } #' purge_string <- function(x, replacement = " ") { iconv(gsub(paste0(replacement, "+"), replacement, - gsub("&|=|-|:|\\.|'|\\/|<|>|e0|e9|e8|e7|e6|_|\\(|\\)|\"|\\*|#|€|\\$|\\%", + gsub("&|=|-|:|\\.|'|\\/|<|>|e0|e9|e8|e7|e6|_|\\(|\\)|\"|\\*|#|\u20AC|\\$|\\%", replacement, enc2utf8(x))), from = "UTF-8", diff --git a/man/purge_string.Rd b/man/purge_string.Rd index 5aad2027cc77903871f823f2bfd2ea44c42b1681..267b6aab611c45cfd7f8712dd3d1db6bb7cbcfdf 100644 --- a/man/purge_string.Rd +++ b/man/purge_string.Rd @@ -19,8 +19,14 @@ Purge a string from all accents and special characters } \examples{ \dontrun{ +# Download some funny UTF-8 string tmp <- tempfile() -download.file("https://raw.githubusercontent.com/bits/UTF-8-Unicode-Test-Documents/master/UTF-8_sequence_unseparated/utf8_sequence_0-0xff_assigned_printable_unseparated.txt", tmp) +download.file( + file.path("https://raw.githubusercontent.com", + "bits/UTF-8-Unicode-Test-Documents", + "master/UTF-8_sequence_unseparated", + "utf8_sequence_0-0xff_assigned_printable_unseparated.txt", tmp) +) txt_utf8 <- readLines(tmp) txt_utf8 purge_string(txt_utf8) diff --git a/man/render_reports.Rd b/man/render_reports.Rd index 545932a57d959d997d86d3358a9242ed1e002042..9ccc9a2c126e931624e926b83a8c294d2c2a773c 100644 --- a/man/render_reports.Rd +++ b/man/render_reports.Rd @@ -16,7 +16,7 @@ render_report( render_reports( reports_dir = file.path(pkgload::pkg_path(), "reports"), reports = list.dirs(reports_dir, full.names = FALSE, recursive = FALSE), - publish_dir = "../../public/reports", + publish_dir = file.path(dirname(reports_dir), "public/reports"), ... ) }