diff --git a/.github/workflows/test-ci.yaml b/.github/workflows/test-ci.yaml index 7ec4d6a1..881ef265 100644 --- a/.github/workflows/test-ci.yaml +++ b/.github/workflows/test-ci.yaml @@ -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} @@ -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 diff --git a/CITATION.cff b/CITATION.cff index c7d66878..ae2c7213 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -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/ # ----------------------------------------------------------- @@ -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 is a human and machine readable file format which provides citation metadata for software. @@ -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 @@ -139,9 +138,6 @@ references: email: jeroen@berkeley.edu 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 diff --git a/DESCRIPTION b/DESCRIPTION index a1337671..b3eae1d3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -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", , "diego.hernangomezherrero@gmail.com", role = c("aut", "cre", "cph"), comment = c(ORCID = "0000-0001-8457-4658")), @@ -34,6 +34,7 @@ Suggests: VignetteBuilder: knitr Config/testthat/edition: 3 +Config/testthat/parallel: true Encoding: UTF-8 LazyData: true Roxygen: list(markdown = TRUE) diff --git a/NAMESPACE b/NAMESPACE index d370f864..16d8f1c6 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -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) diff --git a/NEWS.md b/NEWS.md index 21bb148f..fe67541a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/assertions.R b/R/assertions.R index 17ac7038..d703d6f5 100644 --- a/R/assertions.R +++ b/R/assertions.R @@ -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) } @@ -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) } @@ -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) } @@ -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 { @@ -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) } @@ -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"] @@ -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()) } diff --git a/R/cff-class.R b/R/cff-class.R new file mode 100644 index 00000000..87b0d599 --- /dev/null +++ b/R/cff-class.R @@ -0,0 +1,12 @@ +#' The `cff` class +#' +#' @name cff-class +#' +#' @description +#' TODO +#' +#' @keywords internal +#' +#' +#' +NULL diff --git a/R/cff_create.R b/R/cff_create.R index b11bd6f3..ddb05320 100644 --- a/R/cff_create.R +++ b/R/cff_create.R @@ -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) } @@ -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 @@ -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) } diff --git a/R/cff_gha_update.R b/R/cff_gha_update.R index 00b33f76..5a066074 100644 --- a/R/cff_gha_update.R +++ b/R/cff_gha_update.R @@ -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). #' #' @examples #' \dontrun{ diff --git a/R/cff_git_hook.R b/R/cff_git_hook.R index 3b675cb4..0c54797b 100644 --- a/R/cff_git_hook.R +++ b/R/cff_git_hook.R @@ -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) #' that remembers you to update your `CITATION.cff` file. #' #' @name cff_git_hook diff --git a/R/cff_parse_citation.R b/R/cff_parse_citation.R index 9001c63f..c7fccc55 100644 --- a/R/cff_parse_citation.R +++ b/R/cff_parse_citation.R @@ -86,11 +86,9 @@ cff_parse_citation <- function(bib) { } # Parse BibTeX entry ---- - parse_cit <- parse_bibtex_entry(bib) ## If no title (case of some Misc) then return null - if (!("title" %in% names(parse_cit))) { entry <- capture.output(print(bib, bibtex = FALSE)) entry <- as.character(entry) @@ -100,29 +98,34 @@ cff_parse_citation <- function(bib) { return(NULL) } - # Parse BibTeX fields ---- parsed_fields <- parse_bibtex_fields(parse_cit) + ## Handle collection types ---- + parsed_fields <- add_bibtex_coltype(parsed_fields) + + ## Add conference + parsed_fields <- add_conference(parsed_fields) + + # Create BibTeX to CFF institution logic ---- + parsed_fields <- parse_bibtex_to_inst(parsed_fields) - # Create BibTeX person models ---- - parsed_fields <- parse_bibtex_person_models(parsed_fields) # Parse persons ---- # Special case: authors # Some keys does not strictly require authors, so we create one for cff - # https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#how-to-deal-with-unknown-individual-authors + # https://github.com/citation-file-format/citation-file-format/blob/main/ + # (cont) schema-guide.md#how-to-deal-with-unknown-individual-authors + if (is.null(parsed_fields$authors)) { parsed_fields$authors <- person(family = "anonymous") } - ## authors ---- parse_all_authors <- drop_null( lapply(parsed_fields$authors, cff_parse_person) ) parsed_fields$authors <- unique(parse_all_authors) - ## other persons---- parse_other_persons <- building_other_persons(parsed_fields) @@ -136,19 +139,8 @@ cff_parse_citation <- function(bib) { # Building blocks---- - # Fallback for year and month: use date-published - - if (is.null(parse_cit$month) && !is.null(parse_cit$`date-published`)) { - parse_cit$month <- format(as.Date(parse_cit$`date-published`), "%m") - } - - - if (is.null(parse_cit$year) && !is.null(parse_cit$`date-published`)) { - parse_cit$year <- format(as.Date(parse_cit$`date-published`), "%Y") - } - - ## month ---- - parse_cit$month <- building_month(parse_cit) + # Fallback for year and month: use date-published ---- + parse_cit <- fallback_dates(parse_cit) ## doi---- bb_doi <- building_doi(parse_cit) @@ -171,8 +163,14 @@ cff_parse_citation <- function(bib) { ) } + ## Add thesis type ---- + parse_cit <- add_thesis(parse_cit) - # Last step: Field models---- + ## Handle location ---- + parse_cit <- add_address(parse_cit) + + + # Last step---- # Initial order but starting with type, title, authors final_order <- unique(c( @@ -183,9 +181,6 @@ cff_parse_citation <- function(bib) { parse_cit <- parse_cit[final_order] - parse_cit <- parse_bibtex_fields_models(parse_cit) - - # Remove non-valid names validnames <- cff_schema_definitions_refs() parse_cit <- parse_cit[names(parse_cit) %in% validnames] @@ -231,6 +226,14 @@ parse_bibtex_entry <- function(bib) { ) + # Check if it an inbook with booktitle (BibLaTeX style) + if (all(init_type == "inbook", "booktitle" %in% names(parse_cit))) { + # Make it incollection + parse_cit$bibtex_entry <- "incollection" + parse_cit$type <- "generic" + } + + return(parse_cit) } @@ -239,7 +242,6 @@ parse_bibtex_entry <- function(bib) { parse_bibtex_fields <- function(parse_cit) { # to lowercase names(parse_cit) <- tolower(names(parse_cit)) - nm <- names(parse_cit) # Standard BibTeX fields: # address annote author booktitle chapter crossref edition editor @@ -250,10 +252,15 @@ parse_bibtex_fields <- function(parse_cit) { # edition journal month publisher title volume year # Mapped: - # author booktitle chapter editor howpublished note number + # author booktitle series chapter editor howpublished note number nm[nm == "author"] <- "authors" + # Make collection title + # booktitle takes precedence over series nm[nm == "booktitle"] <- "collection-title" + if (!"collection-title" %in% nm) { + nm[nm == "series"] <- "collection-title" + } nm[nm == "chapter"] <- "section" nm[nm == "editor"] <- "editors" nm[nm == "howpublished"] <- "medium" @@ -274,8 +281,6 @@ parse_bibtex_fields <- function(parse_cit) { # abstract, doi, isbn, issn, url, version - cff_schema_definitions_refs() - # Keywords may be duplicated, unify if ("keywords" %in% nm) { kwords <- unlist(parse_cit["keywords" == nm]) @@ -284,12 +289,11 @@ parse_bibtex_fields <- function(parse_cit) { parse_cit$keywords <- unique(kwords) } - # Not mapped: # annote crossref key organization series type # - # Fields address, organization, series and type already treated on - # parse_bibtex_for_cff()/main function + # Fields address, organization, series and type are treated on + # main function # key is a special field, treated apart # Fields ignored: annote, crossref @@ -354,76 +358,139 @@ parse_bibtex_fields <- function(parse_cit) { #' Modify mapping of some org. fields on BibTeX to CFF #' @noRd -parse_bibtex_person_models <- function(parsed_fields) { - # Manual - if (parsed_fields$bibtex_entry == "manual") { - parsed_fields$institution <- parsed_fields$organization - } else if (parsed_fields$bibtex_entry %in% c( - "conference", "inproceedings", - "proceedings" - )) { - # Conference, InProceedings, Proceedings - if (!is.null(parsed_fields$series)) { - parsed_fields$conference <- person(family = parsed_fields$series) - } - if (!is.null(parsed_fields$organization)) { - parsed_fields$institution <- person(family = parsed_fields$organization) - } - } else if (parsed_fields$bibtex_entry %in% c("mastersthesis", "phdthesis")) { - # Mastersthesis, PhdThesis - parsed_fields$institution <- person(family = parsed_fields$school) +parse_bibtex_to_inst <- function(parsed_fields) { + # Initial values + bibtex_entry <- parsed_fields$bibtex_entry + to_replace <- switch(bibtex_entry, + "mastersthesis" = "school", + "phdthesis" = "school", + "conference" = "organization", + "inproceedings" = "organization", + "manual" = "organization", + "proceedings" = "organization", + "institution" + ) + + if (to_replace == "institution") { + return(parsed_fields) } + # Rest of cases remove bibtex institution and rename + nms <- names(parsed_fields) + + parsed_fields <- parsed_fields["institution" != nms] + + # Rename + nms2 <- names(parsed_fields) + nms2[nms2 == to_replace] <- "institution" + names(parsed_fields) <- nms2 + + parsed_fields +} + +add_conference <- function(parsed_fields) { + bibtex_entry <- parsed_fields$bibtex_entry + + if (bibtex_entry %in% c("conference", "inproceedings", "proceedings")) { + parsed_fields$conference <- parsed_fields$`collection-title` + } return(parsed_fields) } + + #' Adapt cff keys to bibtex entries #' @noRd -parse_bibtex_fields_models <- function(parse_cit) { - # thesis type ---- - if (parse_cit$bibtex_entry %in% c("phdthesis", "mastersthesis")) { - parse_cit$`thesis-type` <- switch(parse_cit$bibtex_entry, - phdthesis = "PhD Thesis", - "Master's Thesis" - ) +add_thesis <- function(parse_cit) { + bibtex_entry <- parse_cit$bibtex_entry + if (!bibtex_entry %in% c("phdthesis", "mastersthesis")) { + return(parse_cit) } - # address---- - - if (!is.null(parse_cit$location)) { - # Usually the address of the publisher as per BibTeX - if (!is.null(parse_cit$publisher) && - !(parse_cit$bibtex_entry %in% c( - "conference", "inproceedings", - "proceedings" - ))) { - parse_cit$publisher$address <- parse_cit$location$name - parse_cit$location <- NULL - } + parse_cit$`thesis-type` <- switch(bibtex_entry, + phdthesis = "PhD Thesis", + "Master's Thesis" + ) - parse_cit$conference + parse_cit +} - # If this is a conference then add to conference - if (!is.null(parse_cit$conference)) { - parse_cit$conference$address <- parse_cit$location$name - } +add_address <- function(parse_cit) { + loc <- parse_cit$location$name + # If available + if (is.null(loc)) { + return(parse_cit) + } - # If is a report or a thesis, add to institution - if (parse_cit$bibtex_entry %in% c( - "techreport", - "phdthesis", "mastersthesis" - ) && - !is.null(parse_cit$institution)) { - parse_cit$institution$address <- parse_cit$location$name - parse_cit$location <- NULL - } + # At this point is in location, see to move + + # Logic order. + # 1. To conference + # 2. To institution + # 3. To publisher + # Otherwise leave on location + + nms <- names(parse_cit) + has_conf <- "conference" %in% nms + has_inst <- "institution" %in% nms + has_publish <- "publisher" %in% nms + + if (!any(has_conf, has_inst, has_publish)) { + return(parse_cit) + } + + if (has_conf) { + parse_cit$conference$address <- loc + parse_cit$location <- NULL + } else if (has_inst) { + parse_cit$institution$address <- loc + parse_cit$location <- NULL + } else { + parse_cit$publisher$address <- loc + parse_cit$location <- NULL + } + + return(parse_cit) +} + +add_bibtex_coltype <- function(parsed_fields) { + # Add collection-type if applicable and rearrange fields + nms <- names(parsed_fields) + + if (!"collection-title" %in% nms) { + return(parsed_fields) + } + + # Made collection-type if we create collection-title + bibtex_type <- parsed_fields$bibtex_entry + + # Remove `in` at init: inbook, incollection affected + coltype <- clean_str(gsub("^in", "", bibtex_type)) + parsed_fields$`collection-type` <- coltype + + # Rearrange to make both collection keys together + nm_first <- nms[seq(1, match("collection-title", nms))] + + nms_end <- unique(c(nm_first, "collection-type", nms)) + + parsed_fields <- parsed_fields[nms_end] + + return(parsed_fields) +} + +fallback_dates <- function(parse_cit) { + # Fallback for year and month: use date-published + if (is.null(parse_cit$month) && !is.null(parse_cit$`date-published`)) { + parse_cit$month <- format(as.Date(parse_cit$`date-published`), "%m") } - # Book, InBook: collection-title. Use series field - if (parse_cit$bibtex_entry %in% c("book", "inbook")) { - parse_cit$`collection-title` <- clean_str(parse_cit$series) + if (is.null(parse_cit$year) && !is.null(parse_cit$`date-published`)) { + parse_cit$year <- format(as.Date(parse_cit$`date-published`), "%Y") } + ## month ---- + parse_cit$month <- building_month(parse_cit) + return(parse_cit) } diff --git a/R/cff_parse_person.R b/R/cff_parse_person.R index 74b7ba92..a19d87e2 100644 --- a/R/cff_parse_person.R +++ b/R/cff_parse_person.R @@ -60,6 +60,10 @@ cff_parse_person <- function(person) { person <- as.person(person) + if (length(person) == 0) { + return(NULL) + } + if (length(person) > 1) { person <- lapply(person, cff_parse_person) class(person) <- "cff" @@ -68,7 +72,7 @@ cff_parse_person <- function(person) { # Special case for Bioconductor - if (is.substring(person$given, "Bioconductor")) { + if (is_substring(person$given, "Bioconductor")) { person <- person( given = paste( clean_str(person$given), @@ -81,11 +85,9 @@ cff_parse_person <- function(person) { } # Special case for R Core Team - - if (all( - is.substring(clean_str(person$given), "R Core"), - is.substring(person$family, "Team") + is_substring(clean_str(person$given), "R Core"), + is_substring(person$family, "Team") )) { person <- person( given = paste( @@ -112,7 +114,7 @@ cff_parse_person <- function(person) { } # Check if several mails (MomTrunc 6.0) - valid_emails <- unlist(lapply(person$email, is.email)) + valid_emails <- unlist(lapply(person$email, is_email)) email <- person$email[valid_emails][1] parsed_person$email <- clean_str(email) @@ -145,7 +147,7 @@ cff_parse_person <- function(person) { web <- parsed_comments$website if (!is.null(web)) { - parsed_comments$website <- clean_str(web[is.url(web)]) + parsed_comments$website <- clean_str(web[is_url(web)]) } # Add comments diff --git a/R/cff_read.R b/R/cff_read.R index 38ad7880..d2c8433f 100644 --- a/R/cff_read.R +++ b/R/cff_read.R @@ -79,7 +79,7 @@ cff_read <- function(path) { #' @rdname cff_read #' @export cff <- function(path, ...) { - if (!missing(path) && is.cff(path)) { + if (!missing(path) && is_cff(path)) { return(path) } @@ -131,7 +131,7 @@ cff <- function(path, ...) { #' # Nice display thanks to yaml package #' cffobj as.cff <- function(x) { - if (is.cff(x)) { + if (is_cff(x)) { return(x) } diff --git a/R/cff_to_bibtex.R b/R/cff_to_bibentry.R similarity index 89% rename from R/cff_to_bibtex.R rename to R/cff_to_bibentry.R index d4555872..c44fe704 100644 --- a/R/cff_to_bibtex.R +++ b/R/cff_to_bibentry.R @@ -2,12 +2,15 @@ #' #' @description #' -#' This function creates BibTeX entries (in the form of [bibentry()] objects +#' This function creates [bibentry()] objects #' from different metadata sources (`cff` objects, `DESCRIPTION` files, etc.). -#' The function tries to parse the information of the source `x` into a `cff` +#' The function tries to map the information of the source `x` into a `cff` #' object and performs a mapping of the metadata to BibTeX, according to #' `vignette("bibtex_cff", "cffr")`. #' +#' Note that a **R** [bibentry()] object is the representation of a BibTeX +#' entry, see **Examples**. +#' #' #' @references #' - Patashnik, Oren. "BIBTEXTING" February 1988. @@ -18,7 +21,7 @@ #' \doi{10.5281/zenodo.1184077}. #' #' - Hernangómez D (2022). "BibTeX and CFF, a potential crosswalk." -#' *The cffr package, Vignettes* +#' *The cffr package, Vignettes*. \doi{10.21105/joss.03900}, #' . #' #' @param x The source that would be used for generating @@ -42,8 +45,8 @@ #' be parsed to BibTeX using [toBibtex()] #' #' @export -#' @name cff_to_bibtex -#' @rdname cff_to_bibtex +#' @name cff_to_bibentry +#' @rdname cff_to_bibentry #' #' @examples #' \donttest{ @@ -53,7 +56,7 @@ #' cff_object #' #' # bibentry object -#' bib <- cff_to_bibtex(cff_object) +#' bib <- cff_to_bibentry(cff_object) #' #' class(bib) #' @@ -66,13 +69,13 @@ #' # From a CITATION.cff file with options #' #' path <- system.file("examples/CITATION_complete.cff", package = "cffr") -#' cff_file <- cff_to_bibtex(path, what = "all") +#' cff_file <- cff_to_bibentry(path, what = "all") #' #' toBibtex(cff_file) #' #' # For an installed package #' -#' installed_package <- cff_to_bibtex("jsonvalidate") +#' installed_package <- cff_to_bibentry("jsonvalidate") #' #' toBibtex(installed_package) #' @@ -80,22 +83,22 @@ #' # Use a DESCRIPTION file #' #' path2 <- system.file("examples/DESCRIPTION_gitlab", package = "cffr") -#' desc_file <- cff_to_bibtex(path2) +#' desc_file <- cff_to_bibentry(path2) #' #' toBibtex(desc_file) #' } -cff_to_bibtex <- function(x, - what = c("preferred", "references", "all")) { +cff_to_bibentry <- function(x, + what = c("preferred", "references", "all")) { what <- match.arg(what) if (is.null(x)) { return(NULL) } - if (is.cff_file(x)) { + if (is_cff_file(x)) { x <- cff_read(x) } - if (is.cff(x)) { + if (is_cff(x)) { obj <- x } else { obj <- cff_create(x) @@ -125,9 +128,9 @@ cff_to_bibtex <- function(x, } #' @export -#' @rdname cff_to_bibtex +#' @rdname cff_to_bibentry #' @usage NULL -cff_extract_to_bibtex <- cff_to_bibtex +cff_to_bibtex <- cff_to_bibentry cff_bibtex_parser <- function(x) { if (is.null(x)) { @@ -137,11 +140,10 @@ cff_bibtex_parser <- function(x) { stopifnotcff(x) # Read cff of CITATION.cff file - if (!is.cff(x)) { + if (!is_cff(x)) { x <- cff(x) } - # Try to generate preferred if not present if (!("preferred-citation" %in% names(x))) { origtype <- clean_str(x$type) @@ -197,7 +199,7 @@ cff_bibtex_parser <- function(x) { if (all( tobibentry$bibtype == "misc", !is.null(x$`collection-title`), - !is.null(x$publisher) + !is.null(x$publisher), !is.null(x$year) )) { tobibentry$bibtype <- "incollection" } @@ -206,10 +208,10 @@ cff_bibtex_parser <- function(x) { # address---- # BibTeX 'address' is taken from the publisher (book, others) or the # conference (inproceedings). - - if (tobibentry$bibtype %in% c("proceedings", "inproceedings")) { + # Set logic: conference > institution > publisher + if (!is.null(x$conference)) { addr_search <- x$conference - } else if (tobibentry$bibtype == "techreport") { + } else if (!is.null(x$institution)) { addr_search <- x$institution } else { addr_search <- x$publisher @@ -380,6 +382,11 @@ cff_bibtex_parser <- function(x) { # note ---- tobibentry$note <- x$notes + # unpublished needs a note + if (all(is.null(x$notes), tobibentry$bibtype == "unpublished")) { + tobibentry$note <- "Extracted with cffr R package" + } + # number---- @@ -403,18 +410,10 @@ cff_bibtex_parser <- function(x) { # series---- - if (tobibentry$bibtype %in% c( - "book", "inbook" - )) { + if (is.null(tobibentry$booktitle)) { tobibentry$series <- x$`collection-title` } - if (tobibentry$bibtype %in% c( - "proceedings", "inproceedings" - )) { - tobibentry$series <- x$conference$name - } - # title ---- tobibentry$title <- x$title @@ -520,8 +519,17 @@ cff_bibtex_parser <- function(x) { sorted <- unique[unique %in% names(tobibentry)] tobibentry <- tobibentry[sorted] - bib <- do.call(bibentry, tobibentry) + # Shouldn't happen but just in case + # nocov start + if (inherits(bib, "try-error")) { + message <- attributes(bib)$condition$message + cli::cli_alert_danger(paste("Can't convert to {.fn bibentry}: ", message)) + cli::cli_alert_info("Returning {.val NULL}") + return(NULL) + } + # nocov end + return(bib) } diff --git a/R/cff_validate.R b/R/cff_validate.R index 75d9dd9c..ceaa3110 100644 --- a/R/cff_validate.R +++ b/R/cff_validate.R @@ -58,7 +58,7 @@ #' try(cff_validate(system.file("CITATION", package = "cffr"))) cff_validate <- function(x = "CITATION.cff", verbose = TRUE) { # If is a cff create the object - if (is.cff(x)) { + if (is_cff(x)) { tmpfile <- tempfile(fileext = ".cff") suppressMessages(yaml::write_yaml(x, tmpfile)) path <- tmpfile diff --git a/R/cff_write.R b/R/cff_write.R index 031f2580..31865a61 100644 --- a/R/cff_write.R +++ b/R/cff_write.R @@ -84,7 +84,7 @@ cff_write <- function(x, # Fix string if it is not cff - if (!is.substring(outfile, ".cff$")) outfile <- paste0(outfile, ".cff") + if (!is_substring(outfile, ".cff$")) outfile <- paste0(outfile, ".cff") # Check if dir exist and if not create outdir <- dirname(outfile) @@ -122,7 +122,7 @@ cff_write <- function(x, } # Add CITATION.cff to .Rbuildignore - if (!is.cff(x) && x == getwd() && file.exists(".Rbuildignore")) { + if (!is_cff(x) && x == getwd() && file.exists(".Rbuildignore")) { ignore <- readLines(".Rbuildignore") # If not already diff --git a/R/deprecated.R b/R/deprecated.R new file mode 100644 index 00000000..07b26ba9 --- /dev/null +++ b/R/deprecated.R @@ -0,0 +1,32 @@ +#' Previous API: Create BibTeX entries from several sources +#' +#' @description +#' `r lifecycle::badge('superseded')` +#' Please use [cff_to_bibentry()] instead. +#' +#' @rdname previous_cff_to_bib +#' @inheritParams cff_to_bibentry +#' @export +#' @keywords internal +#' +#' @return See [cff_to_bibentry()] +#' @examples +#' \donttest{ +#' # From a cff object +#' cff_object <- cff() +#' +#' cff_object +#' +#' # bibentry object +#' bib <- cff_to_bibentry(cff_object) +#' } +cff_extract_to_bibtex <- function(x, + what = c("preferred", "references", "all")) { + if (requireNamespace("lifecycle", quietly = TRUE)) { + lifecycle::deprecate_soft( + "0.5.0", "cff_extract_to_bibtex()", + "cff_to_bibentry()" + ) + } + cff_to_bibentry(x, what) +} diff --git a/R/parse_citation.R b/R/parse_citation.R index 02bfc071..87d0d65b 100644 --- a/R/parse_citation.R +++ b/R/parse_citation.R @@ -132,7 +132,7 @@ building_url <- function(parse_cit) { allurls <- parse_cit$url } - allurls <- allurls[is.url(allurls)] + allurls <- allurls[is_url(allurls)] # The first url goes to url key url <- unlist(allurls[1]) diff --git a/R/parse_description.R b/R/parse_description.R index 7997e4ae..d26b4e51 100644 --- a/R/parse_description.R +++ b/R/parse_description.R @@ -146,7 +146,7 @@ parse_desc_repository <- function(pkg) { repo <- clean_str(pkg$get("Repository")) # Repo is url - if (is.url(repo)) { + if (is_url(repo)) { return(repo) } @@ -160,7 +160,7 @@ parse_desc_repository <- function(pkg) { # Repo is CRAN # Canonic url to CRAN - if (is.substring(repo, "^CRAN$")) { + if (is_substring(repo, "^CRAN$")) { return( paste0("https://CRAN.R-project.org/package=", name) ) @@ -206,7 +206,7 @@ parse_desc_urls <- function(pkg) { # Join issues and urls allurls <- unique(c(issues, url)) - allurls <- allurls[is.url(allurls)] + allurls <- allurls[is_url(allurls)] @@ -279,7 +279,7 @@ parse_desc_version <- function(pkg) { #' @noRd parse_ghtopics <- function(x) { # Only for GitHub repos - if (!is.github(x)) { + if (!is_github(x)) { return(NULL) } diff --git a/R/utils.R b/R/utils.R index 225a6c6d..2b6e07e4 100644 --- a/R/utils.R +++ b/R/utils.R @@ -91,10 +91,12 @@ search_on_repos <- function(name, detect_repos <- function(repos = getOption("repos")) { # Not use RSPM repos <- repos[names(repos) != "RSPM"] - repos <- repos[!grepl("//rspm", repos)] + repos <- repos[!grepl("rspm", repos)] + repos <- repos[!grepl("posit", repos)] + repos <- repos[!grepl("rstudio", repos)] # If not set use 0-Cloud - if (!is.url(repos["CRAN"])) { + if (!is_url(repos["CRAN"])) { repos["CRAN"] <- "https://cloud.r-project.org/" } diff --git a/R/write_bib.R b/R/write_bib.R index 983d586c..7623cfde 100644 --- a/R/write_bib.R +++ b/R/write_bib.R @@ -3,7 +3,7 @@ #' Creates `a .bib` file from a `bibentry` object(s) #' #' @param x A `bibentry` object created with: -#' - [cff_to_bibtex()] +#' - [cff_to_bibentry()] #' - [citation()] or [bibentry()] #' #' @param file Name of the file. If `NULL` it would display the lines to be diff --git a/R/write_citation.R b/R/write_citation.R index 2ba3239d..36f3f0a4 100644 --- a/R/write_citation.R +++ b/R/write_citation.R @@ -6,9 +6,9 @@ #' CITATION.cff file or `cff` object. #' #' @param x It could be -#' - A `bibentry` object created with [cff_to_bibtex()], [citation()] or +#' - A `bibentry` object created with [cff_to_bibentry()], [citation()] or #' [bibentry()] -#' - Any of the valid inputs of [cff_to_bibtex()]: +#' - Any of the valid inputs of [cff_to_bibentry()]: #' * A missing value. That would retrieve the DESCRIPTION file on your #' in-development package. #' * An existing [`cff`] object, @@ -17,7 +17,7 @@ #' * Path to a DESCRIPTION file (`"*/DESCRIPTION*"`). #' @param file Name of the file to write. #' @inheritParams write_bib -#' @inheritDotParams cff_to_bibtex +#' @inheritDotParams cff_to_bibentry #' #' @export #' @family BibTeX helpers @@ -66,7 +66,7 @@ write_citation <- function(x, verbose = TRUE, ...) { if (!inherits(x, "bibentry")) { - x <- cff_to_bibtex(x, ...) + x <- cff_to_bibentry(x, ...) } bentr <- format(x, style = "R") diff --git a/README.Rmd b/README.Rmd index f6cf504d..09167f48 100644 --- a/README.Rmd +++ b/README.Rmd @@ -15,8 +15,7 @@ knitr::opts_chunk$set( ) ``` -# cffr - +# cffr cffr website [![CRAN-status](https://www.r-pkg.org/badges/version/cffr)](https://CRAN.R-project.org/package=cffr) @@ -197,7 +196,7 @@ We can validate the result using `cff_validate()`: cff_validate(test) ``` -Check the [docs](https://docs.ropensci.org/cffr/reference/index.html) and +Check the [docs](https://docs.ropensci.org/cffr//reference/index.html) and `vignette("cffr", package = "cffr")` to learn how to work with `cff` objects. ### Keep your `CITATION.cff` file up-to-date diff --git a/README.md b/README.md index 7102a86a..b87bcf35 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -# cffr +# cffr cffr website @@ -72,7 +72,7 @@ file and the `CITATION` file (if present) of your package. Note that **cffr** works best if your package pass `R CMD check/devtools::check()`. -As per 2024-02-06 there are at least 235 repos on GitHub using **cffr**. +As per 2024-02-13 there are at least 235 repos on GitHub using **cffr**. [Check them out here](https://github.com/search?q=cffr%20path%3A**%2FCITATION.cff&type=code). @@ -276,11 +276,10 @@ test <- cff_create("rmarkdown") 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.0' - type: software title: bslib @@ -386,9 +385,6 @@ test <- cff_create("rmarkdown") email: jeroen@berkeley.edu orcid: https://orcid.org/0000-0002-4035-0289 year: '2024' - identifiers: - - type: url - value: https://arxiv.org/abs/1403.2805 - type: software title: knitr abstract: 'knitr: A General-Purpose Package for Dynamic Report Generation in R' @@ -408,11 +404,10 @@ test <- cff_create("rmarkdown") notes: Imports authors: - name: R Core Team - location: - name: Vienna, Austria - year: '2024' institution: name: R Foundation for Statistical Computing + address: Vienna, Austria + year: '2024' - type: software title: stringr abstract: 'stringr: Simple, Consistent Wrappers for Common String Operations' @@ -445,22 +440,20 @@ test <- cff_create("rmarkdown") notes: Imports authors: - name: R Core Team - location: - name: Vienna, Austria - year: '2024' institution: name: R Foundation for Statistical Computing + address: Vienna, Austria + year: '2024' - type: software title: utils abstract: 'R: A Language and Environment for Statistical Computing' notes: Imports authors: - name: R Core Team - location: - name: Vienna, Austria - year: '2024' institution: name: R Foundation for Statistical Computing + address: Vienna, Austria + year: '2024' - type: software title: xfun abstract: 'xfun: Supporting Functions for Packages Maintained by ''Yihui Xie''' @@ -757,18 +750,6 @@ test <- cff_create("rmarkdown") given-names: Davis email: davis@posit.co year: '2024' - - type: software - title: cleanrmd - abstract: 'cleanrmd: Clean Class-Less ''R Markdown'' HTML Documents' - notes: Suggests - url: https://pkg.garrickadenbuie.com/cleanrmd/ - repository: https://CRAN.R-project.org/package=cleanrmd - authors: - - family-names: Aden-Buie - given-names: Garrick - email: garrick@adenbuie.com - orcid: https://orcid.org/0000-0002-7111-0077 - year: '2024' - type: software title: withr abstract: 'withr: Run Code ''With'' Temporarily Modified Global State' @@ -806,7 +787,7 @@ cff_validate(test) #> ✔ Congratulations! This is valid ``` -Check the [docs](https://docs.ropensci.org/cffr/reference/index.html) +Check the [docs](https://docs.ropensci.org/cffr//reference/index.html) and `vignette("cffr", package = "cffr")` to learn how to work with `cff` objects. @@ -907,9 +888,9 @@ for more info.
-Boettiger, Carl, and Maëlle Salmon. 2021a. *codemeta: A Smaller codemetar Package*. +Boettiger, Carl, and Maëlle Salmon. 2021a. +*codemeta: A Smaller +codemetar Package*. .
@@ -930,8 +911,8 @@ Among Citation Formats*.
-Dietrich, Jan Philipp, and Waldir Leoncio. 2022. *citation: Software Citation Tools*. +Dietrich, Jan Philipp, and Waldir Leoncio. 2022. +*citation: Software Citation Tools*.
diff --git a/codemeta.json b/codemeta.json index be76fce2..1551c39b 100644 --- a/codemeta.json +++ b/codemeta.json @@ -8,13 +8,13 @@ "codeRepository": "https://github.com/ropensci/cffr", "issueTracker": "https://github.com/ropensci/cffr/issues", "license": "https://spdx.org/licenses/GPL-3.0", - "version": "0.5.0", + "version": "0.5.0.9000", "programmingLanguage": { "@type": "ComputerLanguage", "name": "R", "url": "https://r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31)", + "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", "provider": { "@id": "https://cran.r-project.org", "@type": "Organization", @@ -200,7 +200,7 @@ }, "isPartOf": "https://ropensci.org", "keywords": ["attribution", "citation", "credit", "citation-files", "cff", "metadata", "r", "r-package", "citation-file-format", "rstats", "ropensci", "cran"], - "fileSize": "906.703KB", + "fileSize": "911.371KB", "citation": [ { "@type": "ScholarlyArticle", @@ -286,7 +286,7 @@ "sameAs": "https://doi.org/10.5281/zenodo.5171937" } ], - "releaseNotes": "https://github.com/ropensci/cffr/blob/master/NEWS.md", + "releaseNotes": "https://github.com/ropensci/cffr/blob/main/NEWS.md", "readme": "https://github.com/ropensci/cffr/blob/main/README.md", "contIntegration": ["https://github.com/ropensci/cffr/actions/workflows/check-full.yaml", "https://app.codecov.io/gh/ropensci/cffr", "https://github.com/ropensci/cffr/actions/workflows/cff-validator.yml"], "developmentStatus": ["https://www.repostatus.org/#active", "https://lifecycle.r-lib.org/articles/stages.html#experimental"], diff --git a/data-raw/crosswalk_tables.R b/data-raw/crosswalk_tables.R new file mode 100644 index 00000000..b2199230 --- /dev/null +++ b/data-raw/crosswalk_tables.R @@ -0,0 +1,17 @@ +## code to prepare `crosswalk_tables.csv` +library(tidyverse) +df <- openxlsx::read.xlsx("data-raw/crosswalk_tables.xlsx") + +unlink("/inst/extdata/crosswalk_tables.csv") +lapply(df, trimws) %>% + bind_rows() %>% + setNames(names(df)) %>% + write.csv("./inst/extdata/crosswalk_tables.csv", row.names = FALSE) + +cli::cli_alert_success("Excel updated") + +# +# lapply(df, trimws) %>% +# bind_rows() %>% +# setNames(names(df)) %>% +# openxlsx::write.xlsx("data-raw/crosswalk_tables.xlsx", overwrite = TRUE) diff --git a/data-raw/crosswalk_tables.xlsx b/data-raw/crosswalk_tables.xlsx new file mode 100644 index 00000000..44216508 Binary files /dev/null and b/data-raw/crosswalk_tables.xlsx differ diff --git a/data/cran_to_spdx.rda b/data/cran_to_spdx.rda index 54267cd1..0bd1435c 100644 Binary files a/data/cran_to_spdx.rda and b/data/cran_to_spdx.rda differ diff --git a/inst/WORDLIST b/inst/WORDLIST index fb1af619..62027bb1 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -3,7 +3,6 @@ Arfon BIBTEXTING BeaST BibLaTeX -BibTex Bitbucket Bliven Boettiger @@ -40,6 +39,7 @@ Niemeyer ORCID Oren Pandoc +Parsers Patashnik PhDThesis Philipp @@ -48,10 +48,10 @@ README RSPM RStudio Rbuildignore -RefManageR Reproducibility Riederer SPDX +Schemas Spaaks Suárez TechReport @@ -62,6 +62,7 @@ Zenodo Zotero al annote +bibtex biocViews booktitle cff @@ -76,29 +77,21 @@ dois et handlr howpublished -inbook incollection inproceedings -isbn -issn -issuetitle json +jsonvalidate mastersthesis -multivolume -pagetotal param parsers phdthesis plaintext pre rOpenSci -rbibutils repo repos rmarkdown -techreport testthat -urldate xampl zenodo ’CodeMeta’ diff --git a/inst/examples/DESCRIPTION_posit_package_manager b/inst/examples/DESCRIPTION_posit_package_manager new file mode 100644 index 00000000..a9e0f511 --- /dev/null +++ b/inst/examples/DESCRIPTION_posit_package_manager @@ -0,0 +1,31 @@ +Package: resmush +Title: Optimize and Compress Image Files with 'reSmush.it' +Version: 0.1.0 +Authors@R: + person("Diego", "Hernangómez", , "diego.hernangomezherrero@gmail.com", role = c("aut", "cre", "cph"), + comment = c(ORCID = "0000-0001-8457-4658")) +Description: Compress local and online images using the 'reSmush.it' API + service . +License: MIT + file LICENSE +URL: https://dieghernan.github.io/resmush/, + https://github.com/dieghernan/resmush +BugReports: https://github.com/dieghernan/resmush/issues +Depends: R (>= 3.6.0) +Imports: cli, curl, httr2 (>= 1.0.0), tools, utils +Suggests: grid, knitr, png, rmarkdown, testthat (>= 3.0.0) +VignetteBuilder: knitr +Config/Needs/website: dieghernan/gitdevr, xfun, dplyr, tibble, devtools +Config/testthat/edition: 3 +Config/testthat/parallel: true +Encoding: UTF-8 +RoxygenNote: 7.3.1 +X-schema.org-keywords: r, compress-images, optimize-images, resmushit, + api +NeedsCompilation: no +Packaged: 2024-02-01 12:16:47 UTC; diego +Author: Diego Hernangómez [aut, cre, cph] + () +Maintainer: Diego Hernangómez +Repository: RSPM +Date/Publication: 2024-02-02 19:50:02 UTC +Built: R 4.3.0; ; 2024-02-05 12:08:28 UTC; windows diff --git a/inst/examples/DESCRIPTION_r_universe b/inst/examples/DESCRIPTION_r_universe index ebd825c6..5e1fae18 100644 --- a/inst/examples/DESCRIPTION_r_universe +++ b/inst/examples/DESCRIPTION_r_universe @@ -59,12 +59,12 @@ Authors@R: role = "ctb", comment = c(ORCID = "0000-0001-8804-4216")) ) -Description: The 'Codemeta' Project defines a 'JSON-LD' format - for describing software metadata, as detailed at - . This package provides utilities to - generate, parse, and modify 'codemeta.json' files automatically for R - packages, as well as tools and examples for working with - 'codemeta.json' 'JSON-LD' more generally. +Description: The 'Codemeta' Project defines a 'JSON-LD' format for + describing software metadata, as detailed at + . This package provides utilities + to generate, parse, and modify 'codemeta.json' files + automatically for R packages, as well as tools and examples for + working with 'codemeta.json' 'JSON-LD' more generally. License: GPL-3 URL: https://github.com/ropensci/codemetar, https://docs.ropensci.org/codemetar/ @@ -85,10 +85,10 @@ Roxygen: list(markdown = TRUE) Config/testthat/edition: 3 Repository: https://ropensci.r-universe.dev RemoteUrl: https://github.com/ropensci/codemetar -RemoteRef: master -RemoteSha: 4cd7ccc51455f4fad762da8d3cca3f46c368e299 +RemoteRef: main +RemoteSha: bdd9a29d7eabcc43c3195fe461f884932eba763c NeedsCompilation: no -Packaged: 2023-04-05 06:11:53 UTC; root +Packaged: 2024-02-09 05:55:58 UTC; root Author: Carl Boettiger [aut, cre, cph] (), Anna Krystalli [rev, ctb] (), @@ -105,3 +105,4 @@ Author: Carl Boettiger [aut, cre, cph] Sebastian Kreutzer [ctb] (), Thierry Onkelinx [ctb] () Maintainer: Carl Boettiger +Built: R 4.3.2; ; 2024-02-09 05:58:05 UTC; windows diff --git a/inst/extdata/bibtex_field_entry.csv b/inst/extdata/bibtex_field_entry.csv deleted file mode 100644 index 74a7f182..00000000 --- a/inst/extdata/bibtex_field_entry.csv +++ /dev/null @@ -1,26 +0,0 @@ -field,article,book,booklet,inbook,incollection,"conference,inproceedings",manual,"mastersthesis,phdthesis",misc,proceedings,techreport,unpublished -title,x,x,x,x,x,x,x,x,o,x,x,x -year,x,x,o,x,x,x,o,x,o,x,x,o -author,x,(x),o,(x),x,x,o,x,o,,x,x -note,o,o,o,o,o,o,o,o,o,o,o,x -month,o,o,o,o,o,o,o,o,o,o,o,o -address,,o,o,o,o,o,o,o,,o,o, -publisher,,x,,x,x,o,,,,o,, -editor,,(x),,(x),o,o,,,,o,, -number,o,(o),,(o),(o),(o),,,,(o),o, -volume,o,(o),,(o),(o),(o),,,,(o),, -pages,o,,,(x),o,o,,,,,, -series,,o,,o,o,o,,,,o,, -booktitle,,,,,x,x,,,,,, -edition,,o,,o,o,,o,,,,, -type,,,,o,o,,,o,,,o, -chapter,,,,(x),o,,,,,,, -organization,,,,,,o,o,,,o,, -howpublished,,,o,,,,,,o,,, -institution,,,,,,,,,,,x, -journal,x,,,,,,,,,,, -school,,,,,,,,x,,,, -annote,,,,,,,,,,,, -crossref,,,,,,,,,,,, -key,,,,,,,,,,,, - diff --git a/inst/extdata/crosswalk_tables.csv b/inst/extdata/crosswalk_tables.csv new file mode 100644 index 00000000..155c598f --- /dev/null +++ b/inst/extdata/crosswalk_tables.csv @@ -0,0 +1,248 @@ +"table","f1","f2","f3","f4","f5","f6","f7","f8","f9","f10","f11","f12","f13" +"entry_fields","**address**",NA,"o","o","o","o","o","o","o",NA,"o","o",NA +"entry_fields","**annote**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_fields","**author**","x","x","o","x","x","x","o","x","o",NA,"x","x" +"entry_fields","**booktitle**",NA,NA,NA,NA,"x","x",NA,NA,NA,NA,NA,NA +"entry_fields","**chapter**",NA,NA,NA,"x","o",NA,NA,NA,NA,NA,NA,NA +"entry_fields","**crossref**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_fields","**edition**",NA,"o",NA,"o","o",NA,"o",NA,NA,NA,NA,NA +"entry_fields","**editor**",NA,"x",NA,"x","o","o",NA,NA,NA,"o",NA,NA +"entry_fields","**howpublished**",NA,NA,"o",NA,NA,NA,NA,NA,"o",NA,NA,NA +"entry_fields","**institution**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,"x",NA +"entry_fields","**journal**","x",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_fields","**key**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_fields","**month**","o","o","o","o","o","o","o","o","o","o","o","o" +"entry_fields","**note**","o","o","o","o","o","o","o","o","o","o","o","x" +"entry_fields","**number**","o","o",NA,"o","o","o",NA,NA,NA,"o","o",NA +"entry_fields","**organization**",NA,NA,NA,NA,NA,"o","o",NA,NA,"o",NA,NA +"entry_fields","**pages**","o",NA,NA,"x","o","o",NA,NA,NA,NA,NA,NA +"entry_fields","**publisher**",NA,"x",NA,"x","x","o",NA,NA,NA,"o",NA,NA +"entry_fields","**school**",NA,NA,NA,NA,NA,NA,NA,"x",NA,NA,NA,NA +"entry_fields","**series**",NA,"o",NA,"o","o","o",NA,NA,NA,"o",NA,NA +"entry_fields","**title**","x","x","x","x","x","x","x","x","o","x","x","x" +"entry_fields","**type**",NA,NA,NA,"o","o",NA,NA,"o",NA,NA,"o",NA +"entry_fields","**volume**","o","o",NA,"o","o","o",NA,NA,NA,"o",NA,NA +"entry_fields","**year**","x","x","o","x","x","x","o","x","o","x","x","o" +"entry_bib2cff","**\@article**","[article]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@book, \@inbook**","[book]{.underline}","**\@inbook** is a [book]{.underline} with **chapter** and/or **pages**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@booklet**","[pamphlet]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@conference**","[conference-paper]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@incollection**","[generic]{.underline}","Needs additional fields",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@inproceedings**","[conference-paper]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@manual**","[manual]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@mastersthesis, \@phdthesis**","[thesis]{.underline}","Identified by [thesis-type]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@misc**","[generic]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@proceedings**","[proceedings]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@techreport**","[report]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_bib2cff","**\@unpublished**","[unpublished]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[book]{.underline}","**\@book**, **\@inbook**","**\@inbook** is a [book]{.underline} with [section]{.underline} or [start/end]{.underline} (reference to page number or range).",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[conference, conference-paper]{.underline}","**\@inproceedings**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[article, magazine-article, newspaper-article]{.underline}","**\@article**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[manual]{.underline}","**\@manual**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[pamphlet]{.underline}","**\@booklet**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[proceedings]{.underline}","**\@proceedings**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[report]{.underline}","**\@techreport**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[thesis]{.underline}","**\@mastersthesis**, **\@phdthesis**","Using [thesis-type]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[unpublished]{.underline}","**\@unpublished**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","[generic]{.underline}","**\@misc**, **\@incollection**","**\@incollection** is a [generic]{.underline} with [year,publisher,collection-title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"entry_cff2bib","\<[any other value]{.underline}\>","**\@misc**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**address**","Several possibilities","In **BibTeX** it may be the address of a **publisher, conference, organization, institution** or **school**.",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","***annote***","Not clear, won't be mapped",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**author**","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**booktitle**","[collection-title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**chapter**","[section]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","***crossref***","Not clear, won't be mapped",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**edition**","[edition]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**editor**","[editors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**howpublished**","[medium]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**institution, school, organization**","[institution]{.underline}","No overlapping on **BibteX** requirements",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**journal**","[journal]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","***key***","Not clear, won't be mapped",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**month**","[month]{.underline}","Fallback: information in [date-published]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**pages**","[start]{.underline} & [end]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**publisher**","[publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**series**","[collection-title]{.underline} if no **booktitle**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**title**","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","***type***","Won't be mapped","This is a special key in [CFF]{.underline} resembling the **BibteX** entry.",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**volume**","[volume]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_bib2cff","**year**","[year]{.underline}","Fallback: information in [date-published]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**abstract**","[abstract]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**date**","[date-published]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**doi**","[doi]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**file**","[filename]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**isbn**","[isbn]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**issn**","[issn]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**issuetitle**","[issue-title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**pagetotal**","[pages]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**translator**","[translators]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**url**","[url]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**urldate**","[date-accessed]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"fields_biblatex2cff","**version**","[version]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**\@article**","[type: article, magazine-article, newspaper-article]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**author** (required)","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**journal** (required)","[journal]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**volume**","[volume]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**pages**","[start]{.underline} and [end]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_article","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**\@book, \@inbook**","[type: book]{.underline}","If [section]{.underline} or [start-end]{.underline} informed, it would be treated as **\@inbook**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**author** (required)","[authors]{.underline}","At least one of **author,editor** required",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**editor** (required)","[editors]{.underline}","At least one of **author,editor** required",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**publisher** (required)","[publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**chapter** (required in **\@inbook** only)","[section]{.underline}","Not even optional in **\@book**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**pages** (required in **\@inbook** only)","[start]{.underline} and [end]{.underline}","Not even optional in **\@book**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**volume**","[volume]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**series**","[collection-title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**address**","[address]{.underline} property of [publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**edition**","[edition]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_book","**type**","Ignored","Only optional in **\@inbook**",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**\@booklet**","[type: pamphlet]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**author**","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**howpublished**","[medium]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**address**","[location]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**year**","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_booklet","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**\@conference / \@inproceedings**","[type: conference-paper, conference]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**author** (required)","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**booktitle** (required)","[collection-title]{.underline} and [conference]{.underline}","Additionally [collection-type]{.underline} would be populated as ""proceedings""",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**editor**","[editors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**volume**","[volume]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**series**","Ignored",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**pages**","[start]{.underline} and [end]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**address**","[address]{.underline} property of [conference]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**organization**","[institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**publisher**","[publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_inproceedings","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**\@incollection**","[type: generic]{.underline}","Including a [collection-title]{.underline} value",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**author** (required)","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**booktitle** (required)","[collection-title]{.underline}","Additionally [collection-type]{.underline} would be populated as ""collection""",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**publisher** (required)","[publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**editor**","[editors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**volume**","[volume]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**series**","Ignored",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**type**","Ignored",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**chapter**","[section]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**pages**","[start]{.underline} and [end]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**address**","[address]{.underline} property of [publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**edition**","[edition]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_incollection","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**\@manual**","[type: manual]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**author**","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**organization**","[institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**address**","[address]{.underline} property of [organization]{.underline}","On missing [organization]{.underline} mapped to [location]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**edition**","[edition]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**year**","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_manual","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**\@mastersthesis, \@phdthesis**","[type: thesis]{.underline}","Use also [thesis-type]{.underline} for identifying the thesis type.",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**author** (required)","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**school** (required)","[institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**type**","Ignored",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**address**","[address]{.underline} property of [institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_thesis","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**\@misc**","[type: generic]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**author**","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**title**","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**howpublished**","[medium]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**year**","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_misc","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**\@proceedings**","[type: proceedings]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**title** (required)","[title]{.underline} and [conference]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**editor**","[editors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**volume**","[volume]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**series**","[collection-title]{.underline}","Additionally [collection-type]{.underline} would be populated as ""proceedings""",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**address**","[address]{.underline} property of [conference]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**organization**","[institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**publisher**","[publisher]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_proceedings","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**\@techreport**","[type: report]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**author** (required)","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**institution** (required)","[institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**year** (required)","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**type**","Ignored",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**number**","[issue]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**address**","[address]{.underline} property of [institution]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_techreport","**note**","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_unpublished","**\@unpublished**","[type: unpublished]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_unpublished","**author** (required)","[authors]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_unpublished","**title** (required)","[title]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_unpublished","**note** (required)","[notes]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_unpublished","**month**","[month]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"model_unpublished","**year**","[year]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[art]{.underline}","A work of art, e.g., a painting",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[article]{.underline}",NA,"[[article]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[audiovisual]{.underline}",NA,"[[audiovisual]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[bill]{.underline}","A legal bill","[[bill]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[blog]{.underline}","A blog post","[[blog]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[book]{.underline}","A book or e-book","[[book]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[catalogue]{.underline}",NA,"[[catalogue]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[conference]{.underline}",NA,"[[conference]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[conference-paper]{.underline}",NA,"[[conference-paper]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[data]{.underline}","A data set","[[data]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[database]{.underline}","An aggregated or online database","[[database]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[dictionary]{.underline}",NA,"[[dictionary]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[edited-work]{.underline}","An edited work, e.g., a book","[[edited-work]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[encyclopedia]{.underline}",NA,"[[encyclopedia]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[film-broadcast]{.underline}","A film or broadcast","[[film-broadcast]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[generic]{.underline}","The fallback type","[[generic]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[government-document]{.underline}",NA,"[[government-document]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[grant]{.underline}","A research or other grant","[[grant]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[hearing]{.underline}",NA,"[[hearing]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[historical-work]{.underline}","A historical work, e.g., a medieval manuscript","[[historical-work]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[legal-case]{.underline}",NA,"[[legal-case]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[legal-rule]{.underline}",NA,"[[legal-rule]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[magazine-article]{.underline}",NA,"[[magazine-article]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[manual]{.underline}","A manual","[[manual]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[map]{.underline}","A geographical map","[[map]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[multimedia]{.underline}","A multimedia file","[[multimedia]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[music]{.underline}","A music file or sheet music","[[music]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[newspaper-article]{.underline}",NA,"[[newspaper-article]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[pamphlet]{.underline}",NA,"[[pamphlet]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[patent]{.underline}",NA,"[[patent]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[personal-communication]{.underline}",NA,"[[personal-communication]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[proceedings]{.underline}","Conference proceedings","[[proceedings]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[report]{.underline}",NA,"[[report]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[serial]{.underline}",NA,"[[serial]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[slides]{.underline}","Slides, i.e., a published slide deck","[[slides]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[software]{.underline}","Software","[[software]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[software-code]{.underline}","Software source code","[[software-code]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[software-container]{.underline}","A software container (e.g., a docker container)","[[software-container]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[software-executable]{.underline}","An executable software, i.e., a binary/artifact","[[software-executable]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[software-virtual-machine]{.underline}","A virtual machine/vm image","[[software-virtual-machine]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[sound-recording]{.underline}",NA,"[[sound-recording]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[standard]{.underline}",NA,"[[standard]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[statute]{.underline}",NA,"[[statute]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[thesis]{.underline}","An academic thesis","[[thesis]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[unpublished]{.underline}",NA,"[[unpublished]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[video]{.underline}","A video recording","[[video]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA +"cff_types","[website]{.underline}",NA,"[[website]{.underline}]{.underline}",NA,NA,NA,NA,NA,NA,NA,NA,NA,NA diff --git a/inst/schemaorg.json b/inst/schemaorg.json index 71cc4348..dec7a9c6 100644 --- a/inst/schemaorg.json +++ b/inst/schemaorg.json @@ -26,6 +26,6 @@ "name": "Comprehensive R Archive Network (CRAN)", "url": "https://cran.r-project.org" }, - "runtimePlatform": "R version 4.3.2 (2023-10-31)", - "version": "0.5.0" + "runtimePlatform": "R version 4.3.2 (2023-10-31 ucrt)", + "version": "0.5.0.9000" } diff --git a/man/cff-class.Rd b/man/cff-class.Rd new file mode 100644 index 00000000..79127b37 --- /dev/null +++ b/man/cff-class.Rd @@ -0,0 +1,9 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/cff-class.R +\name{cff-class} +\alias{cff-class} +\title{The \code{cff} class} +\description{ +TODO +} +\keyword{internal} diff --git a/man/cff_from_bibtex.Rd b/man/cff_from_bibtex.Rd index b6adf32f..d87fc3b4 100644 --- a/man/cff_from_bibtex.Rd +++ b/man/cff_from_bibtex.Rd @@ -63,7 +63,7 @@ if (requireNamespace("bibtex", quietly = TRUE)) { information between BibTeX and CITATION.cff. Other BibTeX helpers: -\code{\link{cff_to_bibtex}()}, +\code{\link{cff_to_bibentry}()}, \code{\link{encoded_utf_to_latex}()}, \code{\link{write_bib}()}, \code{\link{write_citation}()} diff --git a/man/cff_to_bibtex.Rd b/man/cff_to_bibentry.Rd similarity index 78% rename from man/cff_to_bibtex.Rd rename to man/cff_to_bibentry.Rd index 709b0224..338a14e4 100644 --- a/man/cff_to_bibtex.Rd +++ b/man/cff_to_bibentry.Rd @@ -1,11 +1,11 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/cff_to_bibtex.R -\name{cff_to_bibtex} +% Please edit documentation in R/cff_to_bibentry.R +\name{cff_to_bibentry} +\alias{cff_to_bibentry} \alias{cff_to_bibtex} -\alias{cff_extract_to_bibtex} \title{Create BibTeX entries from several sources} \usage{ -cff_to_bibtex(x, what = c("preferred", "references", "all")) +cff_to_bibentry(x, what = c("preferred", "references", "all")) } \arguments{ \item{x}{The source that would be used for generating @@ -33,11 +33,14 @@ A \code{bibentry} object or a list of \code{bibentry} objects. This could be parsed to BibTeX using \code{\link[=toBibtex]{toBibtex()}} } \description{ -This function creates BibTeX entries (in the form of \code{\link[=bibentry]{bibentry()}} objects +This function creates \code{\link[=bibentry]{bibentry()}} objects from different metadata sources (\code{cff} objects, \code{DESCRIPTION} files, etc.). -The function tries to parse the information of the source \code{x} into a \code{cff} +The function tries to map the information of the source \code{x} into a \code{cff} object and performs a mapping of the metadata to BibTeX, according to \code{vignette("bibtex_cff", "cffr")}. + +Note that a \strong{R} \code{\link[=bibentry]{bibentry()}} object is the representation of a BibTeX +entry, see \strong{Examples}. } \examples{ \donttest{ @@ -47,7 +50,7 @@ cff_object <- cff() cff_object # bibentry object -bib <- cff_to_bibtex(cff_object) +bib <- cff_to_bibentry(cff_object) class(bib) @@ -60,13 +63,13 @@ toBibtex(bib) # From a CITATION.cff file with options path <- system.file("examples/CITATION_complete.cff", package = "cffr") -cff_file <- cff_to_bibtex(path, what = "all") +cff_file <- cff_to_bibentry(path, what = "all") toBibtex(cff_file) # For an installed package -installed_package <- cff_to_bibtex("jsonvalidate") +installed_package <- cff_to_bibentry("jsonvalidate") toBibtex(installed_package) @@ -74,7 +77,7 @@ toBibtex(installed_package) # Use a DESCRIPTION file path2 <- system.file("examples/DESCRIPTION_gitlab", package = "cffr") -desc_file <- cff_to_bibtex(path2) +desc_file <- cff_to_bibentry(path2) toBibtex(desc_file) } @@ -87,7 +90,7 @@ toBibtex(desc_file) \emph{Ruby CFF Library (Version 0.9.0)} (Computer software). \doi{10.5281/zenodo.1184077}. \item Hernangómez D (2022). "BibTeX and CFF, a potential crosswalk." -\emph{The cffr package, Vignettes} +\emph{The cffr package, Vignettes}. \doi{10.21105/joss.03900}, \url{https://docs.ropensci.org/cffr/articles/bibtex_cff.html}. } } diff --git a/man/encoded_utf_to_latex.Rd b/man/encoded_utf_to_latex.Rd index 3a44a611..43cd3d1d 100644 --- a/man/encoded_utf_to_latex.Rd +++ b/man/encoded_utf_to_latex.Rd @@ -47,7 +47,7 @@ ascii_table Other BibTeX helpers: \code{\link{cff_from_bibtex}()}, -\code{\link{cff_to_bibtex}()}, +\code{\link{cff_to_bibentry}()}, \code{\link{write_bib}()}, \code{\link{write_citation}()} } diff --git a/man/figures/lifecycle-archived.svg b/man/figures/lifecycle-archived.svg new file mode 100644 index 00000000..745ab0c7 --- /dev/null +++ b/man/figures/lifecycle-archived.svg @@ -0,0 +1,21 @@ + + lifecycle: archived + + + + + + + + + + + + + + + lifecycle + + archived + + diff --git a/man/figures/lifecycle-defunct.svg b/man/figures/lifecycle-defunct.svg new file mode 100644 index 00000000..d5c9559e --- /dev/null +++ b/man/figures/lifecycle-defunct.svg @@ -0,0 +1,21 @@ + + lifecycle: defunct + + + + + + + + + + + + + + + lifecycle + + defunct + + diff --git a/man/figures/lifecycle-deprecated.svg b/man/figures/lifecycle-deprecated.svg new file mode 100644 index 00000000..b61c57c3 --- /dev/null +++ b/man/figures/lifecycle-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: deprecated + + + + + + + + + + + + + + + lifecycle + + deprecated + + diff --git a/man/figures/lifecycle-experimental.svg b/man/figures/lifecycle-experimental.svg index d1d060e9..5d88fc2c 100644 --- a/man/figures/lifecycle-experimental.svg +++ b/man/figures/lifecycle-experimental.svg @@ -1 +1,21 @@ -lifecyclelifecycleexperimentalexperimental \ No newline at end of file + + lifecycle: experimental + + + + + + + + + + + + + + + lifecycle + + experimental + + diff --git a/man/figures/lifecycle-maturing.svg b/man/figures/lifecycle-maturing.svg new file mode 100644 index 00000000..897370ec --- /dev/null +++ b/man/figures/lifecycle-maturing.svg @@ -0,0 +1,21 @@ + + lifecycle: maturing + + + + + + + + + + + + + + + lifecycle + + maturing + + diff --git a/man/figures/lifecycle-questioning.svg b/man/figures/lifecycle-questioning.svg new file mode 100644 index 00000000..7c1721d0 --- /dev/null +++ b/man/figures/lifecycle-questioning.svg @@ -0,0 +1,21 @@ + + lifecycle: questioning + + + + + + + + + + + + + + + lifecycle + + questioning + + diff --git a/man/figures/lifecycle-soft-deprecated.svg b/man/figures/lifecycle-soft-deprecated.svg new file mode 100644 index 00000000..9c166ff3 --- /dev/null +++ b/man/figures/lifecycle-soft-deprecated.svg @@ -0,0 +1,21 @@ + + lifecycle: soft-deprecated + + + + + + + + + + + + + + + lifecycle + + soft-deprecated + + diff --git a/man/figures/lifecycle-stable.svg b/man/figures/lifecycle-stable.svg new file mode 100644 index 00000000..9bf21e76 --- /dev/null +++ b/man/figures/lifecycle-stable.svg @@ -0,0 +1,29 @@ + + lifecycle: stable + + + + + + + + + + + + + + + + lifecycle + + + + stable + + + diff --git a/man/figures/lifecycle-superseded.svg b/man/figures/lifecycle-superseded.svg new file mode 100644 index 00000000..db8d757f --- /dev/null +++ b/man/figures/lifecycle-superseded.svg @@ -0,0 +1,21 @@ + + lifecycle: superseded + + + + + + + + + + + + + + + lifecycle + + superseded + + diff --git a/man/figures/logo.png b/man/figures/logo.png index ea954aa0..c876c2e1 100644 Binary files a/man/figures/logo.png and b/man/figures/logo.png differ diff --git a/man/previous_cff_to_bib.Rd b/man/previous_cff_to_bib.Rd new file mode 100644 index 00000000..94761d70 --- /dev/null +++ b/man/previous_cff_to_bib.Rd @@ -0,0 +1,48 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/deprecated.R +\name{cff_extract_to_bibtex} +\alias{cff_extract_to_bibtex} +\title{Previous API: Create BibTeX entries from several sources} +\usage{ +cff_extract_to_bibtex(x, what = c("preferred", "references", "all")) +} +\arguments{ +\item{x}{The source that would be used for generating +the \code{\link[=bibentry]{bibentry()}} object via \code{cff}. It could be: +\itemize{ +\item A missing value. That would retrieve the DESCRIPTION +file on your in-development package. +\item An existing \code{\link{cff}} object, +\item Path to a CITATION.cff file (\code{"*/CITATION.cff*"}), +\item The name of an installed package (\code{"jsonlite"}), or +\item Path to a DESCRIPTION file (\code{"*/DESCRIPTION*"}). +}} + +\item{what}{Fields to extract. The value could be: +\itemize{ +\item \code{preferred}: This would create a single entry with the main citation +info of the package. +\item \code{references}: Extract all the entries on \code{references}. +\item \code{all}: A combination of the previous two options. This would extract +both the preferred citation info and the references. +}} +} +\value{ +See \code{\link[=cff_to_bibentry]{cff_to_bibentry()}} +} +\description{ +\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#superseded}{\figure{lifecycle-superseded.svg}{options: alt='[Superseded]'}}}{\strong{[Superseded]}} +Please use \code{\link[=cff_to_bibentry]{cff_to_bibentry()}} instead. +} +\examples{ +\donttest{ +# From a cff object +cff_object <- cff() + +cff_object + +# bibentry object +bib <- cff_to_bibentry(cff_object) +} +} +\keyword{internal} diff --git a/man/write_bib.Rd b/man/write_bib.Rd index 07904f8d..5240e5a0 100644 --- a/man/write_bib.Rd +++ b/man/write_bib.Rd @@ -9,7 +9,7 @@ write_bib(x, file = NULL, append = FALSE, verbose = TRUE, ascii = FALSE) \arguments{ \item{x}{A \code{bibentry} object created with: \itemize{ -\item \code{\link[=cff_to_bibtex]{cff_to_bibtex()}} +\item \code{\link[=cff_to_bibentry]{cff_to_bibentry()}} \item \code{\link[=citation]{citation()}} or \code{\link[=bibentry]{bibentry()}} }} @@ -56,7 +56,7 @@ following packages: Other BibTeX helpers: \code{\link{cff_from_bibtex}()}, -\code{\link{cff_to_bibtex}()}, +\code{\link{cff_to_bibentry}()}, \code{\link{encoded_utf_to_latex}()}, \code{\link{write_citation}()} } diff --git a/man/write_citation.Rd b/man/write_citation.Rd index 09aa9e7b..55d8d8fe 100644 --- a/man/write_citation.Rd +++ b/man/write_citation.Rd @@ -15,9 +15,9 @@ write_citation( \arguments{ \item{x}{It could be \itemize{ -\item A \code{bibentry} object created with \code{\link[=cff_to_bibtex]{cff_to_bibtex()}}, \code{\link[=citation]{citation()}} or +\item A \code{bibentry} object created with \code{\link[=cff_to_bibentry]{cff_to_bibentry()}}, \code{\link[=citation]{citation()}} or \code{\link[=bibentry]{bibentry()}} -\item Any of the valid inputs of \code{\link[=cff_to_bibtex]{cff_to_bibtex()}}: +\item Any of the valid inputs of \code{\link[=cff_to_bibentry]{cff_to_bibentry()}}: \itemize{ \item A missing value. That would retrieve the DESCRIPTION file on your in-development package. @@ -35,7 +35,7 @@ in-development package. \item{verbose}{Display informative messages} \item{...}{ - Arguments passed on to \code{\link[=cff_to_bibtex]{cff_to_bibtex}} + Arguments passed on to \code{\link[=cff_to_bibentry]{cff_to_bibentry}} \describe{ \item{\code{what}}{Fields to extract. The value could be: \itemize{ @@ -91,7 +91,7 @@ R version 4.3.0 (2023-04-21) edition. Other BibTeX helpers: \code{\link{cff_from_bibtex}()}, -\code{\link{cff_to_bibtex}()}, +\code{\link{cff_to_bibentry}()}, \code{\link{encoded_utf_to_latex}()}, \code{\link{write_bib}()} } diff --git a/pkgdown/favicon/apple-touch-icon-180x180.png b/pkgdown/favicon/apple-touch-icon-180x180.png index 32a12c81..ca5657eb 100644 Binary files a/pkgdown/favicon/apple-touch-icon-180x180.png and b/pkgdown/favicon/apple-touch-icon-180x180.png differ diff --git a/pkgdown/favicon/apple-touch-icon-60x60.png b/pkgdown/favicon/apple-touch-icon-60x60.png index c1261dd6..064a4eb9 100644 Binary files a/pkgdown/favicon/apple-touch-icon-60x60.png and b/pkgdown/favicon/apple-touch-icon-60x60.png differ diff --git a/pkgdown/favicon/apple-touch-icon-76x76.png b/pkgdown/favicon/apple-touch-icon-76x76.png index e460dc56..5952d1f1 100644 Binary files a/pkgdown/favicon/apple-touch-icon-76x76.png and b/pkgdown/favicon/apple-touch-icon-76x76.png differ diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png index 32a12c81..ca5657eb 100644 Binary files a/pkgdown/favicon/apple-touch-icon.png and b/pkgdown/favicon/apple-touch-icon.png differ diff --git a/pkgdown/favicon/favicon-32x32.png b/pkgdown/favicon/favicon-32x32.png index af0667aa..2d27344d 100644 Binary files a/pkgdown/favicon/favicon-32x32.png and b/pkgdown/favicon/favicon-32x32.png differ diff --git a/tests/testthat.R b/tests/testthat.R index 7b36cace..fd7977ae 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -3,8 +3,8 @@ # # Where should you do additional test configuration? # Learn more about the roles of various files in: -# * https://r-pkgs.org/tests.html -# * https://testthat.r-lib.org/reference/test_package.html#special-files +# * https://r-pkgs.org/testing-design.html#sec-tests-files-overview +# * https://testthat.r-lib.org/articles/special-files.html library(testthat) library(cffr) diff --git a/tests/testthat/_snaps/bibtex-check-ruby.md b/tests/testthat/_snaps/bibtex-check-ruby.md index 5dd8ef3d..931ceb2e 100644 --- a/tests/testthat/_snaps/bibtex-check-ruby.md +++ b/tests/testthat/_snaps/bibtex-check-ruby.md @@ -26,7 +26,6 @@ booktitle = {Proceedings of Supercomputing 2015}, publisher = {ACM/IEEE}, address = {Austin, Texas, USA}, - series = {Supercomputing 2015 (SC'15)}, doi = {10.1244/2886907.2879400}, } @@ -57,7 +56,6 @@ booktitle = {Proceedings of the 2016 ACM SIGMOD International Conference on Management of Data (SIGMOD)}, publisher = {ACM}, address = {San Francisco, US}, - series = {SIGMOD '16}, pages = {2085--2088}, doi = {10.1145/2882903.2899401}, date = {2016-06-26}, @@ -173,7 +171,6 @@ year = {2016}, month = {jun}, address = {San Francisco, US}, - series = {SIGMOD '16}, doi = {10.1145/2882903.2899401}, abstract = {We present ReproZip, the recommended packaging tool for the SIGMOD Reproducibility Review. ReproZip was designed to simplify the process of making an existing computational experiment reproducible across platforms, even when the experiment was put together without reproducibility in mind. The tool creates a self-contained package for an experiment by automatically tracking and identifying all its required dependencies. The researcher can share the package with others, who can then use ReproZip to unpack the experiment, reproduce the findings on their favorite operating system, as well as modify the original experiment for reuse in new research, all with little effort. The demo will consist of examples of non-trivial experiments, showing how these can be packed in a Linux machine and reproduced on different machines and operating systems. Demo visitors will also be able to pack and reproduce their own experiments.}, date = {2016-06-26}, diff --git a/tests/testthat/_snaps/bibtex2cff.md b/tests/testthat/_snaps/bibtex2cff.md index 5b2672cc..f98d5109 100644 --- a/tests/testthat/_snaps/bibtex2cff.md +++ b/tests/testthat/_snaps/bibtex2cff.md @@ -42,13 +42,14 @@ year: '2004' volume: '3' issue: '7' + collection-title: The LateX Books + collection-type: book edition: Fourth month: '8' notes: Example modified for testing purposes keywords: - Two - keyword - collection-title: The LateX Books # Booklet @@ -82,6 +83,7 @@ - family-names: Yannakakis given-names: Mihalis collection-title: Proc. Fifteenth Annual ACM STOC + collection-type: conference year: '1983' editors: - family-names: Oz @@ -90,18 +92,16 @@ given-names: Mihalis volume: '41' issue: '17' - location: - name: Boston + institution: + name: ACM publisher: name: Academic Press notes: Example modified for testing purposes start: '133' end: '139' conference: - name: All ACM Conferences + name: Proc. Fifteenth Annual ACM STOC address: Boston - institution: - name: ACM # InBook @@ -125,12 +125,13 @@ year: '1994' volume: '27' issue: '2' + collection-title: Implementations of Logic Programming Systems + collection-type: book edition: Second month: '1' notes: Example modified for testing purposes start: '137' end: '149' - collection-title: Implementations of Logic Programming Systems # InCollection @@ -143,6 +144,7 @@ - family-names: Mihalcea given-names: Rada collection-title: 'Word Sense Disambiguation: Algorithms and Applications' + collection-type: collection publisher: name: Springer address: 107--132 @@ -176,6 +178,7 @@ - family-names: Yannakakis given-names: Mihalis collection-title: Proc. Fifteenth Annual ACM STOC + collection-type: proceedings year: '1983' editors: - family-names: Oz @@ -184,18 +187,16 @@ given-names: Mihalis volume: '41' issue: '17' - location: - name: Boston + institution: + name: ACM publisher: name: Academic Press notes: Example modified for testing purposes start: '133' end: '139' conference: - name: All ACM Conferences + name: Proc. Fifteenth Annual ACM STOC address: Boston - institution: - name: ACM # Manual @@ -206,14 +207,13 @@ title: A Language and Environment for Statistical Computing authors: - name: R Core Team - location: - name: Vienna, Austria + institution: + name: R Foundation for Statistical Computing + address: Vienna, Austria edition: Fourth month: '8' year: '2021' notes: Example modified for testing purposes - institution: - name: R Foundation for Statistical Computing # MastersThesis @@ -225,12 +225,12 @@ authors: - family-names: Alsolami given-names: Eesa - year: '2012' - month: '8' - notes: Example modified for testing purposes institution: name: Queensland University of Technology address: Queensland, NZ + year: '2012' + month: '8' + notes: Example modified for testing purposes thesis-type: Master's Thesis # Misc @@ -257,12 +257,12 @@ authors: - family-names: Alsolami given-names: Eesa - year: '2012' - month: '8' - notes: Example modified for testing purposes institution: name: Queensland University of Technology address: Queensland, NZ + year: '2012' + month: '8' + notes: Example modified for testing purposes thesis-type: PhD Thesis # Proceedings @@ -282,17 +282,17 @@ given-names: Mihalis volume: '1' issue: '17' - location: - name: Boston, US + collection-title: All ACM Conferences + collection-type: proceedings month: '8' + institution: + name: The OX Association for Computing Machinery publisher: name: Academic Press notes: Example modified for testing purposes conference: name: All ACM Conferences address: Boston, US - institution: - name: The OX Association for Computing Machinery # TechReport @@ -328,6 +328,30 @@ year: '1977' month: '8' +# InBook with booktitle + + Code + bibparsed + Output + type: generic + title: Bibliographies and citations + authors: + - family-names: Xie + given-names: Yihui + - family-names: Dervieux + given-names: Christophe + - family-names: Riederer + given-names: Emily + year: '2020' + collection-title: R Markdown Cookbook + collection-type: collection + publisher: + name: Chapman and Hall/CRC + address: Boca Raton, Florida + isbn: '9780367563837' + url: https://bookdown.org/yihui/rmarkdown-cookbook + section: '4.5' + # Test entry without author Code @@ -343,11 +367,14 @@ - family-names: Zwaenepoel given-names: Willy collection-title: Proceedings of the 6th European Conference on Computer Systems + collection-type: proceedings publisher: name: ACM month: '4' year: '2006' isbn: 1-59593-322-02 + conference: + name: Proceedings of the 6th European Conference on Computer Systems # Test entry without author but has a key @@ -359,6 +386,7 @@ authors: - name: anonymous collection-title: Proceedings of the 6th European Conference on Computer Systems + collection-type: misc publisher: name: ACM month: '4' @@ -375,6 +403,7 @@ authors: - name: anonymous collection-title: Proceedings of the 6th European Conference on Computer Systems + collection-type: misc publisher: name: ACM month: '4' diff --git a/tests/testthat/_snaps/cff_description.md b/tests/testthat/_snaps/cff_description.md index 693fbefd..4a203664 100644 --- a/tests/testthat/_snaps/cff_description.md +++ b/tests/testthat/_snaps/cff_description.md @@ -286,7 +286,7 @@ repository: https://ropensci.r-universe.dev repository-code: https://github.com/ropensci/codemetar url: https://docs.ropensci.org/codemetar/ - date-released: '2023-04-05' + date-released: '2024-02-09' contact: - family-names: Boettiger given-names: Carl @@ -336,6 +336,39 @@ given-names: Hervé email: hpages.on.github@gmail.com +# Parsing Posit Package Manager + + Code + parsed + Output + cff-version: 1.2.0 + message: 'To cite package "resmush" in publications use:' + type: software + license: MIT + title: 'resmush: Optimize and Compress Image Files with ''reSmush.it''' + version: 0.1.0 + abstract: Compress local and online images using the 'reSmush.it' API service . + authors: + - family-names: Hernangómez + given-names: Diego + email: diego.hernangomezherrero@gmail.com + orcid: https://orcid.org/0000-0001-8457-4658 + repository: https://CRAN.R-project.org/package=resmush + repository-code: https://github.com/dieghernan/resmush + url: https://dieghernan.github.io/resmush/ + date-released: '2024-02-02' + contact: + - family-names: Hernangómez + given-names: Diego + email: diego.hernangomezherrero@gmail.com + orcid: https://orcid.org/0000-0001-8457-4658 + keywords: + - r + - compress-images + - optimize-images + - resmushit + - api + # Search package on CRAN Code diff --git a/tests/testthat/_snaps/cff_parse_citation.md b/tests/testthat/_snaps/cff_parse_citation.md index c3ee0d50..c2081654 100644 --- a/tests/testthat/_snaps/cff_parse_citation.md +++ b/tests/testthat/_snaps/cff_parse_citation.md @@ -242,6 +242,7 @@ given-names: A conference: name: A conference + address: A location database-provider: name: Database provider editors: @@ -254,7 +255,6 @@ - name: Another publisher: name: A publisher - address: A location recipients: - family-names: recipient given-names: A diff --git a/tests/testthat/_snaps/cff_to_bibtex.md b/tests/testthat/_snaps/cff_to_bibentry.md similarity index 99% rename from tests/testthat/_snaps/cff_to_bibtex.md rename to tests/testthat/_snaps/cff_to_bibentry.md index 1da2feca..80e419b9 100644 --- a/tests/testthat/_snaps/cff_to_bibtex.md +++ b/tests/testthat/_snaps/cff_to_bibentry.md @@ -222,7 +222,6 @@ publisher = {International Joint Conference on Artificial Intelligence}, address = {Murray Hill, New Jersey}, editor = {Jan Alexandersson}, - series = {A Series}, pages = {81--86}, organization = {IJCAI}, } @@ -280,6 +279,7 @@ title = {Computer-Aided Analysis of English Punctuation on a Parsed Corpus: The Special Case of Comma}, author = {Murat Bayraktar}, year = {1996}, + address = {Ankara, Turkey}, note = {Forthcoming}, school = {Department of Computer Engineering and Information Science, Bilkent University, Turkey}, } @@ -307,6 +307,7 @@ title = {Presupposition and Assertion in Dynamic Semantics}, author = {David I. Beaver}, year = {1995}, + address = {Edinburgh}, school = {Centre for Cognitive Science, University of Edinburgh}, } diff --git a/tests/testthat/_snaps/deprecated.md b/tests/testthat/_snaps/deprecated.md new file mode 100644 index 00000000..ac22bc72 --- /dev/null +++ b/tests/testthat/_snaps/deprecated.md @@ -0,0 +1,9 @@ +# cff_extract_to_bibtex + + Code + old1 <- cff_extract_to_bibtex(a_cff) + Condition + Warning: + `cff_extract_to_bibtex()` was deprecated in cffr 0.5.0. + i Please use `cff_to_bibentry()` instead. + diff --git a/tests/testthat/_snaps/merge_desc_cit.md b/tests/testthat/_snaps/merge_desc_cit.md index 50bd133f..4476fa32 100644 --- a/tests/testthat/_snaps/merge_desc_cit.md +++ b/tests/testthat/_snaps/merge_desc_cit.md @@ -562,6 +562,70 @@ isbn: 978-3-319-24277-4 url: https://ggplot2.tidyverse.org +--- + + Code + merged + Output + cff-version: 1.2.0 + message: 'To cite package "resmush" in publications use:' + type: software + title: 'resmush: Optimize and Compress Image Files with ''reSmush.it''' + version: 0.1.0 + authors: + - family-names: Hernangómez + given-names: Diego + email: diego.hernangomezherrero@gmail.com + orcid: https://orcid.org/0000-0001-8457-4658 + abstract: Compress local and online images using the 'reSmush.it' API service . + repository: https://CRAN.R-project.org/package=resmush + repository-code: https://github.com/dieghernan/resmush + url: https://dieghernan.github.io/resmush/ + date-released: '2024-02-02' + contact: + - family-names: Hernangómez + given-names: Diego + email: diego.hernangomezherrero@gmail.com + orcid: https://orcid.org/0000-0001-8457-4658 + keywords: + - r + - compress-images + - optimize-images + - resmushit + - api + license: MIT + doi: 10.1111/2041-210X.12469 + preferred-citation: + type: article + title: 'RNeXML: A Package for Reading and Writing Richly Annotated Phylogenetic, + Character, and Trait Data in R' + authors: + - family-names: Boettiger + given-names: Carl + - family-names: Chamberlain + given-names: Scott + - family-names: Vos + given-names: Rutger + - family-names: Lapp + given-names: Hilmar + journal: Methods in Ecology and Evolution + year: '2016' + volume: '7' + doi: 10.1111/2041-210X.12469 + start: '352' + end: '357' + references: + - type: book + title: 'ggplot2: Elegant Graphics for Data Analysis' + authors: + - family-names: Wickham + given-names: Hadley + publisher: + name: Springer-Verlag New York + year: '2016' + isbn: 978-3-319-24277-4 + url: https://ggplot2.tidyverse.org + --- Code @@ -587,7 +651,7 @@ repository: https://ropensci.r-universe.dev repository-code: https://github.com/ropensci/codemetar url: https://docs.ropensci.org/codemetar/ - date-released: '2023-04-05' + date-released: '2024-02-09' contact: - family-names: Boettiger given-names: Carl diff --git a/tests/testthat/test-assertions.R b/tests/testthat/test-assertions.R index 920d6027..aaebfdb9 100644 --- a/tests/testthat/test-assertions.R +++ b/tests/testthat/test-assertions.R @@ -1,49 +1,49 @@ -test_that("Check is.email", { +test_that("Check is_email", { # Examples from https://www.nicebread.de/validating-email-adresses-in-r/ # Valid addresses expect_true( all( - is.email("felix@nicebread.de"), - is.email("felix.123.honeyBunny@nicebread.lmu.de"), - is.email("felix@nicebread.de "), - is.email(" felix@nicebread.de"), - is.email("felix+batman@nicebread.de"), - is.email("felix@nicebread.office") + is_email("felix@nicebread.de"), + is_email("felix.123.honeyBunny@nicebread.lmu.de"), + is_email("felix@nicebread.de "), + is_email(" felix@nicebread.de"), + is_email("felix+batman@nicebread.de"), + is_email("felix@nicebread.office") ) ) # invalid addresses expect_false( any( - is.email("felix@nicebread"), - is.email("felix@nicebread@de"), - is.email("felixnicebread.de"), - is.email("@felixnicebread"), - is.email(NULL), - is.email(NA) + is_email("felix@nicebread"), + is_email("felix@nicebread@de"), + is_email("felixnicebread.de"), + is_email("@felixnicebread"), + is_email(NULL), + is_email(NA) ) ) }) -test_that("Check is.url", { +test_that("Check is_url", { # Valid urls expect_true( all( - is.url("https://github.com/dieghernan"), - is.url("http://github.com/dieghernan"), - is.url("ftp://github.com/dieghernan"), - is.url("sftp://github.com/dieghernan") + is_url("https://github.com/dieghernan"), + is_url("http://github.com/dieghernan"), + is_url("ftp://github.com/dieghernan"), + is_url("sftp://github.com/dieghernan") ) ) # invalid addresses expect_false( any( - is.url("https:/github.com/dieghernan"), - is.url("http:/github.com/dieghernan"), - is.url("ftp:/github.com/dieghernan"), - is.url("sftp:/github.com/dieghernan"), - is.url("www.github.com/dieghernan") + is_url("https:/github.com/dieghernan"), + is_url("http:/github.com/dieghernan"), + is_url("ftp:/github.com/dieghernan"), + is_url("sftp:/github.com/dieghernan"), + is_url("www.github.com/dieghernan") ) ) }) diff --git a/tests/testthat/test-bibtex-check-ruby.R b/tests/testthat/test-bibtex-check-ruby.R index c6347475..6dd4f780 100644 --- a/tests/testthat/test-bibtex-check-ruby.R +++ b/tests/testthat/test-bibtex-check-ruby.R @@ -1,4 +1,5 @@ -# See https://github.com/citation-file-format/ruby-cff/tree/main/test/files/formatted +# See ´ +# https://github.com/citation-file-format/ruby-cff/tree/main/test/files/formatted test_that("preferred-citation-book-missing", { @@ -6,7 +7,7 @@ test_that("preferred-citation-book-missing", { package = "cffr" ) - expect_warning(expect_error(cff_to_bibtex(x))) + expect_warning(expect_error(cff_to_bibentry(x))) }) test_that("preferred-citation-book", { @@ -14,7 +15,7 @@ test_that("preferred-citation-book", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -23,7 +24,7 @@ test_that("preferred-citation-conference-paper-2", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -32,7 +33,7 @@ test_that("preferred-citation-conference-paper-missing", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -41,7 +42,7 @@ test_that("preferred-citation-conference-paper", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -50,7 +51,7 @@ test_that("preferred-citation-manual", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -59,7 +60,7 @@ test_that("preferred-citation-no-month", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -68,7 +69,7 @@ test_that("preferred-citation-no-vol", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -78,7 +79,7 @@ test_that("preferred-citation-pamphlet", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -87,7 +88,7 @@ test_that("preferred-citation-report-no-institution", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -96,7 +97,7 @@ test_that("preferred-citation-report", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -106,7 +107,7 @@ test_that("preferred-citation-unpublished", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -115,7 +116,7 @@ test_that("reprozip", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -125,7 +126,7 @@ test_that("smith-et-al", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -134,6 +135,6 @@ test_that("tidyverse-joss-paper", { package = "cffr" ) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) diff --git a/tests/testthat/test-bibtex2cff.R b/tests/testthat/test-bibtex2cff.R index 4af1feb7..29a49e4b 100644 --- a/tests/testthat/test-bibtex2cff.R +++ b/tests/testthat/test-bibtex2cff.R @@ -21,6 +21,13 @@ test_that("Article", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- sort(names(unclass(bib)[[1]])) + fld2 <- sort(names(unclass(tobib)[[1]])) + expect_identical(fld1, fld2) }) @@ -53,6 +60,13 @@ test_that("Book", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- sort(names(unclass(bib)[[1]])) + fld2 <- sort(names(unclass(tobib)[[1]])) + expect_identical(fld1, fld2) }) @@ -78,6 +92,15 @@ test_that("Booklet", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- sort(names(unclass(bib)[[1]])) + fld2 <- sort(names(unclass(tobib)[[1]])) + + # Keyword is not parsed + expect_identical(setdiff(fld1, fld2), "keywords") }) test_that("Conference", { @@ -108,8 +131,6 @@ test_that("Conference", { bib <- list(bib_un) class(bib) <- "bibentry" - - bibparsed <- cff_parse_citation(bib) expect_snapshot(bibparsed) @@ -119,6 +140,14 @@ test_that("Conference", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "series") }) test_that("InBook", { @@ -150,6 +179,13 @@ test_that("InBook", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "type") }) test_that("InCollection", { @@ -183,8 +219,15 @@ test_that("InCollection", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) -}) + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), c("series", "type")) +}) test_that("InProceedings", { bib <- bibentry("InProceedings", @@ -214,8 +257,15 @@ test_that("InProceedings", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) -}) + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "series") +}) test_that("Manual", { bib <- bibentry("Manual", @@ -238,8 +288,15 @@ test_that("Manual", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) -}) + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(fld1, fld2) +}) test_that("MastersThesis", { bib <- bibentry("MastersThesis", @@ -255,7 +312,6 @@ test_that("MastersThesis", { month = "August", note = "Example modified for testing purposes" ) - bibparsed <- cff_parse_citation(bib) expect_snapshot(bibparsed) @@ -264,8 +320,15 @@ test_that("MastersThesis", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) -}) + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "type") +}) test_that("Misc", { bib <- bibentry("Misc", @@ -286,6 +349,14 @@ test_that("Misc", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(fld1, fld2) }) @@ -311,6 +382,14 @@ test_that("PhdThesis", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "type") }) @@ -338,6 +417,14 @@ test_that("Proceedings", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(fld1, fld2) }) test_that("TechReport", { @@ -362,6 +449,14 @@ test_that("TechReport", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "type") }) test_that("Unpublished", { @@ -382,8 +477,52 @@ test_that("Unpublished", { ) expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(fld1, fld2) }) +test_that("InBook with booktitle", { + bib <- bibentry("InBook", + title = "Bibliographies and citations", + year = "2020", + author = "Yihui Xie and Christophe Dervieux and Emily Riederer", + booktitle = "{R} Markdown Cookbook", + publisher = "Chapman and Hall/CRC", + address = "Boca Raton, Florida", + series = "The {R} Series", + isbn = "9780367563837", + url = "https://bookdown.org/yihui/rmarkdown-cookbook", + chapter = "4.5" + ) + + bibparsed <- cff_parse_citation(bib) + expect_snapshot(bibparsed) + + cffobj <- cff_create(cff(), + keys = list(references = list(bibparsed)) + ) + + expect_true(cff_validate(cffobj, verbose = FALSE)) + + # Should be an incollection now + res <- cff_to_bibentry(bibparsed) + init_type <- attr(unclass(res)[[1]], "bibtype") + expect_identical(tolower(init_type), "incollection") + + # Back to bibtex and check names + tobib <- cff_to_bibentry(bibparsed) + + fld1 <- unique(sort(names(unclass(bib)[[1]]))) + fld2 <- unique(sort(names(unclass(tobib)[[1]]))) + + expect_identical(setdiff(fld1, fld2), "series") +}) test_that("Test entry without author", { bib <- bibentry("Proceedings", diff --git a/tests/testthat/test-cff_description.R b/tests/testthat/test-cff_description.R index b096a052..2a6f8f1d 100644 --- a/tests/testthat/test-cff_description.R +++ b/tests/testthat/test-cff_description.R @@ -172,6 +172,26 @@ test_that("Parsing Bioconductor", { expect_true(cff_validate(parsed, verbose = FALSE)) }) +test_that("Parsing Posit Package Manager", { + desc_path <- system.file("examples/DESCRIPTION_posit_package_manager", + package = "cffr" + ) + + parsed <- cff_create(desc_path, + gh_keywords = FALSE, + keys = list(references = NULL) + ) + + expect_length(parsed$repository, 1) + expect_identical( + parsed$repository, + "https://CRAN.R-project.org/package=resmush" + ) + expect_s3_class(parsed, "cff") + expect_snapshot(parsed) + expect_true(cff_validate(parsed, verbose = FALSE)) +}) + test_that("Search package on CRAN", { basic_path <- system.file("examples/DESCRIPTION_basic", package = "cffr" diff --git a/tests/testthat/test-cff_parse_person.R b/tests/testthat/test-cff_parse_person.R index 952809f5..2e169564 100644 --- a/tests/testthat/test-cff_parse_person.R +++ b/tests/testthat/test-cff_parse_person.R @@ -1,3 +1,8 @@ +test_that("NULL gives NULL", { + expect_null(cff_parse_person(NULL)) + expect_null(cff_parse_person(NA)) +}) + test_that("Parse one person", { p <- person("one", "person") expect_snapshot(cff_parse_person(p)) diff --git a/tests/testthat/test-cff_read.R b/tests/testthat/test-cff_read.R index 2fd047d1..0c437b26 100644 --- a/tests/testthat/test-cff_read.R +++ b/tests/testthat/test-cff_read.R @@ -58,13 +58,13 @@ test_that("Other convertes", { a <- cff(a) expect_s3_class(a, "cff") a <- as.cff(a) - expect_true(is.cff(a)) + expect_true(is_cff(a)) expect_s3_class(a, "cff") expect_message(noadd <- cff(address = "New York", version = 5)) - expect_true(is.cff(noadd)) - expect_false(is.cff(list(a = 1, b = 2))) - expect_true(is.cff(as.cff(list(a = 1, b = 2)))) + expect_true(is_cff(noadd)) + expect_false(is_cff(list(a = 1, b = 2))) + expect_true(is_cff(as.cff(list(a = 1, b = 2)))) }) @@ -107,7 +107,7 @@ test_that("Fuzzy matching of keys on cff", { ) ) - expect_true(is.cff(cffobj)) + expect_true(is_cff(cffobj)) expect_true(cff_validate(cffobj, verbose = FALSE)) expect_snapshot(print_snapshot("Fuzzy keys", cffobj)) diff --git a/tests/testthat/test-cff_to_bibtex.R b/tests/testthat/test-cff_to_bibentry.R similarity index 88% rename from tests/testthat/test-cff_to_bibtex.R rename to tests/testthat/test-cff_to_bibentry.R index 04e804f6..d5438428 100644 --- a/tests/testthat/test-cff_to_bibtex.R +++ b/tests/testthat/test-cff_to_bibentry.R @@ -14,7 +14,7 @@ test_that("Article to bibtex", { ) expect_snapshot(toBibtex(bib)) x <- cff_parse_citation(bib) - bib <- cff_to_bibtex(x) + bib <- cff_to_bibentry(x) expect_snapshot(toBibtex(bib)) }) @@ -42,7 +42,7 @@ test_that("Book to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -63,7 +63,7 @@ test_that("Booklet to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -91,7 +91,7 @@ test_that("InBook to bibtex with pages", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -110,7 +110,7 @@ test_that("InCollection to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -135,7 +135,7 @@ test_that("InProceedings to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -153,7 +153,7 @@ test_that("Manual to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -172,7 +172,7 @@ test_that("MastersThesis to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -189,7 +189,7 @@ test_that("PhdThesis to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -208,7 +208,7 @@ test_that("Proceedings to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -224,7 +224,7 @@ test_that("TechReport to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -239,7 +239,7 @@ test_that("Unpublished to bibtex", { expect_snapshot(toBibtex(bib)) bibparsed <- cff_parse_citation(bib) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -264,7 +264,7 @@ test_that("particle names", { expect_snapshot(bibparsed) - bib <- cff_to_bibtex(bibparsed) + bib <- cff_to_bibentry(bibparsed) expect_snapshot(toBibtex(bib)) }) @@ -281,12 +281,12 @@ test_that("From plain cff with a citation", { s$`preferred-citation` <- cff_parse_citation(acit) s$`preferred-citation`$editors <- list(cff_parse_person("A name")) - bib <- cff_to_bibtex(s) + bib <- cff_to_bibentry(s) expect_snapshot(toBibtex(bib)) }) test_that("From plain cff", { - expect_message(bib <- cff_to_bibtex(cff())) + expect_message(bib <- cff_to_bibentry(cff())) expect_snapshot(toBibtex(bib)) }) @@ -295,13 +295,13 @@ test_that("From file", { package = "cffr" ) - bib <- cff_to_bibtex(file) + bib <- cff_to_bibentry(file) expect_snapshot(toBibtex(bib)) }) test_that("NULL", { s <- NULL - expect_null(cff_to_bibtex(s)) + expect_null(cff_to_bibentry(s)) }) @@ -311,7 +311,7 @@ test_that("Test anonymous", { ) - expect_message(back <- cff_to_bibtex(cff_parse_citation(bib))) + expect_message(back <- cff_to_bibentry(cff_parse_citation(bib))) expect_snapshot(toBibtex(back)) @@ -320,7 +320,7 @@ test_that("Test anonymous", { ) - expect_message(back <- cff_to_bibtex(cff_parse_citation(bib))) + expect_message(back <- cff_to_bibentry(cff_parse_citation(bib))) expect_snapshot(toBibtex(back)) bib <- bibentry("misc", @@ -328,7 +328,7 @@ test_that("Test anonymous", { ) - expect_message(back <- cff_to_bibtex(cff_parse_citation(bib))) + expect_message(back <- cff_to_bibentry(cff_parse_citation(bib))) expect_snapshot(toBibtex(back)) bib <- bibentry("proceedings", @@ -337,7 +337,7 @@ test_that("Test anonymous", { ) - expect_silent(back <- cff_to_bibtex(cff_parse_citation(bib))) + expect_silent(back <- cff_to_bibentry(cff_parse_citation(bib))) expect_snapshot(toBibtex(back)) }) @@ -356,7 +356,7 @@ test_that("Fallback month", { # Delete here the month x$month <- NULL - bibback <- cff_to_bibtex(x) + bibback <- cff_to_bibentry(x) expect_snapshot(toBibtex(bibback)) }) @@ -390,7 +390,7 @@ test_that("Test BibLateX entry", { x <- cff_parse_citation(bib) - parsed <- cff_to_bibtex(x) + parsed <- cff_to_bibentry(x) expect_snapshot(toBibtex(parsed)) }) @@ -398,7 +398,7 @@ test_that("Test BibLateX entry", { test_that("Test Fallback year", { x <- cff() - expect_message(msg <- cff_to_bibtex(x)) + expect_message(msg <- cff_to_bibentry(x)) expect_snapshot(toBibtex(msg)) @@ -407,32 +407,32 @@ test_that("Test Fallback year", { expect_true(cff_validate(x, verbose = FALSE)) - parsed <- cff_to_bibtex(x) + parsed <- cff_to_bibentry(x) expect_snapshot(toBibtex(parsed)) }) test_that("Errors", { - expect_silent(b <- cff_to_bibtex("testthat")) + expect_silent(b <- cff_to_bibentry("testthat")) expect_s3_class(b, "bibentry") - expect_error(cff_to_bibtex("testthat", what = "aa")) + expect_error(cff_to_bibentry("testthat", what = "aa")) }) test_that("From package", { skip_if_not_installed("rmarkdown") - base <- cff_to_bibtex("rmarkdown") + base <- cff_to_bibentry("rmarkdown") expect_s3_class(base, "bibentry") expect_length(base, 1) - refs <- cff_to_bibtex("rmarkdown", "references") + refs <- cff_to_bibentry("rmarkdown", "references") expect_s3_class(refs, "bibentry") expect_gte(length(refs), 1) - all <- cff_to_bibtex("rmarkdown", "all") + all <- cff_to_bibentry("rmarkdown", "all") expect_s3_class(all, "bibentry") expect_length(all, length(base) + length(refs)) @@ -441,10 +441,10 @@ test_that("From package", { test_that("NULL references", { basic <- cff() - expect_null(cff_to_bibtex(basic, "references")) + expect_null(cff_to_bibentry(basic, "references")) # Test all - expect_message(l <- cff_to_bibtex(basic, "all")) + expect_message(l <- cff_to_bibentry(basic, "all")) expect_length(l, 1) }) @@ -452,7 +452,7 @@ test_that("NULL references", { test_that("From CITATION.cff", { p <- system.file("examples/smith-et-al.cff", package = "cffr") - base <- cff_to_bibtex(p) + base <- cff_to_bibentry(p) expect_s3_class(base, "bibentry") diff --git a/tests/testthat/test-deprecated.R b/tests/testthat/test-deprecated.R new file mode 100644 index 00000000..7097e013 --- /dev/null +++ b/tests/testthat/test-deprecated.R @@ -0,0 +1,8 @@ +test_that("cff_extract_to_bibtex", { + a_cff <- cff_create("cffr") + + current <- cff_to_bibentry(a_cff) + expect_snapshot(old1 <- cff_extract_to_bibtex(a_cff)) + + expect_identical(current, old1) +}) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 800df3c4..a77bfd96 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -24,3 +24,20 @@ test_that("Try cleaning string", { expect_null(clean_str(logical(0))) expect_null(clean_str(list())) }) + +test_that("Use right repo", { + # Use some other repos + repos <- c("https://ropensci.r-universe.dev", "https://cloud.r-project.org") + + final <- detect_repos(repos) + expect_identical(final, c(CRAN = "https://cloud.r-project.org/")) + + # With posit package manager + repos <- c( + CRAN = "https://packagemanager.posit.co/cran/latest", + RPSM = "https://packagemanager.rstudio.com/", + ANOTHER = "https://packagemanager.rspm.com/" + ) + final <- detect_repos(repos) + expect_identical(final, c(CRAN = "https://cloud.r-project.org/")) +}) diff --git a/tests/testthat/test_ci/.gitignore b/tests/testthat/test_ci/.gitignore index a7cc310b..84cb1ec8 100644 --- a/tests/testthat/test_ci/.gitignore +++ b/tests/testthat/test_ci/.gitignore @@ -1,3 +1,4 @@ _snaps CITATION allpackages.csv +results.* diff --git a/tests/testthat/test_ci/README.md b/tests/testthat/test_ci/README.md index 0500a79b..983fc683 100644 --- a/tests/testthat/test_ci/README.md +++ b/tests/testthat/test_ci/README.md @@ -13,21 +13,15 @@ This test validates the `cff` parsing for \>1500 packages: This test is deployed in [GitHub Actions](https://github.com/ropensci/cffr/actions/workflows/test-ci.yaml) and -the results are uploaded as an artifact. We use here Windows and MacOS binaries -for speeding up the process. +the results are uploaded as an report on the action itself. We use here Windows +and MacOS. -As the installations differs across users and machines, the snapshot testing is -expected to fail on a normal run. However, the snapshots are quite useful for -extensive tests and debugging, as well as for capturing corner cases. For that -reason, these tests are no run in **CRAN** or in the regular package development -workflow. - -However, the test can be run locally with +The test can be run locally with ``` r # Load package devtools::load_all() -# Run the tests -testthat::test_dir("tests/testthat/test_ci") +# Run the report +source("tests/testthat/test_ci/test-new.R") ``` diff --git a/tests/testthat/test_ci/test-full_cff.R b/tests/testthat/test_ci/test-full_cff.R index f86a598f..453fe002 100644 --- a/tests/testthat/test_ci/test-full_cff.R +++ b/tests/testthat/test_ci/test-full_cff.R @@ -1,89 +1,97 @@ -test_that("Test ALL installed packages", { - expect_snapshot_output(print_snapshot("Sessioninfo", sessionInfo())) - - installed <- as.data.frame(installed.packages()[, c("Package", "Version")]) - installed <- installed[order(installed$Package), ] - - rownames(installed) <- seq_len(nrow(installed)) - - l <- nrow(installed) - - # Initial set of packages - write.csv(installed, "allpackages.csv", row.names = FALSE) - expect_snapshot_output(print_snapshot("Summary", paste( - "testing a sample of", - nrow(installed), "installed packages" - ))) - message("Sample of ", nrow(installed)) - - res <- c() - withcit <- c() - - for (i in seq_len(nrow(installed))) { - pkg <- installed[i, ]$Package - # Display some advances - message( - "Testing ", i, "/", nrow(installed), - " (", sprintf("%05.02f", i / nrow(installed) * 100), "%)" - ) - cit_path <- file.path(find.package(installed[i, ]$Package), "CITATION") - - - if (file.exists(cit_path)) { - withcit <- c(withcit, TRUE) - } else { - withcit <- c(withcit, FALSE) - } - - # Add cffobj - cffobj <- suppressMessages( - cff_create(pkg, gh_keywords = FALSE, dependencies = FALSE) - ) - - s <- suppressMessages(cff_validate(cffobj)) - - - res <- c(res, s) - } - - - expect_snapshot_output({ - installed$with_citation <- withcit - installed$is_ok <- res - - errors <- installed[installed$is_ok == FALSE, ] - - okrate <- 1 - nrow(errors) / nrow(installed) - - expect_snapshot_output(print_snapshot( - "OK rate", - sprintf("%1.2f%%", 100 * okrate) - )) - - - if (nrow(errors) > 0) { - print_snapshot( - "Errors", - errors - ) - - print_snapshot( - "Error reports for ", - paste(errors$Package, collapse = ", ") - ) - - for (j in seq_len(nrow(errors))) { - pkg <- errors[j, ]$Package - cff <- cff_create(pkg, gh_keywords = FALSE, dependencies = FALSE) - - print_snapshot(paste0(pkg, ": cffr object"), cff) - - print_snapshot("Validation results", cff_validate(cff)) - } - } else { - print_snapshot(obj = "No errors, hooray!") - } - }) - - write.csv(installed, "allpackages.csv", row.names = FALSE) -}) +# ---------------------------------------------------------------- +# DEPRECATED: SEE ./tests/testthat/test_ci/test-new.R file instead +# ---------------------------------------------------------------- + + +# test_that("Test ALL installed packages", { +# expect_snapshot_output(print_snapshot("Sessioninfo", sessionInfo())) +# +# installed <- as.data.frame(installed.packages()[, c("Package", "Version")]) +# installed <- installed[order(installed$Package), ] +# +# end <- match("ctv", installed$Package) + 10 +# installed <- installed[seq_len(end), ] +# +# rownames(installed) <- seq_len(nrow(installed)) +# +# l <- nrow(installed) +# +# # Initial set of packages +# write.csv(installed, "allpackages.csv", row.names = FALSE) +# expect_snapshot_output(print_snapshot("Summary", paste( +# "testing a sample of", +# nrow(installed), "installed packages" +# ))) +# message("Sample of ", nrow(installed)) +# +# res <- c() +# withcit <- c() +# +# for (i in seq_len(nrow(installed))) { +# pkg <- installed[i, ]$Package +# # Display some advances +# message( +# "Testing ", i, "/", nrow(installed), +# " (", sprintf("%05.02f", i / nrow(installed) * 100), "%)" +# ) +# cit_path <- file.path(find.package(installed[i, ]$Package), "CITATION") +# +# +# if (file.exists(cit_path)) { +# withcit <- c(withcit, TRUE) +# } else { +# withcit <- c(withcit, FALSE) +# } +# +# # Add cffobj +# cffobj <- suppressMessages( +# cff_create(pkg, gh_keywords = FALSE, dependencies = FALSE) +# ) +# +# s <- suppressMessages(cff_validate(cffobj)) +# +# +# res <- c(res, s) +# } +# +# +# expect_snapshot_output({ +# installed$with_citation <- withcit +# installed$is_ok <- res +# +# errors <- installed[installed$is_ok == FALSE, ] +# +# okrate <- 1 - nrow(errors) / nrow(installed) +# +# expect_snapshot_output(print_snapshot( +# "OK rate", +# sprintf("%1.2f%%", 100 * okrate) +# )) +# +# +# if (nrow(errors) > 0) { +# print_snapshot( +# "Errors", +# errors +# ) +# +# print_snapshot( +# "Error reports for ", +# paste(errors$Package, collapse = ", ") +# ) +# +# for (j in seq_len(nrow(errors))) { +# pkg <- errors[j, ]$Package +# cff <- cff_create(pkg, gh_keywords = FALSE, dependencies = FALSE) +# +# print_snapshot(paste0(pkg, ": cffr object"), cff) +# +# print_snapshot("Validation results", cff_validate(cff)) +# } +# } else { +# print_snapshot(obj = "No errors, hooray!") +# } +# }) +# +# write.csv(installed, "allpackages.csv", row.names = FALSE) +# }) diff --git a/tests/testthat/test_ci/test-new.R b/tests/testthat/test_ci/test-new.R new file mode 100644 index 00000000..5ea2c93e --- /dev/null +++ b/tests/testthat/test_ci/test-new.R @@ -0,0 +1,149 @@ +library(cffr) +installed <- as.data.frame(installed.packages()[, c("Package", "Version")]) +installed <- installed[order(installed$Package), ] + + +rownames(installed) <- seq_len(nrow(installed)) + +l <- nrow(installed) + +dir_path <- "./tests/testthat/test_ci/" + +message("Testing a sample of ", nrow(installed), " packages") + +res <- c() +withcit <- c() +note <- c() +for (i in seq_len(nrow(installed))) { + pkg <- installed[i, ]$Package + # Display some advances + message( + "Testing ", i, "/", nrow(installed), + " (", sprintf("%05.02f", i / nrow(installed) * 100), "%) [", + installed[i, ]$Package, "]" + ) + cit_path <- file.path(find.package(installed[i, ]$Package), "CITATION") + + + if (file.exists(cit_path)) { + withcit <- c(withcit, TRUE) + } else { + withcit <- c(withcit, FALSE) + } + + # Add cffobj + cffobj <- try( + cff_create(pkg, gh_keywords = FALSE, dependencies = FALSE), + silent = TRUE + ) + + if (inherits(cffobj, "cff")) { + s <- try(cff_validate(cffobj, verbose = FALSE), silent = TRUE) + if (!is.logical(s)) s <- FALSE + + res <- c(res, s) + note <- c(note, "") + } else { + res <- c(res, FALSE) + note <- c(note, "Other errors") + } +} + +installed$with_citation <- withcit +installed$is_ok <- res +installed$note <- note + +# Create report + +options(cli.width = 60) +outmd <- file.path(dir_path, "results.md") +unlink(outmd) + +cat("# Test all files\n\n", file = outmd) +write("## Session info\n", outmd, append = TRUE) +write("
", outmd, append = TRUE) +write("\n```r", outmd, append = TRUE) +conn <- file(outmd, "a") +capture.output(sessioninfo::session_info(), file = conn) +close(conn) +write("```\n", outmd, append = TRUE) +write("
", outmd, append = TRUE) + +errors <- installed[installed$is_ok == FALSE, ] +errother <- errors$Package[errors$note == "Other errors"] +errcff <- setdiff(errors$Package, errother) +errother_df <- installed[installed$Package %in% errother, c(1, 2)] + + + +write("\n## High level summary", outmd, append = TRUE) +write(paste0("\n- I checked ", nrow(installed), " packages"), + outmd, + append = TRUE +) +write(paste0("- Invalid cff in ", length(errcff), " packages"), + outmd, + append = TRUE +) +write(paste0("- I failed to generate cff in ", length(errother), " packages"), + outmd, + append = TRUE +) + +okrate <- 100 * (1 - length(errcff) / (nrow(installed) - length(errother))) +write(paste0("- OK Rate: ", round(okrate, 2), "%"), outmd, append = TRUE) + + +if (nrow(errors) == 0) { + write("\nNo errors, hooray!", outmd, append = TRUE) +} else { + write("\nPackages with errors:", outmd, append = TRUE) + conn <- file(outmd, "a") + capture.output(knitr::kable(errors, row.names = FALSE), + file = conn + ) + close(conn) + + + if (length(errother) > 0) { + pk <- paste0(errother, collapse = ", ") + line <- paste0("\n## Packages with errors not coming from cff") + write(line, outmd, append = TRUE) + conn <- file(outmd, "a") + capture.output(knitr::kable(errother_df, row.names = FALSE), + file = conn + ) + close(conn) + } + + if (length(errcff) > 0) { + write("\n## cff errors reported", outmd, append = TRUE) + # Prepare links + cfflist <- paste0("- [", errcff, "](#", tolower(errcff), ")", + collapse = "\n" + ) + write(cfflist, outmd, append = TRUE) + + for (j in errcff) { + write(paste0("\n### ", j, ""), outmd, append = TRUE) + write("\n#### cff object\n", outmd, append = TRUE) + write("
", outmd, append = TRUE) + write("\n```r", outmd, append = TRUE) + cff <- cff_create(j, gh_keywords = FALSE, dependencies = FALSE) + conn <- file(outmd, "a") + capture.output(print(cff), file = conn) + close(conn) + write("```\n", outmd, append = TRUE) + write("
", outmd, append = TRUE) + + + write("\n#### Validation results", outmd, append = TRUE) + + s <- cff_validate(cff, verbose = FALSE) + df <- attr(s, "errors") + conn <- file(outmd, "a") + capture.output(knitr::kable(df, row.names = FALSE), file = conn) + close(conn) + } + } +} diff --git a/vignettes/REFERENCES.bib b/vignettes/REFERENCES.bib index 6bbbf02a..78eb0a53 100644 --- a/vignettes/REFERENCES.bib +++ b/vignettes/REFERENCES.bib @@ -8,6 +8,16 @@ @misc{biblatexcheatsheet note = {Version Number: 2017-06-24}, date = {2017-06-24} } +@misc{biblatexpack, + title = {The {biblatex} package}, + author = {Philip Kime and Moritz Wemheuer and Philipp Lehman}, + year = 2023, + month = {mar}, + url = {https://osl.ugr.es/CTAN/macros/latex/contrib/biblatex/doc/biblatex.pdf}, + urldate = {2024-02-07}, + note = {Version Number: 3.19}, + date = {2023-03-05} +} @manual{codemetar2021, title = {{codemetar}: Generate '{CodeMeta}' Metadata for {R} Packages}, author = {Carl Boettiger and Maëlle Salmon}, @@ -212,3 +222,14 @@ @manual{codemeta url = {https://CRAN.R-project.org/package=codemeta}, note = {R package version 0.1.1} } +@misc{druskat2019, + title = {{Citation File Format (CFF)} - Specifications}, + author = {Druskat, Stephan and Spaaks, Jurriaan H. and Chue Hong, Neil and Haines, Robert and Baker, James}, + year = 2019, + month = 11, + doi = {10.5281/ZENODO.3515946}, + url = {https://zenodo.org/record/3515946}, + note = {Version 1.0.3-4}, + date = {2019-11-04}, + langid = {en} +} diff --git a/vignettes/bibtex_cff.Rmd b/vignettes/bibtex_cff.Rmd index 05e76077..c86fdeb6 100644 --- a/vignettes/bibtex_cff.Rmd +++ b/vignettes/bibtex_cff.Rmd @@ -2,23 +2,25 @@ title: "BibTeX and CFF" subtitle: A potential crosswalk bibliography: REFERENCES.bib -author: Diego Hernangómez ORCID logo +author: Diego Hernangómez description: >- This article presents a crosswalk between BibTeX and Citation File Format [@druskat_citation_2021], as it is performed by the cffr package [@hernangomez2021]. abstract: >- - This article presents a crosswalk between BibTeX and Citation File Format - [@druskat_citation_2021], as it is performed by the cffr package - [@hernangomez2021]. Several crosswalk models specific for each BibTeX entry - type [@patashnik1988] are proposed. The article also provide examples using real - BibTeX entries and tips for developers that would like to implement the crosswalk - on different programming languages. + This article introduces a crosswalk between **BibTeX** and the Citation File + Format (CFF) [@druskat_citation_2021], as implemented by the **cffr** package + [@hernangomez2021]. The crosswalk aims to facilitate seamless translation + between these two reference formats. Specifically, it proposes various + crosswalk models tailored to different **BibTeX** entry types + [@patashnik1988]. Additionally, the article includes practical examples using + real **BibTeX** entries and offers tips for developers interested in + implementing this crosswalk across various programming languages. link-citations: yes documentclass: article editor_options: markdown: - wrap: 120 + wrap: 80 output: rmarkdown::html_vignette: toc: true @@ -34,9 +36,18 @@ knitr::opts_chunk$set( comment = "" ) -options(width = 60) +# Load the table of tables + +p2file <- system.file("extdata/crosswalk_tables.csv", package = "cffr") + +table_master <- read.csv(p2file) ``` +## Disclaimer + +*This article was reviewed and updated in 2024, along with the release of +**cffr** v0.6.0.* + ## Citation Please cite this article as: @@ -49,12 +60,14 @@ thisart <- bibentry("article", journal = "The {cffr} package", year = 2022, volume = "Vignettes", + doi = "10.21105/joss.03900", + url = "https://docs.ropensci.org/cffr/articles/bibtex_cff.html" ) cat(" \n") thisart ``` -A BibTeX entry for LaTeX users: +A **BibTeX** entry for LaTeX users: ``` bibtex @article{hernangomez2022, @@ -62,17 +75,21 @@ A BibTeX entry for LaTeX users: author = {Diego Hernangómez}, year = 2022, journal = {The {cffr} package}, - volume = {Vignettes} + volume = {Vignettes}, + doi = {10.21105/joss.03900}, + url = {https://docs.ropensci.org/cffr/articles/bibtex_cff.html} } ``` ## BibTeX and R -[BibTeX](https://en.wikipedia.org/wiki/BibTeX) is a well-known format for storing references created by [Oren -Patashnik](https://en.wikipedia.org/wiki/Oren_Patashnik "Oren Patashnik") and [Leslie -Lamport](https://en.wikipedia.org/wiki/Leslie_Lamport "Leslie Lamport") back in 1985. BibTeX that may be reused by -another software, like [LaTeX](https://en.wikipedia.org/wiki/LaTeX), for adding references to a work. An example -structure of a BibTeX entry would be: +[**BibTeX**](https://en.wikipedia.org/wiki/BibTeX) is a well-known format for +storing references created by [Oren +Patashnik](https://en.wikipedia.org/wiki/Oren_Patashnik "Oren Patashnik") and +[Leslie Lamport](https://en.wikipedia.org/wiki/Leslie_Lamport "Leslie Lamport") +back in 1985. **BibTeX** can be reused by other software, such as +[LaTeX](https://en.wikipedia.org/wiki/LaTeX), to add references to scholarly +works. An example structure of a **BibTeX** entry would be: ``` bibtex @book{einstein1921, @@ -85,10 +102,10 @@ structure of a BibTeX entry would be: } ``` -On this case, the entry (identified as `einstein1921`) would refer to a book. This entry then can be used on a document -and include references to it. - -On **R** [@R_2021], we can replicate this structure using the `bibentry()` and `toBibtex()` functions: +In this case, the entry (identified as `einstein1921`) refers to a book. This +entry can then be used in a document to include references to it. In **R** +[@R_2021], we can replicate this structure using the `bibentry()` and +`toBibtex()` functions: ```{r bibentry, comment="#>"} entry <- bibentry("book", @@ -106,14 +123,16 @@ toBibtex(entry) The final results of the entry as a text string would be parsed as[^1]: -[^1]: By default R Pandoc would generate the cite on the Chicago author-date format [@rmarkdowncookbook2020] +[^1]: By default **R** Pandoc would generate the cite on the Chicago author-date + format [@rmarkdowncookbook2020] ```{r echo=FALSE, results='asis'} entry ``` -Additionally, **cffr** [@hernangomez2021] incorporates a function `cff_from_bibtex()` than can be used to read and -transform BibTeX strings into different formats: +Additionally, the **cffr** package [@hernangomez2021] incorporates a function +`cff_from_bibtex()` that can be used to read and transform **BibTeX** strings +into different formats: ```{r cffbibread,comment="#>"} string <- "@book{einstein1921, @@ -131,362 +150,398 @@ cff_format <- cff_from_bibtex(string) cff_format # To citation R format and bibtex -citation_format <- cff_to_bibtex(cff_format) +citation_format <- cff_to_bibentry(cff_format) class(citation_format) citation_format toBibtex(citation_format) ``` -## BibTeX definitions +## BibTeX Definitions -@patashnik1988 provides a comprehensive explanation of the BibTeX formats. We can distinguish between **Entries** and -**Fields**. +@patashnik1988 provides a comprehensive explanation of the **BibTeX** formats. +Let's distinguish between **Entries** and **Fields**. ### Entries {#entries} -Each entry type defines a different type of work. The 14 entry types defined on BibTeX[^2] are: - -[^2]: Other implementations similar to BibTeX, as [BibLaTeX](https://www.ctan.org/pkg/biblatex), expand the definitions - of entries including other types as **online**, **software** or **dataset**. On BibTeX these entries should be - reclassified to **misc**. - -- **\@article**: An article from a journal or magazine. -- **\@book**: A book with an explicit publisher. -- **\@booklet**: A work that is printed and bound, but without a named publisher or sponsoring institution. -- **\@conference**: The same as **\@inproceedings**, included for Scribe compatibility. -- **\@inbook**: A part of a book, which may be a chapter (or section or whatever) and/or a range of pages. -- **\@incollection**: A part of a book having its own title. -- **\@inproceedings**: An article in a conference proceedings. -- **\@manual**: Technical documentation. -- **\@mastersthesis**: A Master's thesis. -- **\@misc**: Use this type when nothing else fits. -- **\@phdthesis**: A PhD thesis. -- **\@proceedings**: The proceedings of a conference. -- **\@techreport**: A report published by a school or other institution, usually numbered within a series. -- **\@unpublished**: A document having an author and title, but not formally published. - -Regarding the entries, `bibentry()` **R** function does not implement **\@conference** . However, we can replace that -key by **\@inproceedings** given that the definition is identical. - -### Fields - -As in the case of Entries, @patashnik1988 provides also a definition for each of the possible standard BibTeX -fields[^3]. An entry can include other fields that would be ignored on the raw implementation of BibTeX: - -[^3]: As in the case of the entries, other implementations based on BibTeX may recognize additional fields. - -- **address**: Usually the address of the **publisher** or other of **institution**. -- **annote**: An annotation. It is not used by the standard bibliography styles, but may be used by others that - produce an annotated bibliography. -- **author**: The name(s) of the author(s), in the format described in the LaTeX book [@lamport86latex]. -- **booktitle**: Title of a book, part of which is being cited. For **\@book** entries, use the **title** field - instead. -- **chapter**: A chapter (or section or whatever) number. -- **crossref**: The database key of the entry being cross referenced. -- **edition**: The edition of a **\@book**, for example, "Second". This should be an ordinal, and should have the - first letter capitalized, the standard styles convert to lower case when necessary. -- **editor**: Name(s) of editor(s), typed as indicated in the LaTeX book [@lamport86latex]. If there is also an - **author** field, then the editor field gives the editor of the book or collection in which the reference appears. -- **howpublished**: How something strange has been published. The first word should be capitalized. -- **institution**: The sponsoring institution of a technical report. -- **journal**: A journal name. -- **key**: Used for alphabetizing, cross referencing, and creating a label when the **author** information is missing. -- **month**: The month in which the work was published or, for an unpublished work, in which it was written. You - should use the standard three-letter abbreviation, as described in Appendix B.1.3 of the LaTeX book - [@lamport86latex] (i.e. `jan, feb, mar`). -- **note**: Any additional information that can help the reader. The first word should be capitalized. -- **number**: The number of a journal, magazine, technical report, or of a work in a series. An issue of a journal or - magazine is usually identified by its **volume**: and number; the organization that issues a technical report - usually gives it a number; and sometimes books are given numbers in a named series. -- **organization**: The organization that sponsors a **\@conference** or that publishes a manual. -- **pages**: One or more page numbers or range of numbers, such as `42--111` or `7,41,73--97` or `43+`. -- **publisher**: The publisher's name. -- **school**: The name of the school where a thesis was written. -- **series**: The name of a series or set of books. When citing an entire book, the **title** field gives its title - and an optional **series** field gives the name of a series or multi-volume set in which the book is published. -- **title**: The work's title. -- **type**: The type of a technical report, for example, "Research Note". -- **volume**: The volume of a journal or multivolume book. -- **year**: The year of publication or, for an unpublished work, the year it was written. Generally it should consist - of four numerals, such as `1984`. - -There is a strict relation between Entries and Fields on BibTeX. Depending on the type of entries, some fields are -required while others are optional or even ignored. On the following table, required field are flagged as **x** and -optional fields are flagged as **o**. Fields on parenthesis (**(x), (o)**) denotes that there are some degree of -flexibility on the requirement of the field, see @patashnik1988 for more information. +Each entry type defines a different type of work. The 14 entry types defined in +**BibTeX** are: + +1. **\@article**: An article from a journal or magazine. +2. **\@book**: A book with an explicit publisher. +3. **\@booklet**: A work that is printed and bound, but without a named + publisher or sponsoring institution. +4. **\@conference**: Equivalent to **\@inproceedings**, included for + [Scribe](https://en.wikipedia.org/wiki/Scribe_(markup_language)) + compatibility. +5. **\@inbook**: A part of a book, which may be a chapter (or section) and/or a + range of pages. +6. **\@incollection**: A part of a book having its own title. +7. **\@inproceedings**: An article in conference proceedings. +8. **\@manual**: Technical documentation. +9. **\@mastersthesis**: A Master's thesis. +10. **\@misc**: Use this type when nothing else fits. +11. **\@phdthesis**: A PhD thesis. +12. **\@proceedings**: The proceedings of a conference. +13. **\@techreport**: A report published by a school or other institution, + usually numbered within a series. +14. **\@unpublished**: A document having an author and title, but not formally + published. + +Other implementations similar to **BibTeX**, such as **BibLaTeX** +[@biblatexpack], expand the definitions of entries to include other types such +as online resources, software, or datasets. In **BibTeX**, these entries should +be reclassified as **\@misc**. + +In **R**, the `bibentry()` base function does not implement **\@conference**. +However, we can use **\@inproceedings**, instead given that the definition is +identical. + +### Fields {#fields} + +Similar to the **Entries**, @patashnik1988 also provides definitions for each of +the possible standard **BibTeX fields**. While an entry must include certain +required fields, it can also include additional fields that might be ignored in +the raw implementation of **BibTeX**. Let's explore some of these fields: + +1. **address**: Typically represents the address of the **publisher** or + another **institution**. In the case of **\@conference**, + **\@inproceedings** and **\@proceedings** this field indicates where the + conference was held. +2. **annote**: An annotation. Although not used by standard bibliography + styles, it may be relevant for producing annotated bibliographies. +3. **author**: Contains the name(s) of the author(s), following the format + described in the LaTeX book [@lamport86latex]. +4. **booktitle**: Refers to the title of a book, part of which is being cited. + For **\@book** entries, use the **title** field instead. +5. **chapter**: Indicates a chapter (or section) number. +6. **crossref**: Refers to the database key of the entry being + cross-referenced. +7. **edition**: Specifies the edition of a **\@book**, e.g., `"Second"`. The + ordinal should have the first letter capitalized; standard styles convert to + lowercase when necessary. +8. **editor**: Contains the name(s) of editor(s), following the conventions in + the LaTeX book [@lamport86latex]. If there is also an **author** field, the + **editor** field specifies the editor of the book or collection where the + reference appears. +9. **howpublished**: Describes how something unusual has been published. The + first word should be capitalized. +10. **institution**: Represents the sponsoring institution of a technical + report. +11. **journal**: Refers to the name of a journal. +12. **key**: Used for alphabetizing, cross-referencing, and creating a label + when **author** information is missing. +13. **month**: Indicates the month in which the work was published or, for an + unpublished work, when it was written. Use the standard three-letter + abbreviation (e.g., `jan`, `feb`, `mar`) as described in **Appendix B.1.3** + of the LaTeX book [@lamport86latex]. +14. **note**: Provides any additional information that can assist the reader. + The first word should be capitalized. +15. **number**: Represents the number of a journal, magazine, technical report, + or a work in a series. An issue of a journal or magazine is usually + identified by its **volume** and number. Organizations issuing technical + reports often assign them numbers, and sometimes books are given numbers + within a named series. +16. **organization**: Refers to the organization that sponsors a + **\@conference** or publishes a manual. +17. **pages**: Specifies one or more page numbers or a range of numbers (e.g., + `42--111` or `7,41,73--97` or `43+`). +18. **publisher**: Indicates the publisher's name. +19. **school**: Provides the name of the school where a thesis was written. +20. **series**: Specifies the name of a series or set of books. When citing an + entire book, the **title** field gives its title, and an optional **series** + field provides the name of a series or multi-volume set in which the book is + published. +21. **title**: Represents the work's title. +22. **type**: Describes the type of a technical report (e.g., "Research Note"). +23. **volume**: Refers to the volume of a journal or multi-volume book. +24. **year**: Indicates the year of publication or, for an unpublished work, the + year it was written. Generally, it should consist of four numerals (e.g., + `1984`). + +As in the case of the **Entries**, other implementations such as **BibLaTeX** +recognize additional fields. + +In **BibTeX**, there exists a strict relationship between **Entries** and +**Fields**. Depending on the type of entry, certain fields are required, while +others are optional or even ignored. + +The following table summarizes the relationship between **Entries** and +**Fields** in **BibTeX**. Required fields are flagged as **x**, and optional +fields are flagged as **o**. For more detailed information, refer to +@patashnik1988. ```{r entry_fields1, echo=FALSE} -bibtex_field_entry <- read.csv( - system.file("extdata/bibtex_field_entry.csv", - package = "cffr" - ), - sep = "," +df_table <- table_master[table_master$table == "entry_fields", -1] + +nms <- c( + "**field**", "**\\@article**", "**\\@book**", "**\\@booklet**", + "**\\@inbook**", "**\\@incollection**", "**\\@conference, \\@inproceedings**", + "**\\@manual**", "**\\@mastersthesis, phdthesis**", "**\\@misc**", + "**\\@proceedings**", "**\\@techreport**", "**\\@unpublished**" ) -t1 <- bibtex_field_entry[, c(1:7)] + +df_table[is.na(df_table)] <- "" +row.names(df_table) <- NULL +t1 <- df_table[, c(1:7)] +nm1 <- nms[1:7] knitr::kable(t1, - col.names = gsub("\\.", ",", names(t1)), - align = c("l", rep("c", 6)), - caption = "BibTeX, required fields by entry" + col.names = nm1, row.names = NA, align = c("l", rep("c", 6)), + caption = "**BibTeX**, required fields by entry" ) ``` ```{r entry_fields2, echo=FALSE} -t2 <- bibtex_field_entry[, c(1, 8:13)] - +t2 <- df_table[, c(1, 8:13)] +nm2 <- nms[c(1, 8:13)] knitr::kable(t2, - col.names = gsub("\\.", ",", names(t2)), - align = c("l", rep("c", 6)), - caption = "(cont) BibTeX, required fields by entry" + col.names = nm2, row.names = NA, align = c("l", rep("c", 6)), + caption = "(cont) **BibTeX**, required fields by entry" ) ``` -It can be observed that just a subset of fields is required in any of the Entries. For example, **title**, **year** and -**author** are either required or optional on almost every entry, while **crossref**, **annote** or **key** are never -required. +It can be seen that only a subset of fields is necessary for any entry. For +instance, **title**, **year**, and **author** are either required or optional in +almost every entry, whereas **crossref**, **annote**, or **key** are never +mandatory. ## Citation File Format -[Citation File Format (CFF](https://citation-file-format.github.io/)) [@druskat_citation_2021] are plain text files with -human- and machine-readable citation information for software (and datasets). Among the [valid keys of -CFF](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#valid-keys) there are two -keys, `preferred-citation` and `references` of special interest for citing and referring to related works[^4]: - -[^4]: See [Guide to Citation File Format schema version - 1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#preferred-citation). - -- **`preferred-citation`**: A reference to another work that should be cited instead of the software or dataset - itself. - -- **`references`**: Reference(s) to other creative works. Similar to a list of references in a paper, references of - the software or dataset may include other software (dependencies), or other research products that the software or - dataset builds on, but not work describing the software or dataset. - -These two keys are expected to be -[`definition.reference`](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreference) -objects, therefore they may contain the following keys: +[Citation File Format (CFF](https://citation-file-format.github.io/)) +[@druskat_citation_2021] consists of plain text files containing both human- and +machine-readable citation information for software and datasets. Within +[CFF]{.underline}, there are two important keys: `preferred-citation` and +`references`, which play a crucial role in citing and referring to related +works: + +- `preferred-citation`: Refers to another work that should be cited instead of + the software or dataset itself. +- `references`: Includes reference(s) to other creative works related to the + software or dataset. Similar to a list of references in a scholarly paper, + these references may encompass papers describing the abstract concepts of + the software or algorithms implemented in the software version. + +These two keys are expected to be `definition.reference objects`, as defined in +the [Guide to Citation File Format schema version +1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#preferred-citation), +and they may contain the following keys: ```{r refkeys, echo=FALSE, message=FALSE, warning=FALSE, results='asis'} library(cffr) # Fill with whites -l <- c(cff_schema_definitions_refs(), rep("", 4)) +init <- paste0("[", cff_schema_definitions_refs(), "]{.underline}") + +l <- c(init, rep("", 4)) refkeys <- matrix(l, ncol = 5, byrow = TRUE) knitr::kable(refkeys, - caption = "Valid keys on CFF `definition-reference` objects" + row.names = NA, + caption = "Valid keys on [CFF]{underline} `definition-reference` objects" +) +``` + +These keys are equivalent to the **BibTeX** [fields](#fields), with the +exception of the key [type]{.underline}. In [CFF]{.underline}, this key defines +the type of work[^2], making it analogous to the **BibTeX** [entries](#0). + +[^2]: See a complete list of possible values of [CFF]{.underline} + [type]{.underline} in [Appendix B](#appendix_cff_type). + +## Proposed Crosswalk + +The **cffr** package [@hernangomez2021] provides utilities for converting +**BibTeX** entries (via the **R** base function `bibentry()`) to +[CFF]{.underline} files and vice versa. This section describes how the +conversion between both formats has been implemented. The crosswalk is partially +based on @Haines_Ruby_CFF_Library_2021[^3]. + +[^3]: Note that this software performs only the conversion from + [CFF]{.underline} to **BibTeX**, however **cffr** can perform the conversion + in both directions. + +In the following two sections, I present an overview of the proposed mapping +between the **Entries** and **Fields** of **BibTeX** and the [CFF]{.underline} +keys. After this initial mapping, I propose further transformations to enhance +compatibility between both systems using different [Entry Models](#entrymodels). + +For better clarity, when a field is in **bold** (e.g., **\@book, edition**), it +corresponds to **BibTeX**, and when the field is [underlined]{.underline} (e.g., +[book, edition]{.underline}), it corresponds to [CFF]{.underline}. + +### Entry/Type Crosswalk + +For converting general **BibTeX** entries to [CFF]{.underline} +[types]{.underline}, the following crosswalk is proposed: + +```{r entry_bib2cff, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "entry_bib2cff", c(2:4)] +df_table[is.na(df_table)] <- "" +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +row.names(df_table) <- NULL + +knitr::kable(df_table, + col.names = c("**BibTeX** Entry", "[**CFF key: type**]{.underline}", "Notes"), + row.names = NA, + caption = "Entry/Type crosswalk: From **BibTeX** to [CFF]{.underline}" +) +``` + +The previous crosswalk has the following specifications: + +- **\@book**, **\@inbook**, and **\@incollection** are closely related in + **BibTeX**[^4]. While **\@inbook** and **\@incollection** both reference + parts of a **\@book**, the former is used for citing sections, chapters, + pages, or other specific parts, whereas the latter is used for citing parts + with a specific title. Since [CFF]{.underline} allows keys `type:book` and + `collection-type: book`, we may utilize a combination of these fields to tag + each entry type in [CFF]{.underline} accordingly. +- **\@mastersthesis** and **\@phdthesis** would be tagged using a combination + of `type:thesis` and `thesis-type`. + +[^4]: Note that **BibLaTeX** [@biblatexpack] handles **\@inbook** differently, + see [Appendix A](#appendix_inbook). + +Additionally, considering that [CFF]{.underline} allows for a wide range of +values[^5] for the [type]{.underline} field, the following conversion would be +applied from [CFF]{.underline} to **BibTeX**: + +[^5]: See [Appendix B](#appendix_cff_type) for all possible values. Information + extracted from @druskat2019. + +```{r entry_cff2bib, echo=FALSE,results='asis'} +df_table <- table_master[table_master$table == "entry_cff2bib", c(2:4)] +df_table[is.na(df_table)] <- "" +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +row.names(df_table) <- NULL + +knitr::kable(df_table, + col.names = c("[**CFF key: type**]{.underline}", "**BibTeX** Entry", "Notes"), + caption = "Entry/Type crosswalk: From [CFF]{.underline} to **BibTeX**" +) +``` + +### Fields/Key Crosswalk + +There is a significant similarity between the definitions and names of certain +**BibTeX** fields and [CFF]{.underline} keys. While the equivalence is +straightforward in some cases, there are instances where certain keys need to be +processed depending on the **entry** type. + +```{r fields_bib2cff, echo=FALSE,results='asis'} +df_table <- table_master[table_master$table == "fields_bib2cff", c(2:4)] +df_table[is.na(df_table)] <- "" +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +row.names(df_table) <- NULL + +knitr::kable(df_table, + col.names = c("**BibTeX Field**", "[CFF key]{.underline}", "Notes"), + caption = "**BibTeX** - [CFF]{.underline} Field/Key crosswalk" +) +``` + +We provide more detail on some of the mappings presented in the table above: + +- Some fields are not mapped because there is no clear equivalence with + [CFF]{.underline} keys (such as **annote**, **crossref**, and **key**). + Regarding the **type** field, the [CFF]{.underline} key [type]{.underline} + corresponds to the identifier of the work (similar to an entry in + **BibTeX**), therefore, **BibTeX type** won't be mapped. These fields are + always optional in **BibTeX**. + +- For the **address** field, its intended use in **BibTeX** varies depending + on the entry type (e.g., for **\@inproceedings**, it denotes the **address** + of the **conference**, while for **\@mastersthesis/\@phdthesis**, is the + **address** of the **school**, etc.). Mapping between **BibTeX** and + [CFF]{.underline} becomes more complex when related to institutions, + resulting in varying final mappings in [CFF]{.underline}. When converting + from [CFF]{.underline} to **BibTeX**, we propose to follow the same + entry-based logic, using the key [location]{.underline} as a fallback value + when converting to **address**. + +- In relation with this complexity mentioned above, **institution, + organization** and **school** would be mapped to [institution]{.underline}. + +- **series** would be mapped to [collection-title]{.underline} only on those + entries that does not requires **booktitle**. In practice, this means that + collection-title would correspond to **booktitle** for **incollection** and + **inproceedings**, and in the rest of cases it would correspond to series. A + consequence of this is that series information would be lost for + incollection and inproceedings, but on those cases is an optional field. + +- Regarding **series**, it would be mapped to [collection-title]{.underline} + only for those entries that do not require **booktitle**. In practice, this + means that [collection-title]{.underline} would correspond to **booktitle** + for **\@incollection** and **\@inproceedings**, while in other cases it + would correspond to **series**. As a consequence, **series** information + would be lost for **\@incollection** and **\@inproceedings**, but in those + cases, it is an optional field. + +- When converting from [CFF]{.underline} to **BibTeX**, we propose to use + [date-published]{.underline} as a fallback for extracting **month** and + **year** fields. + +- When **pages** is provided as a range separated by `--`, i.e, **pages = + {3--5}** would be parsed as [start: 3]{.underline}, [end: 5]{.underline} in + [CFF]{.underline}. + +Additionally, there are other [CFF]{.underline} keys that correspond to +**BibLaTeX** fields. We propose to include these fields in the crosswalk[^6], +even though they are not part of the core **BibTeX** fields definition. + +[^6]: See @biblatexcheatsheet for a preview of the accepted **BibLaTeX** fields. + +```{r fields_biblatex2cff, echo=FALSE,results='asis'} +df_table <- table_master[table_master$table == "fields_biblatex2cff", c(2:3)] +df_table[is.na(df_table)] <- "" +# fix links +df_table$f2 <- gsub("link_to_entry_models", "#entrymodels", df_table$f2) +row.names(df_table) <- NULL + +knitr::kable(df_table, + col.names = c("**BibLaTeX Field**", "[CFF key]{.underline}"), + caption = "**BibLaTeX** - [CFF]{.underline} Field/Key crosswalk" ) ``` -These keys are the equivalent to the fields of BibTeX (see [Fields]), with the exception of the key **type**. On CFF, -this key defines the type of work[^5], therefore this is the equivalent to the BibTeX entries (see [Entries](#entries)). - -[^5]: See a complete list of possible values of CFF type on the [Guide to Citation File Format schema version - 1.2.0](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencetype). - -## Proposed crosswalk - -The **cffr** package [@hernangomez2021] provides utilities from converting BibTeX entries (via the **R** base function -`bibentry()`) to CFF files and vice-versa. This section describes how the conversion between both formats have been -implemented. This crosswalk is based partially on @Haines_Ruby_CFF_Library_2021[^6]. - -[^6]: Note that this software performs only the conversion from CFF to BibTeX, however **cffr** can perform the - conversion in both directions. - -On the following two section I present an overview of the proposed mapping between the Entries and Fields of BibTeX and -the CFF keys. After this initial mapping, I propose further transformations to improve the compatibility between both -systems using different [Entry Models]. - -For a better understanding of this paper, when a field is in **bold** (i.e. **\@book**, **edition**) the field -correspond to **BibTex** and when the field is [underlined]{.underline} (i.e. [book]{.underline}, [edition]{.underline}) -the field correspond to [CFF]{.underline}. - -### Entry/Type crosswalk - -For converting general **BibTeX** entries to [CFF]{.underline} types, the following crosswalk is proposed: - -+----------------------------+-----------------------------------------------------------+----------------------------+ -| BibTeX Entry | [**Value of CFF key: type**]{.underline} | Notes | -+============================+===========================================================+============================+ -| **\@article** | [article]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@book** | [book]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@booklet** | [pamphlet]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@conference** | [conference-paper]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@inbook** | [book]{.underline} | See [Entry Models] | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@incollection** | [generic]{.underline} | See [Entry Models] | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@inproceedings** | [conference-paper]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@manual** | [manual]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@mastersthesis** | [thesis]{.underline} | See [Entry Models] | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@misc** | [generic]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@phdthesis** | [thesis]{.underline} | See [Entry Models] | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@proceedings** | [proceedings]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@techreport** | [report]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ -| **\@unpublished** | [unpublished]{.underline} | | -+----------------------------+-----------------------------------------------------------+----------------------------+ - -: Entry/Type crosswalk: From **BibTeX** to [CFF]{.underline} - -Also, given that CFF provides with a [wide range of allowed -values](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#definitionsreferencetype) -on type, the following conversion would be performed from [CFF]{.underline} to **BibTeX**: - -+------------------------------------+---------------------------------+---------------------------------------------+ -| [Value of CFF key: | BibTeX Entry | Notes | -| type]{.underline} | | | -+====================================+=================================+=============================================+ -| [book]{.underline} | **\@book** **/ \@inbook** | See [Entry Models] | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [conference]{.underline} | **\@inproceedings** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [conference-paper]{.underline} | **\@inproceedings** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [magazine-article]{.underline} | **\@article** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [manual]{.underline} | **\@manual** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [newspaper-article]{.underline} | **\@article** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [pamphlet]{.underline} | **\@booklet** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [proceedings]{.underline} | **\@proceedings** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [report]{.underline} | **\@techreport** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [thesis]{.underline} | **\@mastersthesis / | See [Entry Models] | -| | \@phdthesis** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [unpublished]{.underline} | **\@unpublished** | | -+------------------------------------+---------------------------------+---------------------------------------------+ -| [generic]{.underline} | **\@misc / \@incollection** | Under specific conditions, see [Entry | -| | | Models] | -+------------------------------------+---------------------------------+---------------------------------------------+ -| \ | **\@misc** | | -+------------------------------------+---------------------------------+---------------------------------------------+ - -: Entry/Type crosswalk: From [CFF]{.underline} to **BibTeX** - -### Fields/Key crosswalk - -There is a large degree of similarity between the definition and names of some **BibTeX** fields and [CFF]{.underline} -keys. On the following cases, the equivalence is almost straightforward: - -| BibTeX Field | [CFF key]{.underline} | -|------------------|-----------------------------------------| -| **address** | See [Entry Models] | -| ***annote*** | \- | -| **author** | [authors]{.underline} | -| **booktitle** | [collection-title]{.underline} | -| **chapter** | [section]{.underline} | -| ***crossref*** | \- | -| **edition** | [edition]{.underline} | -| **editor** | [editors]{.underline} | -| **howpublished** | [medium]{.underline} | -| **institution** | See [Entry Models] | -| **journal** | [journal]{.underline} | -| ***key*** | \- | -| **month** | [month]{.underline} | -| **note** | [notes]{.underline} | -| **number** | [issue]{.underline} | -| **organization** | See [Entry Models] | -| **pages** | [start]{.underline} & [end]{.underline} | -| **publisher** | [publisher]{.underline} | -| **school** | See [Entry Models] | -| **series** | See [Entry Models] | -| **title** | [title]{.underline} | -| ***type*** | \- | -| **volume** | [volume]{.underline} | -| **year** | [year]{.underline} | - -: BibTeX - CFF Field/Key crosswalk - -Additionally, there are other additional CFF keys that have a correspondence with BibLaTeX fields. We propose also to -include these fields on the crosswalk[^7], although they are not part of the core BibTeX fields definition. - -[^7]: See @biblatexcheatsheet for a preview of the accepted BibLaTeX fields. - -| BibLaTeX Field | [CFF key]{.underline} | -|----------------|------------------------------| -| **abstract** | [abstract]{.underline} | -| **date** | [date-published]{.underline} | -| **doi** | [doi]{.underline} | -| **file** | [filename]{.underline} | -| **isbn** | [isbn]{.underline} | -| **issn** | [issn]{.underline} | -| **issuetitle** | [issue-title]{.underline} | -| **pagetotal** | [pages]{.underline} | -| **translator** | [translators]{.underline} | -| **url** | [url]{.underline} | -| **urldate** | [date-accessed]{.underline} | -| **version** | [version]{.underline} | - -: BibLaTeX - CFF Field/Key crosswalk - -## Entry Models - -This section presents the specific mapping proposed for each of the BibTeX entries, providing further information on how -each field is treated. Examples are adapted from the [xampl.bib](https://tug.org/texmf-docs/bibtex/xampl.bib) file -provided with the bibtex package [@patashnik]. - -### article +## Entry Models {#entrymodels} + +This section presents the specific mapping proposed for each of the **BibTeX** +entries, providing further information on how each field is treated. Examples +are adapted from the [xampl.bib](https://tug.org/texmf-docs/bibtex/xampl.bib) +file provided with the **bibtex** package [@patashnik]. + +### \@article {#article} The crosswalk of **\@article** does not require any special treatment. -+------------------------+------------------------------------------+------------------------------------------------+ -| BibTeX | [CFF]{.underline} | Note | -+========================+==========================================+================================================+ -| **\@article** | [type: article]{.underline} | When converting CFF to BibTeX, [type | -| | | magazine-article]{.underline} and | -| | | [newspaper-article]{.underline} are converted | -| | | to **\@article**. | -+------------------------+------------------------------------------+------------------------------------------------+ -| **author\*** | [authors]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ -| **title\*** | [title]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ -| **journal\*** | [journal]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ -| **year\*** | [year]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ -| **volume** | [volume]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ -| **number** | [issue]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ -| **pages** | [start]{.underline} and | Separated by `--`, i.e, **pages = {3\--5}** | -| | [end]{.underline} | would be parsed as: | -| | | | -| | | - [start: 3]{.underline} | -| | | | -| | | - [end: 5]{.underline} | -+------------------------+------------------------------------------+------------------------------------------------+ -| **month** | [month]{.underline} | As a fallback, **month** could be extracted | -| | | also from **date** (BibLaTeX field) or | -| | | [date-published]{.underline} | -+------------------------+------------------------------------------+------------------------------------------------+ -| **note** | [notes]{.underline} | | -+------------------------+------------------------------------------+------------------------------------------------+ - -: **\@article** Model +```{r model_article, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_article", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@article** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @article{article-full, @@ -502,7 +557,7 @@ The crosswalk of **\@article** does not require any special treatment. } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE} bib <- "@article{article-full, @@ -519,69 +574,53 @@ bib <- "@article{article-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) -``` - -### book/inbook - -In terms of field required on BibTeX, the only difference between **\@book** and **\@inbook** is that the latter -requires also a **chapter** or **pages**, while for **\@book** these fields are not even optional. So we propose here to -identify an **\@inbook** on CFF as a [book]{.underline} with [section]{.underline} and -[start]{.underline}-[end]{.underline} fields (CFF). - -Another specificity is that **series** field is mapped to [collection-title]{.underline} and **address** is mapped as -the [address]{.underline} of the [publisher]{.underline} (CFF). - -+----------------------+---------------------------+------------------------------------------------------------------+ -| BibTeX | [CFF]{.underline} | Note | -+======================+===========================+==================================================================+ -| **\@book** | [type: book]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **\@inbook** | [type: book]{.underline} | For identifying an **\@inbook** in CFF, assess if | -| | | [section]{.underline} or [start/end]{.underline} information is | -| | | available | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **author\*** | [authors]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **editor\*** | [editors]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **title\*** | [title]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **publisher\*** | [publisher]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **year\*** | [year]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **chapter\*** | [section]{.underline} | Only required on **\@inbook** | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **pages\*** | [start]{.underline} and | Only required on **\@inbook** | -| | [end]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **volume** | [volume]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **number** | [issue]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **series** | [coll | | -| | ection-title]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **address** | [address]{.underline} | As a fallback, the field [location]{.underline} can be used | -| | property of | | -| | [publisher]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **edition** | [edition]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+----------------------+---------------------------+------------------------------------------------------------------+ -| **note** | [notes]{.underline} | | -+----------------------+---------------------------+------------------------------------------------------------------+ - -: **\@book/\@inbook** Model - -**Examples: book** - -[*BibTeX entry*]{.underline} +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +### \@book / \@inbook {#book-inbook} + +In terms of the fields required in BibTeX, the primary difference between +**\@book** and **\@inbook** is that **\@inbook** requires a **chapter** or +**page** field, while **\@book** does not even allow these fields as optional. +Therefore, we propose that an **\@inbook** entry in [CFF]{.underline} be treated +as a **\@book** with the following supplementary fields: + +1. [section]{.underline}: To denote the specific **chapter** within the book. +2. [start-end]{.underline}: To indicate the range of **pages** covered by the + section. + +Additionally, note that in [CFF]{.underline}, the **series** field corresponds +to [collection-title]{.underline}, and the **address** field represents the +[publisher]{.underline}'s [address]{.underline}. By last, the key +[collection-type]{.underline} would be populated with [book-series]{.underline}. + +```{r model_book, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_book", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@book / \\@inbook** Model" +) +``` + +There are notable differences in how **BibTeX** and **BibLaTeX** handle the +**\@inbook** entry (further discussed in the [Appendix A](#appendix_inbook)). We +propose to treat a **BibLaTeX \@inbook** as a **BibTeX \@incollection.** + +**Examples: \@book** + +**BibTeX entry** ``` bibtex @book{book-full, @@ -598,7 +637,7 @@ the [address]{.underline} of the [publisher]{.underline} (CFF). } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE} bib <- "@book{book-full, @@ -617,15 +656,15 @@ bib <- "@book{book-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r, echo=FALSE} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) ``` -**Examples: inbook** +**Examples: \@inbook** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @inbook{inbook-full, @@ -645,7 +684,7 @@ toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@inbook{inbook-full, @@ -667,47 +706,36 @@ bib <- "@inbook{inbook-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) ``` -### booklet +### \@booklet {#booklet} In **\@booklet** **address** is mapped to [location]{.underline}. -+---------------------+---------------------+--------------------------------------------------------------------------+ -| BibTeX | [CFF]{.underline} | Note | -+=====================+=====================+==========================================================================+ -| **\@booklet** | [type: | | -| | pa | | -| | mphlet]{.underline} | | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **title\*** | [title]{.underline} | | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **author\*** | [a | | -| | uthors]{.underline} | | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **howpublished** | [ | | -| | medium]{.underline} | | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **address** | [lo | | -| | cation]{.underline} | | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **year** | [year]{.underline} | As a fallback, **year** could be extracted also from **date** (BibLaTeX | -| | | field)/ [date-published]{.underline} | -+---------------------+---------------------+--------------------------------------------------------------------------+ -| **note** | [notes]{.underline} | | -+---------------------+---------------------+--------------------------------------------------------------------------+ - -: **\@booklet** Model +```{r model_booklet, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_booklet", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@booklet** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @booklet{booklet-full, @@ -721,7 +749,7 @@ In **\@booklet** **address** is mapped to [location]{.underline}. } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE, } bib <- "@booklet{booklet-full, @@ -737,61 +765,38 @@ bib <- "@booklet{booklet-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE, } -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) -``` - -### conference/inproceedings - -Note that in this case, **organization** is mapped to [institution]{.underline}, as BibTeX does not prescribe the use of -**institution** on these entries. - -+---------------------------+----------------------------+-------------------------------------------------------------+ -| BibTeX | CFF | Note | -+===========================+============================+=============================================================+ -| **\@conference / | [type: | CFF entries with [type; conference]{.underline} are mapped | -| \@inproceedings** | con | back to **\@inproceedings**. | -| | ference-paper]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **author\*** | [authors]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **title\*** | [title]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **booktitle\*** | [col | | -| | lection-title]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **year\*** | [year]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **editor** | [editors]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **volume** | [volume]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **number** | [issue]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **series** | [conference]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **pages** | [start]{.underline} and | See **Note** on [article] | -| | [end]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **address** | [location]{.underline} | As a fallback, [address]{.underline} property of | -| | | [conference]{.underline} can be used | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **organization** | [institution]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **publisher** | [publisher]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ -| **note** | [notes]{.underline} | | -+---------------------------+----------------------------+-------------------------------------------------------------+ - -: **\@conference/\@inproceedings** Model +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +### \@conference / \@inproceedings {#conf_inproc} + +Note that in this case, **organization** is mapped to [institution]{.underline}. +Additionally, **series** would be ignored as there is not clear mapping on +[CFF]{.underline} for this field. + +```{r model_inproceedings, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_inproceedings", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@conference / \\@inproceedings** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @inproceedings{inproceedings-full, @@ -810,7 +815,7 @@ Note that in this case, **organization** is mapped to [institution]{.underline}, } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@inproceedings{inproceedings-full, @@ -831,63 +836,42 @@ bib <- "@inproceedings{inproceedings-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) -``` - -### incollection - -As **booktitle** is a required field, we propose to map that field to [collection-title]{.underline} and the -[type]{.underline} to [generic]{.underline}. Therefore, an **\@incollection** is a [type: generic]{.underline} with a -[collection-title]{.underline} key. - -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **BibTeX** | [CFF]{.underline} | Note | -+=========================+=================================================+=========================================+ -| **\@incollection** | [type: generic]{.underline} | Including a | -| | | [collection-title]{.underline} value | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **author\*** | [authors]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **title\*** | [title]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **booktitle\*** | [collection-title]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **publisher\*** | [publisher]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **year\*** | [year]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **editor** | [editors]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **volume** | [volume]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **number** | [issue]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **series** | [series]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **type** | \- | Ignored | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **chapter** | [section]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **pages** | [start]{.underline} and [end]{.underline} | See **Note** on [article] | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **address** | [address]{.underline} property of | See **Note** on [book/inbook] | -| | [publisher]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **edition** | [edition]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+-------------------------+-------------------------------------------------+-----------------------------------------+ -| **note** | [notes]{.underline} | | -+-------------------------+-------------------------------------------------+-----------------------------------------+ - -: **\@incollection** Model +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +### \@incollection {#incol} + +As **booktitle** is a required field, we propose to map that field to +[collection-title]{.underline} and the [type]{.underline} to +[generic]{.underline}. Therefore, an **\@incollection** is a [type: +generic]{.underline} with a [collection-title]{.underline} key. + +Additionally, **series** and **type** would be ignored as there is not clear +mapping on [CFF]{.underline} for this field. + +```{r model_incollection, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_incollection", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@incollection** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @incollection{incollection-full, @@ -909,7 +893,7 @@ As **booktitle** is a required field, we propose to map that field to [collectio } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@incollection{incollection-full, @@ -933,46 +917,40 @@ bib <- "@incollection{incollection-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) -``` - -### manual - -As in the case of [conference/inproceedings], **organization** is mapped to [institution]{.underline}. - -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **BibTeX** | [CFF]{.underline} | Note | -+============================+============================================+===========================================+ -| **\@manual** | [type: manual]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **title\*** | [title]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **author** | [authors]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **organization** | [institution]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **address** | [location]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **edition** | [edition]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **year** | [year]{.underline} | See **Note** on [booklet] | -+----------------------------+--------------------------------------------+-------------------------------------------+ -| **note** | [notes]{.underline} | | -+----------------------------+--------------------------------------------+-------------------------------------------+ - -: **\@manual** Model +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +### \@manual + +As in the case of [**\@conference** / **\@inproceedings**](#conf_inproc), +**organization** is mapped to [institution]{.underline}. + +```{r model_manual, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_manual", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@manual** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** -Note that **month** can't be parsed to a single integer in the range `1--12` as required on CFF, so it is not parsed to -avoid validation errors. +Note that **month** can't be parsed to a single integer in the range `1--12` as +required on CFF, so it is not parsed to avoid validation errors. ``` bibtex @manual{manual-full, @@ -987,7 +965,7 @@ avoid validation errors. } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@manual{manual-full, @@ -1004,52 +982,44 @@ bib <- "@manual{manual-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) -``` - -### mastersthesis/phdthesis - -In terms of field required on BibTeX, it is identical for both **\@mastersthesis** and **\@phdthesis.** - -We propose here to identify each type of thesis using the field [thesis-type]{.underline} (CFF). So if -[thesis-type]{.underline} contains a [regex pattern](https://regex101.com/r/mBWfbs/1) `(?i)(phd)` it would be recognized -as **\@phdthesis**. - -+------------------------+------------------------------------------+-------------------------------------------------+ -| BibTeX | [CFF]{.underline} | Note | -+========================+==========================================+=================================================+ -| **\@mastersthesis** | [type: thesis]{.underline} | Use also [thesis-type]{.underline} for | -| | | identifying the thesis type. | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **\@phdthesis** | [type: thesis]{.underline} | Use also [thesis-type]{.underline} for | -| | | identifying the thesis type. | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **author\*** | [authors]{.underline} | | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **title\*** | [title]{.underline} | | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **school\*** | [institution]{.underline} | | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **year\*** | [year]{.underline} | | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **type** | | | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **address** | [address]{.underline} property of | See **Note** on [book/inbook] | -| | [institution]{.underline} | | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+------------------------+------------------------------------------+-------------------------------------------------+ -| **note** | [notes]{.underline} | | -+------------------------+------------------------------------------+-------------------------------------------------+ - -: **\@mastersthesis/phdthesis** Model - -**Examples: mastersthesis** - -[*BibTeX entry*]{.underline} +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +### \@mastersthesis / \@phdthesis + +In terms of field required on BibTeX, it is identical for both +**\@mastersthesis** and **\@phdthesis.** + +We propose here to identify each type of thesis using the key +[thesis-type]{.underline} So if [thesis-type]{.underline} contains a [regex +pattern](https://regex101.com/r/mBWfbs/1) `(?i)(phd)` it would be recognized as +**\@phdthesis**. + +Additionally, **school** would be mapped to [institution]{.underline}. + +```{r model_thesis, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_thesis", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@mastersthesis / \\@phdthesis** Model" +) +``` + +**Examples: \@mastersthesis** + +**BibTeX entry** ``` bibtex @mastersthesis{mastersthesis-full, @@ -1064,7 +1034,7 @@ as **\@phdthesis**. } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE} bib <- "@mastersthesis{mastersthesis-full, @@ -1081,15 +1051,15 @@ bib <- "@mastersthesis{mastersthesis-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r, echo=FALSE} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) ``` -**Examples: phdthesis** +**Examples: \@phdthesis** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @phdthesis{phdthesis-full, @@ -1104,7 +1074,7 @@ toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@phdthesis{phdthesis-full, @@ -1121,42 +1091,42 @@ bib <- "@phdthesis{phdthesis-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) ``` -### misc +### \@misc -The crosswalk of **\@misc** does not require any special treatment. This entry does not require any field. +The crosswalk of **\@misc** does not require any special treatment. This +**entry** does not require any **field**. -Note also that it is mapped to [type: generic]{.underline} as [incollection], but in this case **booktitle** is not even -an option, so the proposed definition should cover both **\@misc** and **\@incollection** without problems. +Note also that it is mapped to [type: generic]{.underline} as +[**\@incollection**](#incol), but in this case **booktitle** is not even an +option, so the proposed definition should cover both **\@misc** and +**\@incollection** without problems. -+----------------------------+---------------------------------------------+------------------------------------------+ -| **BibTeX** | [CFF]{.underline} | Note | -+============================+=============================================+==========================================+ -| **\@misc** | [type: generic]{.underline} | | -+----------------------------+---------------------------------------------+------------------------------------------+ -| **author** | [authors]{.underline} | | -+----------------------------+---------------------------------------------+------------------------------------------+ -| **title** | [title]{.underline} | | -+----------------------------+---------------------------------------------+------------------------------------------+ -| **howpublished** | [medium]{.underline} | | -+----------------------------+---------------------------------------------+------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+----------------------------+---------------------------------------------+------------------------------------------+ -| **year** | [year]{.underline} | See **Note** on [booklet] | -+----------------------------+---------------------------------------------+------------------------------------------+ -| **note** | [notes]{.underline} | | -+----------------------------+---------------------------------------------+------------------------------------------+ +```{r model_misc, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_misc", c(2:4)] +df_table[is.na(df_table)] <- "" -: **\@misc** Model +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@misc** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @misc{misc-full, @@ -1169,7 +1139,7 @@ an option, so the proposed definition should cover both **\@misc** and **\@incol } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@misc{misc-full, @@ -1184,61 +1154,45 @@ bib <- "@misc{misc-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) ``` -### proceedings +### \@proceedings -The proposed model is similar to [conference/inproceedings]. Note that **\@proceedings** does not prescribe a **author** -field. On this cases, as [authors]{.underline} is required on CFF, we would use *anonymous*[^8] when converting to CFF -and omit it on the conversion back to CFF. +The proposed model is consistent with [**\@conference** / +**\@inproceedings**](#conf_inproc). Note that **\@proceedings** does not +prescribe a **author** field. On this cases, as [authors]{.underline} is +required on [CFF]{.underline}, we would use *anonymous*[^7] when converting to +[CFF]{.underline} and omit it on the conversion from [CFF]{.underline} to +**BibTeX**. -[^8]: As proposed on [*How to deal with unknown individual +[^7]: As proposed on [*How to deal with unknown individual authors?*](https://github.com/citation-file-format/citation-file-format/blob/main/schema-guide.md#how-to-deal-with-unknown-individual-authors), **(Guide to Citation File Format schema version 1.2.0)** -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| BibTeX | [CFF]{.underline} | Note | -+=======================+=======================+====================================================================+ -| **\@proceedings** | [type: | | -| | pro | | -| | ceedings]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **title\*** | [title]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **year\*** | [year]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **editor** | [editors]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **volume** | [volume]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **number** | [issue]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **series** | [co | | -| | nference]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **address** | [ | As a fallback, [address]{.underline} property of | -| | location]{.underline} | [conference]{.underline} can be used | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **organization** | [ins | | -| | titution]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **publisher** | [p | | -| | ublisher]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ -| **note** | [notes]{.underline} | | -+-----------------------+-----------------------+--------------------------------------------------------------------+ - -: **\@conference/\@inproceedings** Model +```{r model_proceedings, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_proceedings", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@proceedings** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @proceedings{proceedings-full, @@ -1274,44 +1228,36 @@ bib <- "@proceedings{proceedings-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) -``` - -### techreport - -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **BibTeX** | [CFF]{.underline} | Note | -+=========================+=============================================================+=============================+ -| **\@techreport** | [type: report]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **author\*** | [authors]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **title\*** | [title]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **institution\*** | [institution]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **year\*** | [year]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **type** | \- | Ignored | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **number** | [issue]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **address** | [address]{.underline} property of [institution]{.underline} | See **Note** on | -| | | [book/inbook] | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+-------------------------+-------------------------------------------------------------+-----------------------------+ -| **note** | [notes]{.underline} | | -+-------------------------+-------------------------------------------------------------+-----------------------------+ - -: **\@techreport** Model +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +### \@techreport + +The crosswalk of **\@techreport** does not require any special treatment. + +```{r model_techreport, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_techreport", c(2:4)] +df_table[is.na(df_table)] <- "" + +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) + +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@techreport** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @techreport{techreport-full, @@ -1327,7 +1273,7 @@ toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@techreport{techreport-full, @@ -1345,35 +1291,36 @@ bib <- "@techreport{techreport-full, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) ``` -### unpublished +### \@unpublished + +The crosswalk of **\@unpublished** does not require any special treatment. + +```{r model_unpublished, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "model_unpublished", c(2:4)] +df_table[is.na(df_table)] <- "" -+----------------------------+------------------------------------------------+---------------------------------------+ -| **BibTeX** | [CFF]{.underline} | Note | -+============================+================================================+=======================================+ -| **\@unpublished** | [type: unpublished]{.underline} | | -+----------------------------+------------------------------------------------+---------------------------------------+ -| **author\*** | [authors]{.underline} | | -+----------------------------+------------------------------------------------+---------------------------------------+ -| **title\*** | [title]{.underline} | | -+----------------------------+------------------------------------------------+---------------------------------------+ -| **note\*** | [notes]{.underline} | | -+----------------------------+------------------------------------------------+---------------------------------------+ -| **month** | [month]{.underline} | See **Note** on [article] | -+----------------------------+------------------------------------------------+---------------------------------------+ -| **year** | [year]{.underline} | See **Note** on [booklet] | -+----------------------------+------------------------------------------------+---------------------------------------+ +# fix links +df_table$f3 <- gsub("link_to_entry_models", "#entrymodels", df_table$f3) +df_table$f3 <- gsub("link_to_article", "#article", df_table$f3) +df_table$f3 <- gsub("link_to_booklet", "#booklet", df_table$f3) +df_table$f3 <- gsub("link_to_book", "#book-inbook", df_table$f3) -: **\@unpublished** Model +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("**BibTeX**", "[CFF]{.underline}", "Notes"), + caption = "**\\@unpublished** Model" +) +``` **Examples** -[*BibTeX entry*]{.underline} +**BibTeX entry** ``` bibtex @unpublished{unpublished-minimal, @@ -1383,7 +1330,7 @@ toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) } ``` -[*CFF entry*]{.underline} +[CFF entry]{.underline} ```{r echo=FALSE,} bib <- "@unpublished{unpublished-minimal, @@ -1395,10 +1342,98 @@ bib <- "@unpublished{unpublished-minimal, cff_from_bibtex(bib) ``` -[*From CFF to BibTeX*]{.underline} +From [CFF]{.underline} to **BibTeX** + +```{r echo=FALSE,} +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +## Appendix A: **\@inbook** in BibTeX and BibLaTeX {#appendix_inbook} + +The definition of **\@inbook** and **\@incollection** in **BibTeX** +[@patashnik1988] is as follows: + +> - **\@inbook**: A part of a book, which may be a chapter (or section) and/or +> a range of pages. Required fields: author or editor, title, chapter and/or +> pages, publisher, year (...) +> +> - **\@incollection**: A part of a book having its own title. Required +> fields: author, title, booktitle, publisher, year (...) + +Whereas **BibLaTeX** [@biblatexpack] specifies: + +> - **\@inbook:** A part of a book which forms a self-contained unit with its +> own title. Note that the [profile]{.underline} of this entry type is +> [different from standard BibTeX]{.underline}, see § 2.3.1. Required +> fields: author, title, booktitle, year/date (...). + +When considering required fields, an important difference is **booktitle** +requirement in **BibLaTeX**. Notably, **BibTeX \@incollection** requires also +this field. Moreover, both **BibTeX \@incollection** and **BibLaTeX \@inbook** +emphasize its reference to *"a part of a book (...) with its own title"*. + +In this document, the proposed crosswalk ensures full compatibility with +**BibTeX**. Hence, we propose to consider a **BibLaTeX \@inbook** entry as +equivalent to a **BibTeX \@incollection**, given the congruence in their +definitions and field requirements. + +**Examples** + +**BibTeX entry** + +``` bibtex +@inbook{inbook-biblatex, + author = {Yihui Xie and Christophe Dervieux and Emily Riederer}, + title = {Bibliographies and citations}, + booktitle = {{R} Markdown Cookbook}, + date = {2023-12-30}, + publisher = {Chapman and Hall/CRC}, + address = {Boca Raton, Florida}, + series = {The {R} Series}, + isbn = 9780367563837, + url = {https://bookdown.org/yihui/rmarkdown-cookbook}, + chapter = {4.5} +} +``` + +[CFF entry]{.underline} + +```{r echo=FALSE,} +bib <- "@inbook{inbook-biblatex, + author = {Yihui Xie and Christophe Dervieux and Emily Riederer}, + title = {Bibliographies and citations}, + booktitle = {{R} Markdown Cookbook}, + date = {2023-12-30}, + publisher = {Chapman and Hall/CRC}, + address = {Boca Raton, Florida}, + series = {The {R} Series}, + isbn = 9780367563837, + url = {https://bookdown.org/yihui/rmarkdown-cookbook}, + chapter = {4.5} +}" + +cff_from_bibtex(bib) +``` + +From [CFF]{.underline} to **BibTeX** ```{r echo=FALSE,} -toBibtex(cff_to_bibtex(cff_from_bibtex(bib))) +toBibtex(cff_to_bibentry(cff_from_bibtex(bib))) +``` + +## Appendix B: [CFF key:type]{.underline} values {#appendix_cff_type} + +From @druskat2019 Table 4: Complete list of [CFF]{.underline} reference types. + +```{r cff_types, echo=FALSE, results='asis'} +df_table <- table_master[table_master$table == "cff_types", c(2:3)] +df_table[is.na(df_table)] <- "" +row.names(df_table) <- NULL +knitr::kable(df_table, + col.names = c("Reference type string", "Description"), + row.names = NA, + caption = "Complete list of [CFF]{.underline} reference types." +) ``` ## References diff --git a/vignettes/cffr.Rmd b/vignettes/cffr.Rmd index c6b97152..030c065a 100644 --- a/vignettes/cffr.Rmd +++ b/vignettes/cffr.Rmd @@ -254,7 +254,7 @@ simplified as: allkeys <- list( "url" = "https://ropensci.org/", "version" = "0.0.1", - "repository" = "https://github.com/user/repo", + "repository" = "https://github.com/ropensci/cffr", # If the field is already present, it would be overridden title = "Modifying a 'cff' object", authors = newauthors, diff --git a/vignettes/crosswalk.Rmd b/vignettes/crosswalk.Rmd index 0acf2d20..e1cb1741 100644 --- a/vignettes/crosswalk.Rmd +++ b/vignettes/crosswalk.Rmd @@ -3,7 +3,7 @@ title: "From R to CFF" subtitle: "Crosswalk" description: > A comprehenshive description of the internal mappings performed by `cffr`. -author: Diego Hernangómez ORCID logo +author: Diego Hernangómez bibliography: REFERENCES.bib link-citations: yes output: