From fd9e538ac4f26782a4ad483114a6c6bb0a096556 Mon Sep 17 00:00:00 2001 From: Carlos Martinez Date: Wed, 1 May 2024 23:57:29 +0200 Subject: [PATCH 1/2] Add cff (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Initial test adding cff * Add dummy CFF file * Add citation * Minor typo in display message * Generate documentation --------- Co-authored-by: Carlos Martinez Co-authored-by: Pablo Rodríguez Sánchez --- NAMESPACE | 1 + R/cff.R | 23 +++++++++++++++++++++++ _pkgdown.yml | 1 + inst/templates/CITATION-template.cff | 17 +++++++++++++++++ man/use_cff.Rd | 19 +++++++++++++++++++ tests/testthat/test-cff.R | 5 +++++ 6 files changed, 66 insertions(+) create mode 100644 R/cff.R create mode 100644 inst/templates/CITATION-template.cff create mode 100644 man/use_cff.Rd create mode 100644 tests/testthat/test-cff.R diff --git a/NAMESPACE b/NAMESPACE index 3648d5db7..c8e96ab5b 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -104,6 +104,7 @@ export(use_build_ignore) export(use_c) export(use_cc0_license) export(use_ccby_license) +export(use_cff) export(use_circleci) export(use_circleci_badge) export(use_citation) diff --git a/R/cff.R b/R/cff.R new file mode 100644 index 000000000..a54fc177d --- /dev/null +++ b/R/cff.R @@ -0,0 +1,23 @@ +#' Create Citation File Format +#' +#' `use_cff()` ... +#' +#' @seealso The [data chapter](https://r-pkgs.org/data.html) of [R +#' Packages](https://r-pkgs.org). +#' @export +#' @examples +#' \dontrun{ +#' use_cff() +#' } +use_cff <- function() { + check_is_package() # CM: Other functions start with this, but not sure if I need it + use_template( + "CITATION-template.cff", + "CITATION.cff", + open = TRUE + ) + + ui_bullets(c( + "_" = "Edit `CITATION.cff` (see {.url https://book.the-turing-way.org/communication/citable/citable-cffinit.html} and {.url https://citation-file-format.github.io/cff-initializer-javascript/#/})." + )) +} diff --git a/_pkgdown.yml b/_pkgdown.yml index 11664e0a4..a4cdabfbe 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -60,6 +60,7 @@ reference: - use_test - use_vignette - use_addin + - use_cff - use_citation - use_tutorial - use_author diff --git a/inst/templates/CITATION-template.cff b/inst/templates/CITATION-template.cff new file mode 100644 index 000000000..b32b2fa35 --- /dev/null +++ b/inst/templates/CITATION-template.cff @@ -0,0 +1,17 @@ +# YAML 1.2 +--- +cff-version: "1.2.0" +title: "" +authors: + - + family-names: + given-names: + orcid: "https://orcid.org/0000-0000-0000-0000" +date-released: 20??-MM-DD +doi: +version: "" +repository-code: "" +keywords: + - keyword1 +message: "If you use this software, please cite it using these metadata." +license: diff --git a/man/use_cff.Rd b/man/use_cff.Rd new file mode 100644 index 000000000..77abe0c36 --- /dev/null +++ b/man/use_cff.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cff.R +\name{use_cff} +\alias{use_cff} +\title{Create Citation File Format} +\usage{ +use_cff() +} +\description{ +\code{use_cff()} ... +} +\examples{ +\dontrun{ +use_cff() +} +} +\seealso{ +The \href{https://r-pkgs.org/data.html}{data chapter} of \href{https://r-pkgs.org}{R Packages}. +} diff --git a/tests/testthat/test-cff.R b/tests/testthat/test-cff.R new file mode 100644 index 000000000..78ad62247 --- /dev/null +++ b/tests/testthat/test-cff.R @@ -0,0 +1,5 @@ +test_that("use_cff() creates promised file", { + create_local_package() + use_cff() + expect_proj_file("CITATION.cff") +}) From d6f794e1a130b4d5a5ae70c003fc4f3d3a13b5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Rodr=C3=ADguez=20S=C3=A1nchez?= Date: Tue, 27 Aug 2024 15:00:05 +0200 Subject: [PATCH 2/2] Point to the Turing way docs --- R/cff.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/cff.R b/R/cff.R index a54fc177d..ff5d58aaa 100644 --- a/R/cff.R +++ b/R/cff.R @@ -2,8 +2,7 @@ #' #' `use_cff()` ... #' -#' @seealso The [data chapter](https://r-pkgs.org/data.html) of [R -#' Packages](https://r-pkgs.org). +#' @seealso The Turing way [tutorial on CFF](https://book.the-turing-way.org/communication/citable/citable-cffinit.html). #' @export #' @examples #' \dontrun{