From a8ed6a021d7b6a251fcb9fd00ade4555f968fd00 Mon Sep 17 00:00:00 2001
From: David Dorchies <david.dorchies@inrae.fr>
Date: Tue, 27 Feb 2024 16:48:39 +0100
Subject: [PATCH] fix: remove warnings and notes at Rcheck

- extra folder .devcontainer
- non ascii characters
- remaining folder public after check
---
 .Rbuildignore         |  1 +
 R/render_report.R     |  3 ---
 R/render_reports.R    |  2 +-
 R/utils.R             | 16 ++++++++++++++--
 man/purge_string.Rd   |  8 +++++++-
 man/render_reports.Rd |  2 +-
 6 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/.Rbuildignore b/.Rbuildignore
index 179f6c2..2610bc2 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 e62d237..a80b316 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 dbf8fc2..62011a1 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 37297ac..f4865bc 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 5aad202..267b6aa 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 545932a..9ccc9a2 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"),
   ...
 )
 }
-- 
GitLab