Closed maelle closed 3 years ago
And to generate the text citation without needing to remember to update it (you'd just need to remember to re-build the website after a release), the code below would work (tested on the dev guide DOI)
sprintf(
"%s. (%s). %s (version %s). Zenodo. %s",
glue::glue_collapse(purrr::map_chr(json$metadata$creators, "name"), sep = ", ", last=" and "),
lubridate::year(json$metadata$publication_date),
json$metadata$title,
json$metadata$version,
paste0("https://doi.org/", json$metadata$doi)
)
Reprex below for the dev guide
cat("\n```bibtex\n")
#>
#> ```bibtex
zenodo <- zen4R::ZenodoManager$new(
token = Sys.getenv("ZENODO_TOKEN")
)
#> Warning in default_backend_auto(): Selecting 'env' backend. Secrets are stored
#> in environment variables
guide <- zenodo$getDepositionByConceptDOI("10.5281/zenodo.2553043")
#> Warning in Sys.setlocale("LC_TIME", "us_US"): la requête OS pour spécifier la
#> localisation à "us_US" n'a pas pu être honorée
guide$exportAsBibTeX("dev_citation")
cat(readLines("dev_citation_BibTeX.bib"), sep = "\n")
#> Warning in readLines("dev_citation_BibTeX.bib"): ligne finale incomplète trouvée
#> dans 'dev_citation_BibTeX.bib'
#> @software{ropensci_2021_4554776,
#> author = {rOpenSci and
#> Brooke Anderson and
#> Scott Chamberlain and
#> Laura DeCicco and
#> Julia Gustavsen and
#> Anna Krystalli and
#> Mauro Lepore and
#> Lincoln Mullen and
#> Karthik Ram and
#> Noam Ross and
#> Maëlle Salmon and
#> Melina Vidoni},
#> title = {{rOpenSci Packages: Development, Maintenance, and
#> Peer Review}},
#> month = feb,
#> year = 2021,
#> publisher = {Zenodo},
#> version = {0.6.0},
#> doi = {10.5281/zenodo.4554776},
#> url = {https://doi.org/10.5281/zenodo.4554776}
#> }
guide$exportAsJSON("dev_citation")
json <- jsonlite::read_json("dev_citation_JSON.json")
sprintf(
"%s. (%s). %s (version %s). Zenodo. %s",
glue::glue_collapse(purrr::map_chr(json$metadata$creators, "name"), sep = ", ", last=" and "),
lubridate::year(json$metadata$publication_date),
json$metadata$title,
json$metadata$version,
paste0("https://doi.org/", json$metadata$doi)
)
#> [1] "rOpenSci, Brooke Anderson, Scott Chamberlain, Laura DeCicco, Julia Gustavsen, Anna Krystalli, Mauro Lepore, Lincoln Mullen, Karthik Ram, Noam Ross, Maëlle Salmon and Melina Vidoni. (2021). rOpenSci Packages: Development, Maintenance, and Peer Review (version 0.6.0). Zenodo. https://doi.org/10.5281/zenodo.4554776"
fs::file_delete(c("dev_citation_BibTeX.bib", "dev_citation_JSON.json"))
Created on 2021-02-22 by the reprex package (v1.0.0.9001)
@steffilazerte Can you please digest this 🙂 and after reviewing, merge the PR & update NEWS?
I think it looks good! l looked into the idea of automating the citation, but after talking to @stefaniebutland, I think we'll leave it as is for now. Thanks @maelle!
Feel free to merge!
I was also hoping to create a BibTex chunk as we now have in the dev guide (thanks to Hugo Gruson's suggestion) but I suspect I don't have the correct access rights to the Zenodo records.
The idea would be to install zen4R (+ add it to DESCRIPTION), create a Zenodo API key (+ add it to repo secrets) and run