From 49728a1ec9de5c4febe5990c1a44073174817043 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Mon, 9 May 2022 17:55:34 +0200 Subject: [PATCH 01/46] add validate_doi() --- NAMESPACE | 1 + R/validate_doi.R | 22 ++++++++++++++++++++++ man/validate_doi.Rd | 23 +++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 R/validate_doi.R create mode 100644 man/validate_doi.Rd diff --git a/NAMESPACE b/NAMESPACE index 3f533fed..bee51a72 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,6 +28,7 @@ export(references) export(render_natbib) export(report) export(slides) +export(validate_doi) importFrom(assertthat,assert_that) importFrom(assertthat,has_name) importFrom(assertthat,is.count) diff --git a/R/validate_doi.R b/R/validate_doi.R new file mode 100644 index 00000000..fe898265 --- /dev/null +++ b/R/validate_doi.R @@ -0,0 +1,22 @@ +#' validate a DOI +#' +#' Checks the format of a DOI. +#' The format must obey https://www.doi.org/doi_handbook/2_Numbering.html#2.2 +#' The DOI should the minimal version. +#' Hence no `doi:`, `https://doi.org` or other prefixes. +#' An example of a minimal version is `10.21436/inbor.70809860`. +#' The part before the forward slash consists of two or three sets of digits +#' separated by a dot. +#' E.g. `10.21436` or `10.21436.1`. +#' The part afther the forward slash consists either of only digits or of +#' two sets of any character separated by a dot. +#' @param doi a string containing the DOI. +#' @export +#' @importFrom assertthat assert_that is.string noNA +validate_doi <- function(doi) { + assert_that(is.string(doi), noNA(doi)) + assert_that( + grepl("^[0-9]+\\.[0-9]+(\\.[0-9]+)?\\/([0-9]+|.*\\..*)$", doi), + msg = "DOI is not a in the correct format. See ?INBOmd::validate_doi" + ) +} diff --git a/man/validate_doi.Rd b/man/validate_doi.Rd new file mode 100644 index 00000000..39954ea1 --- /dev/null +++ b/man/validate_doi.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/validate_doi.R +\name{validate_doi} +\alias{validate_doi} +\title{validate a DOI} +\usage{ +validate_doi(doi) +} +\arguments{ +\item{doi}{a string containing the DOI.} +} +\description{ +Checks the format of a DOI. +The format must obey https://www.doi.org/doi_handbook/2_Numbering.html#2.2 +The DOI should the minimal version. +Hence no \verb{doi:}, \verb{https://doi.org} or other prefixes. +An example of a minimal version is \code{10.21436/inbor.70809860}. +The part before the forward slash consists of two or three sets of digits +separated by a dot. +E.g. \code{10.21436} or \verb{10.21436.1}. +The part afther the forward slash consists either of only digits or of +two sets of any character separated by a dot. +} From 27161a94b09d0cd5a6bb356acf3b6314b834fc04 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Mon, 9 May 2022 18:40:34 +0200 Subject: [PATCH 02/46] pdf_report(), gitbook_() and epub_book() validate the DOI --- R/ebook.R | 1 + R/gitbook.R | 1 + R/pdf_report.R | 1 + 3 files changed, 3 insertions(+) diff --git a/R/ebook.R b/R/ebook.R index d4836a39..fb7e466a 100644 --- a/R/ebook.R +++ b/R/ebook.R @@ -36,6 +36,7 @@ epub_book <- function() { style == "Flanders" || lang == "nl", msg = "Use style: Flanders when the language is not nl" ) + validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1")) pandoc_args <- c( "--csl", diff --git a/R/gitbook.R b/R/gitbook.R index 844f0da8..d3e42be7 100644 --- a/R/gitbook.R +++ b/R/gitbook.R @@ -47,6 +47,7 @@ gitbook <- function() { split_by %in% c("chapter+number", "section+number"), msg = "`split_by` must be either 'chapter+number' or `section+number`" ) + validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1")) pandoc_args <- c( "--csl", diff --git a/R/pdf_report.R b/R/pdf_report.R index 8d74099a..f372dfb9 100644 --- a/R/pdf_report.R +++ b/R/pdf_report.R @@ -63,6 +63,7 @@ pdf_report <- function( paste(sprintf("'%s' (%s)", names(languages), languages), collapse = ", ") ) ) + validate_doi(ifelse(has_name(fm, "doi"), fm$doi, "1.1/1")) template <- system.file( file.path("pandoc", "inbo_rapport.tex"), package = "INBOmd" From a81cdaab58197148cff27e97d313dd6f6b00829a Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Mon, 9 May 2022 18:43:41 +0200 Subject: [PATCH 03/46] bump package version --- .zenodo.json | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ inst/CITATION | 4 ++-- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index 52e2b6e6..63b866ea 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "INBOmd: Markdown Templates for INBO", - "version": "0.5.3", + "version": "0.5.4", "description": "Several templates to generate reports, presentations and posters.", "creators": [ { diff --git a/CITATION.cff b/CITATION.cff index 72c5bdbd..ae22f631 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -11,7 +11,7 @@ contact: - email: info@inbo.be name: Research Institute for Nature and Forest title: 'INBOmd: Markdown Templates for INBO' -version: 0.5.3 +version: 0.5.4 abstract: Several templates to generate reports, presentations and posters. license: GPL-3.0 type: software diff --git a/DESCRIPTION b/DESCRIPTION index 2eb1437e..43f556bf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: INBOmd Title: Markdown Templates for INBO -Version: 0.5.3 +Version: 0.5.4 Authors@R: c( person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8804-4216")), diff --git a/NEWS.md b/NEWS.md index 3c8c7be2..63a5c8af 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# INBOmd 0.5.4 + +* Add `validate_doi()` to validate a DOI. + `pdf_report()`, `gitbook()` and `epub_book()` use this function to validate + the optional DOI when set. + # INBOmd 0.5.3 * Rename `report()` to `pdf_report()` and `epub()` to `epub_book()`. diff --git a/inst/CITATION b/inst/CITATION index 462a6c62..228cfcbc 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -2,12 +2,12 @@ citHeader("To cite `INBOmd` in publications please use:") # begin checklist entry citEntry( entry = "Manual", - title = "INBOmd: Markdown Templates for INBO. Version 0.5.3", + title = "INBOmd: Markdown Templates for INBO. Version 0.5.4", author = c(person(given = "Thierry", family = "Onkelinx")), year = 2022, url = "https://github.com/inbo/inbomd", abstract = "Several templates to generate reports, presentations and posters.", - textVersion = "Onkelinx, Thierry (2022) INBOmd: Markdown Templates for INBO. Version 0.5.3. https://github.com/inbo/inbomd, https://doi.org/10.5281/zenodo.842223", + textVersion = "Onkelinx, Thierry (2022) INBOmd: Markdown Templates for INBO. Version 0.5.4. https://github.com/inbo/inbomd, https://doi.org/10.5281/zenodo.842223", keywords = "R package", doi = "10.5281/zenodo.842223", ) From 855515adfeef7b28603e5349ddd82b285a8131df Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Mon, 9 May 2022 19:52:56 +0200 Subject: [PATCH 04/46] update pkgdown --- R/validate_doi.R | 1 + man/check_dependencies.Rd | 3 ++- man/cover_info.Rd | 3 ++- man/dyn_table.Rd | 3 ++- man/kolom_breedte.Rd | 3 ++- man/kolom_start.Rd | 3 ++- man/references.Rd | 3 ++- man/render_natbib.Rd | 3 ++- man/validate_doi.Rd | 11 +++++++++++ 9 files changed, 26 insertions(+), 7 deletions(-) diff --git a/R/validate_doi.R b/R/validate_doi.R index fe898265..35ecef8b 100644 --- a/R/validate_doi.R +++ b/R/validate_doi.R @@ -11,6 +11,7 @@ #' The part afther the forward slash consists either of only digits or of #' two sets of any character separated by a dot. #' @param doi a string containing the DOI. +#' @family utils #' @export #' @importFrom assertthat assert_that is.string noNA validate_doi <- function(doi) { diff --git a/man/check_dependencies.Rd b/man/check_dependencies.Rd index cb153e59..5091d83c 100644 --- a/man/check_dependencies.Rd +++ b/man/check_dependencies.Rd @@ -18,6 +18,7 @@ Other utils: \code{\link{kolom_breedte}()}, \code{\link{kolom_start}()}, \code{\link{references}()}, -\code{\link{render_natbib}()} +\code{\link{render_natbib}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/cover_info.Rd b/man/cover_info.Rd index 96f8f994..7c51c9e2 100644 --- a/man/cover_info.Rd +++ b/man/cover_info.Rd @@ -23,6 +23,7 @@ Other utils: \code{\link{kolom_breedte}()}, \code{\link{kolom_start}()}, \code{\link{references}()}, -\code{\link{render_natbib}()} +\code{\link{render_natbib}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/dyn_table.Rd b/man/dyn_table.Rd index 726a9662..0d5840c8 100644 --- a/man/dyn_table.Rd +++ b/man/dyn_table.Rd @@ -48,6 +48,7 @@ Other utils: \code{\link{kolom_breedte}()}, \code{\link{kolom_start}()}, \code{\link{references}()}, -\code{\link{render_natbib}()} +\code{\link{render_natbib}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/kolom_breedte.Rd b/man/kolom_breedte.Rd index 2a038bc3..b2a794ef 100644 --- a/man/kolom_breedte.Rd +++ b/man/kolom_breedte.Rd @@ -23,6 +23,7 @@ Other utils: \code{\link{dyn_table}()}, \code{\link{kolom_start}()}, \code{\link{references}()}, -\code{\link{render_natbib}()} +\code{\link{render_natbib}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/kolom_start.Rd b/man/kolom_start.Rd index 2e65407c..66ed9042 100644 --- a/man/kolom_start.Rd +++ b/man/kolom_start.Rd @@ -25,6 +25,7 @@ Other utils: \code{\link{dyn_table}()}, \code{\link{kolom_breedte}()}, \code{\link{references}()}, -\code{\link{render_natbib}()} +\code{\link{render_natbib}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/references.Rd b/man/references.Rd index 89adcd54..e85f9b94 100644 --- a/man/references.Rd +++ b/man/references.Rd @@ -22,6 +22,7 @@ Other utils: \code{\link{dyn_table}()}, \code{\link{kolom_breedte}()}, \code{\link{kolom_start}()}, -\code{\link{render_natbib}()} +\code{\link{render_natbib}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/render_natbib.Rd b/man/render_natbib.Rd index 259b808f..9734ad51 100644 --- a/man/render_natbib.Rd +++ b/man/render_natbib.Rd @@ -42,6 +42,7 @@ Other utils: \code{\link{dyn_table}()}, \code{\link{kolom_breedte}()}, \code{\link{kolom_start}()}, -\code{\link{references}()} +\code{\link{references}()}, +\code{\link{validate_doi}()} } \concept{utils} diff --git a/man/validate_doi.Rd b/man/validate_doi.Rd index 39954ea1..82ae7f95 100644 --- a/man/validate_doi.Rd +++ b/man/validate_doi.Rd @@ -21,3 +21,14 @@ E.g. \code{10.21436} or \verb{10.21436.1}. The part afther the forward slash consists either of only digits or of two sets of any character separated by a dot. } +\seealso{ +Other utils: +\code{\link{check_dependencies}()}, +\code{\link{cover_info}()}, +\code{\link{dyn_table}()}, +\code{\link{kolom_breedte}()}, +\code{\link{kolom_start}()}, +\code{\link{references}()}, +\code{\link{render_natbib}()} +} +\concept{utils} From 53c9ccee5a9be1f4cfdd822e9e397eb794029257 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 5 Jul 2022 14:48:09 +0200 Subject: [PATCH 05/46] fix gitbook edit url --- R/gitbook.R | 2 +- inbomd.Rproj | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/R/gitbook.R b/R/gitbook.R index d3e42be7..805d57d3 100644 --- a/R/gitbook.R +++ b/R/gitbook.R @@ -120,7 +120,7 @@ gitbook_edit_button <- function(path) { return(invisible(FALSE)) } url <- git_remote_info(repo = root)$url - url <- gsub("^.*@", "https://", url) + url <- gsub("^.*@(.*?):", "https://\\1/", url) url <- paste("edit:", gsub("\\.git$", "", url)) url <- file.path( fsep = "/", url, "edit", diff --git a/inbomd.Rproj b/inbomd.Rproj index f86938b3..b067fd56 100644 --- a/inbomd.Rproj +++ b/inbomd.Rproj @@ -17,7 +17,6 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes -PackageCleanBeforeInstall: Yes PackageInstallArgs: --no-multiarch --with-keep.source PackageCheckArgs: --as-cran PackageRoxygenize: rd,collate,namespace From 0e99d1ce473bdd330c0f7559a02c15bfb6a9bbda Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 5 Jul 2022 16:14:27 +0200 Subject: [PATCH 06/46] upgrade to roxygen2 7.2.0 --- DESCRIPTION | 2 +- man/epub_book.Rd | 6 ++++-- man/gitbook.Rd | 6 ++++-- man/handouts.Rd | 6 ++++-- man/pdf_report.Rd | 6 ++++-- man/slides.Rd | 6 ++++-- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 43f556bf..2c4ca03e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -41,4 +41,4 @@ Encoding: UTF-8 Language: en-GB LazyData: true Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.2 +RoxygenNote: 7.2.0 diff --git a/man/epub_book.Rd b/man/epub_book.Rd index 2c678831..7f27c79c 100644 --- a/man/epub_book.Rd +++ b/man/epub_book.Rd @@ -47,11 +47,13 @@ All options going from large to small are: "normalsize", "small", Quotes are required when a part contains spaces. If the author doesn't have an ORCID, you can omit that line. However, note that the INBO policy is that all scientific personnel is -required to obtain an ORCID from https://orcid.org.\preformatted{ - firstname: "Authors first name" +required to obtain an ORCID from https://orcid.org. + +\if{html}{\out{
}}\preformatted{ - firstname: "Authors first name" name: "Authors last name" email: "local-part@domain.com" orcid: 0000-0002-1825-0097 -} +}\if{html}{\out{
}} } \section{Available YAML headers options specific for reports}{ diff --git a/man/gitbook.Rd b/man/gitbook.Rd index 37857a67..e4d27dfd 100644 --- a/man/gitbook.Rd +++ b/man/gitbook.Rd @@ -47,11 +47,13 @@ All options going from large to small are: "normalsize", "small", Quotes are required when a part contains spaces. If the author doesn't have an ORCID, you can omit that line. However, note that the INBO policy is that all scientific personnel is -required to obtain an ORCID from https://orcid.org.\preformatted{ - firstname: "Authors first name" +required to obtain an ORCID from https://orcid.org. + +\if{html}{\out{
}}\preformatted{ - firstname: "Authors first name" name: "Authors last name" email: "local-part@domain.com" orcid: 0000-0002-1825-0097 -} +}\if{html}{\out{
}} } \section{Available YAML headers options specific for reports}{ diff --git a/man/handouts.Rd b/man/handouts.Rd index 3da9db8f..5432f3be 100644 --- a/man/handouts.Rd +++ b/man/handouts.Rd @@ -65,11 +65,13 @@ All options going from large to small are: "normalsize", "small", Quotes are required when a part contains spaces. If the author doesn't have an ORCID, you can omit that line. However, note that the INBO policy is that all scientific personnel is -required to obtain an ORCID from https://orcid.org.\preformatted{ - firstname: "Authors first name" +required to obtain an ORCID from https://orcid.org. + +\if{html}{\out{
}}\preformatted{ - firstname: "Authors first name" name: "Authors last name" email: "local-part@domain.com" orcid: 0000-0002-1825-0097 -} +}\if{html}{\out{
}} } \section{Available YAML headers options specific for slides}{ diff --git a/man/pdf_report.Rd b/man/pdf_report.Rd index 71946e50..4732785b 100644 --- a/man/pdf_report.Rd +++ b/man/pdf_report.Rd @@ -60,11 +60,13 @@ All options going from large to small are: "normalsize", "small", Quotes are required when a part contains spaces. If the author doesn't have an ORCID, you can omit that line. However, note that the INBO policy is that all scientific personnel is -required to obtain an ORCID from https://orcid.org.\preformatted{ - firstname: "Authors first name" +required to obtain an ORCID from https://orcid.org. + +\if{html}{\out{
}}\preformatted{ - firstname: "Authors first name" name: "Authors last name" email: "local-part@domain.com" orcid: 0000-0002-1825-0097 -} +}\if{html}{\out{
}} } \section{Available YAML headers options specific for reports}{ diff --git a/man/slides.Rd b/man/slides.Rd index 42fd2d58..488d3133 100644 --- a/man/slides.Rd +++ b/man/slides.Rd @@ -52,11 +52,13 @@ All options going from large to small are: "normalsize", "small", Quotes are required when a part contains spaces. If the author doesn't have an ORCID, you can omit that line. However, note that the INBO policy is that all scientific personnel is -required to obtain an ORCID from https://orcid.org.\preformatted{ - firstname: "Authors first name" +required to obtain an ORCID from https://orcid.org. + +\if{html}{\out{
}}\preformatted{ - firstname: "Authors first name" name: "Authors last name" email: "local-part@domain.com" orcid: 0000-0002-1825-0097 -} +}\if{html}{\out{
}} } \section{Available YAML headers options specific for slides}{ From eb64c9f378fb01f743c6a64a0dccbe4c9fbcdb97 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 5 Jul 2022 16:14:48 +0200 Subject: [PATCH 07/46] fix DOI url in git_book() format --- inst/template/report_en.epub3 | 4 ++-- inst/template/report_en.html | 8 ++++---- inst/template/report_fr.epub3 | 4 ++-- inst/template/report_fr.html | 8 ++++---- inst/template/report_nl.html | 8 ++++---- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/inst/template/report_en.epub3 b/inst/template/report_en.epub3 index c8155417..94a35abe 100644 --- a/inst/template/report_en.epub3 +++ b/inst/template/report_en.epub3 @@ -65,7 +65,7 @@ $if(titlepage)$

$date$

$endif$ $if(doi)$ -

$doi$

+

$doi$

$endif$ $if(ordernr)$

$ordernr$

@@ -130,7 +130,7 @@ $if(titlepage)$ $endif$ Research Institute for Nature and Forest, Brussels. DOI: $if(doi)$ - $doi$ + $doi$ $else$

!!!! MISSING: doi !!!!

$endif$ diff --git a/inst/template/report_en.html b/inst/template/report_en.html index b20b5d2a..9affe68f 100644 --- a/inst/template/report_en.html +++ b/inst/template/report_en.html @@ -129,7 +129,7 @@

$author$

$date$

$endif$ $if(doi)$ -

$doi$

+

$doi$

$endif$ $if(ordernr)$

$ordernr$

@@ -194,7 +194,7 @@

!!!! MISSING: reportnr !!!!

$endif$ Research Institute for Nature and Forest, Brussels. DOI: $if(doi)$ - $doi$ + $doi$ $else$

!!!! MISSING: doi !!!!

$endif$ @@ -316,7 +316,7 @@

!!!! MISSING: cover_description !!!!

$shortauthor$ ($year$) $title$
$endif$ -$if(doi)$$doi$$endif$ +$if(doi)$$doi$$endif$
Creative Commons-License