Skip to content

Commit

Permalink
Overhaul of cff-bibtex conversion system (#63)
Browse files Browse the repository at this point in the history
* Start review of article

* Update bibtex to cff

* Prepare crosswalk

* Update vignette

* Finish tables

* Finish article

* Try new test suite

* Full results

* New testing process in GHA

* Finish test new

* Ready to merge

* Roll back action

* Go!
  • Loading branch information
dieghernan authored Feb 13, 2024
1 parent 361a79a commit d568801
Show file tree
Hide file tree
Showing 81 changed files with 2,419 additions and 1,254 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/test-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,34 @@ jobs:
# Check packages not installed yet
instpack <- as.character(installed.packages()[, "Package"])
toinstall <- setdiff(all, instpack)
toinstall_init <- setdiff(all, instpack)
# Install
options(repos = c(
ropensci = "https://ropensci.r-universe.dev",
ropenscireviewtools = "https://ropensci-review-tools.r-universe.dev",
RSPM = "https://packagemanager.rstudio.com/all/latest",
RSPM = "https://packagemanager.posit.co/cran/latest",
CRAN = "https://cloud.r-project.org"
))
message("Installing ", length(toinstall)," packages: ", paste0(toinstall, collapse = ","))
# Check packages available
pakav <- as.data.frame(available.packages(repos = getOption("repos")))
toinstall <- toinstall_init[toinstall_init %in% pakav$Package]
message("Installing ", length(toinstall)," packages")
install.packages(toinstall,
dependencies = TRUE,
verbose = TRUE, quiet = TRUE
dependencies = TRUE, verbose = TRUE,
quiet = TRUE, type = "binary"
)
# Update binary
# update.packages(type = "binary")
shell: Rscript {0}


- name: Test GHA
run: |
# Load package
devtools::load_all()
# Run the tests
testthat::test_dir("tests/testthat/test_ci")
source("tests/testthat/test_ci/test-new.R")
shell: Rscript {0}

Expand All @@ -131,5 +128,5 @@ jobs:
shell: bash
run: |
# OK :)
cat ./tests/testthat/test_ci/_snaps/full_cff.md >$GITHUB_STEP_SUMMARY
cat ./tests/testthat/test_ci/results.md >$GITHUB_STEP_SUMMARY
12 changes: 4 additions & 8 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -----------------------------------------------------------
# CITATION file created with {cffr} R package, v0.5.0
# CITATION file created with {cffr} R package, v0.5.0.9000
# See also: https://docs.ropensci.org/cffr/
# -----------------------------------------------------------

Expand All @@ -8,7 +8,7 @@ message: 'To cite package "cffr" in publications use:'
type: software
license: GPL-3.0-or-later
title: 'cffr: Generate Citation File Format (''cff'') Metadata for R Packages'
version: 0.5.0
version: 0.5.0.9000
doi: 10.21105/joss.03900
abstract: The Citation File Format version 1.2.0 <doi:10.5281/zenodo.5171937> is a
human and machine readable file format which provides citation metadata for software.
Expand Down Expand Up @@ -92,11 +92,10 @@ references:
url: https://www.R-project.org/
authors:
- name: R Core Team
location:
name: Vienna, Austria
year: '2024'
institution:
name: R Foundation for Statistical Computing
address: Vienna, Austria
year: '2024'
version: '>= 3.6.0'
- type: software
title: cli
Expand Down Expand Up @@ -139,9 +138,6 @@ references:
email: [email protected]
orcid: https://orcid.org/0000-0002-4035-0289
year: '2024'
identifiers:
- type: url
value: https://arxiv.org/abs/1403.2805
version: '>= 1.7.2'
- type: software
title: jsonvalidate
Expand Down
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: cffr
Title: Generate Citation File Format ('cff') Metadata for R Packages
Version: 0.5.0
Version: 0.5.0.9000
Authors@R: c(
person("Diego", "Hernangómez", , "[email protected]", role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-8457-4658")),
Expand Down Expand Up @@ -34,6 +34,7 @@ Suggests:
VignetteBuilder:
knitr
Config/testthat/edition: 3
Config/testthat/parallel: true
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export(cff_schema_definitions_person)
export(cff_schema_definitions_refs)
export(cff_schema_keys)
export(cff_schema_keys_license)
export(cff_to_bibentry)
export(cff_to_bibtex)
export(cff_validate)
export(cff_write)
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# cffr (development version)

## Major changes in the API

- The conversion from `cff` to `bibentry` is performed now by a new function
`cff_to_bibentry()`. Previous names of this function were `cff_to_bibtex()`
and `cff_extract_to_bibtex()` that are now superseded.

## Changes on bibtex crosswalk

- **\@inbook** and **\@book** gains a new value on [CFF]{.underline} when
**series** is provided: [collection-type: book-series.]{.underline}
- Review and update `vignette("bibtex_cff", package = "cffr")`.

# cffr 0.5.0

## Lifecycle
Expand Down
14 changes: 7 additions & 7 deletions R/assertions.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Check if a string is an email
#' @param email The string to be evaluated
#' @noRd
is.email <- function(email) {
is_email <- function(email) {
if (is.null(email)) {
return(FALSE)
}
Expand All @@ -17,7 +17,7 @@ is.email <- function(email) {
#' Check if a string is an url
#' @param url The url to be evaluated
#' @noRd
is.url <- function(url) {
is_url <- function(url) {
if (is.null(url)) {
return(FALSE)
}
Expand All @@ -31,7 +31,7 @@ is.url <- function(url) {
#' @param x string
#' @param sub subtring to be evaluated
#' @noRd
is.substring <- function(x, sub) {
is_substring <- function(x, sub) {
if (is.null(x)) {
return(FALSE)
}
Expand All @@ -46,7 +46,7 @@ is.substring <- function(x, sub) {
#' Check if a object is cff
#' @param x object to be evaluated
#' @noRd
is.cff <- function(x) {
is_cff <- function(x) {
if (inherits(x, "cff")) {
return(TRUE)
} else {
Expand All @@ -57,7 +57,7 @@ is.cff <- function(x) {
#' Check if a object is cff file
#' @param x object to be evaluated
#' @noRd
is.cff_file <- function(x) {
is_cff_file <- function(x) {
if (!inherits(x, "character")) {
return(FALSE)
}
Expand All @@ -73,7 +73,7 @@ is.cff_file <- function(x) {
#' Check if a object is cff
#' @param x object to be evaluated
#' @noRd
is.github <- function(x) {
is_github <- function(x) {
res <- isTRUE(grep(
"^http[a-z]://github.com/",
x["repository-code"]
Expand All @@ -86,7 +86,7 @@ is.github <- function(x) {
#' @param x file to be evaluated
#' @noRd
stopifnotcff <- function(x) {
if (is.cff(x)) {
if (is_cff(x)) {
return(invisible())
}

Expand Down
12 changes: 12 additions & 0 deletions R/cff-class.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' The `cff` class
#'
#' @name cff-class
#'
#' @description
#' TODO
#'
#' @keywords internal
#'
#'
#'
NULL
6 changes: 3 additions & 3 deletions R/cff_create.R
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ cff_create <- function(x,
# On missing use package root
if (missing(x)) x <- getwd()

if (!is.cff(x) && !is.character(x)) {
if (!is_cff(x) && !is.character(x)) {
msg <- "{.arg x} should be a {.cls cff} or {.cls character} object."
cli::cli_abort(msg)
}
Expand All @@ -129,7 +129,7 @@ cff_create <- function(x,
desc_path <- NULL

# Paths
if (is.cff(x)) {
if (is_cff(x)) {
# It is already an object
cffobj <- x
cffobj["cff-version"] <- cff_version
Expand Down Expand Up @@ -163,7 +163,7 @@ cff_create <- function(x,
msg <- paste0(
"{.arg x} ({x}) not valid. If it is a package ",
"you may need to install it with ",
"{.fun install.packages}"
"{.fn install.packages}"
)
cli::cli_abort(msg)
}
Expand Down
3 changes: 2 additions & 1 deletion R/cff_gha_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
#' @details
#'
#' Triggers on your action can be modified, see
#' [Events that trigger workflows](https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows).
#' [Events that trigger
#' workflows](https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows).

Check warning on line 20 in R/cff_gha_update.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_gha_update.R,line=20,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 101 characters.

Check warning on line 20 in R/cff_gha_update.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_gha_update.R,line=20,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 101 characters.

Check warning on line 20 in R/cff_gha_update.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_gha_update.R,line=20,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 101 characters.

Check warning on line 20 in R/cff_gha_update.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_gha_update.R,line=20,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 101 characters.
#'
#' @examples
#' \dontrun{
Expand Down
3 changes: 2 additions & 1 deletion R/cff_git_hook.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#' @description
#'
#' Install a
#' [pre-commit hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks)
#' [pre-commit
#' hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks#_committing_workflow_hooks)

Check warning on line 7 in R/cff_git_hook.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_git_hook.R,line=7,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.

Check warning on line 7 in R/cff_git_hook.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_git_hook.R,line=7,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.

Check warning on line 7 in R/cff_git_hook.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_git_hook.R,line=7,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.

Check warning on line 7 in R/cff_git_hook.R

View workflow job for this annotation

GitHub Actions / Run lintr scanning

file=R/cff_git_hook.R,line=7,col=81,[line_length_linter] Lines should not be more than 80 characters. This line is 93 characters.
#' that remembers you to update your `CITATION.cff` file.
#'
#' @name cff_git_hook
Expand Down
Loading

0 comments on commit d568801

Please sign in to comment.