diff --git a/.Rbuildignore b/.Rbuildignore index 0d42a0f..b9f4eb5 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,3 +16,4 @@ references.bib citeproc_json_from_rorcid.json appveyor.yml ^LICENSE\.md$ +vignettes/handlr.Rmd diff --git a/Makefile b/Makefile index 1eff740..41a81e4 100644 --- a/Makefile +++ b/Makefile @@ -26,3 +26,8 @@ check_windows: readme: ${RSCRIPT} -e "knitr::knit('README.Rmd')" + +vign: + cd vignettes;\ + ${RSCRIPT} -e "Sys.setenv(NOT_CRAN='true'); knitr::knit('handlr.Rmd.og', output = 'handlr.Rmd')";\ + cd .. diff --git a/README.Rmd b/README.Rmd index 5d3e9d9..44b47bd 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,25 +19,25 @@ knitr::opts_chunk$set( a tool for converting among citation formats. -heavily influenced by, and code ported from +heavily influenced by, and code ported from the Ruby gem `bolognese` supported readers: -- [citeproc][] -- [ris][] -- [bibtex][] (requires suggested package `bibtex`) -- [codemeta][] -- [cff][] +- citeproc +- ris +- bibtex +- codemeta +- cff supported writers: -- [citeproc][] -- [ris][] -- [bibtex][] -- [schema.org][] -- [rdfxml][] (requires suggested package [jsonld][]) -- [codemeta][] -- [cff][] +- citeproc +- ris +- bibtex +- schemaorg +- rdfxml +- codemeta +- cff not supported yet, but plan to: @@ -57,58 +57,10 @@ dev version remotes::install_github("ropensci/handlr") ``` -```{r} +```{r eval=FALSE} library("handlr") ``` -## All in one - -There's a single R6 interface to all readers and writers - -```{r} -z <- system.file("extdata/citeproc.json", package = "handlr") -x <- HandlrClient$new(x = z) -x -``` - -read the file - -```{r} -x$read(format = "citeproc") -``` - -the parsed content - -```{r} -x$parsed -``` - -write out bibtex - -```{r} -cat(x$write("bibtex"), sep = "\n") -``` - -## Choose your own adventure - -Instead of using the `HandlrClient`, you can use the regular functions for each -reader or writer. They are: - -- `citeproc_reader()` / `citeproc_writer()` -- `ris_reader()` / `ris_writer()` -- `bibtex_reader()` / `bibtex_writer()` -- `codemeta_reader()` / `codemeta_writer()` -- `schema_org_writer()` -- `rdf_xml_writer()` - -## Convert data to data.frame - -```{r} -z <- system.file('extdata/bib-many.bib', package = "handlr") -res2 <- bibtex_reader(x = z) -handl_to_df(res2) -``` - ## Meta * Please [report any issues or bugs](https://github.com/ropensci/handlr/issues). @@ -117,13 +69,3 @@ handl_to_df(res2) * Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms. [![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org) - - -[jsonld]: https://github.com/ropensci/jsonld/ -[codemeta]: https://codemeta.github.io/ -[citeproc]: https://en.wikipedia.org/wiki/CiteProc -[ris]: https://en.wikipedia.org/wiki/RIS_(file_format) -[bibtex]: http://www.bibtex.org/ -[schema.org]: https://schema.org/ -[rdfxml]: https://en.wikipedia.org/wiki/RDF/XML -[cff]: https://citation-file-format.github.io/ diff --git a/README.md b/README.md index f73c7ce..9efc7ff 100644 --- a/README.md +++ b/README.md @@ -13,25 +13,25 @@ handlr a tool for converting among citation formats. -heavily influenced by, and code ported from +heavily influenced by, and code ported from the Ruby gem `bolognese` supported readers: -- [citeproc][] -- [ris][] -- [bibtex][] (requires suggested package `bibtex`) -- [codemeta][] -- [cff][] +- citeproc +- ris +- bibtex +- codemeta +- cff supported writers: -- [citeproc][] -- [ris][] -- [bibtex][] -- [schema.org][] -- [rdfxml][] (requires suggested package [jsonld][]) -- [codemeta][] -- [cff][] +- citeproc +- ris +- bibtex +- schemaorg +- rdfxml +- codemeta +- cff not supported yet, but plan to: @@ -58,82 +58,6 @@ remotes::install_github("ropensci/handlr") library("handlr") ``` -## All in one - -There's a single R6 interface to all readers and writers - - -```r -z <- system.file("extdata/citeproc.json", package = "handlr") -x <- HandlrClient$new(x = z) -x -#> -#> doi: -#> ext: json -#> format (guessed): citeproc -#> path: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/handlr/extdata/citeproc.json -#> string (abbrev.): none -``` - -read the file - - -```r -x$read(format = "citeproc") -``` - -the parsed content - - -```r -x$parsed -#> -#> from: citeproc -#> many: FALSE -#> count: 1 -#> first 10 -#> id/doi: https://doi.org/10.5438/4k3m-nyvg -``` - -write out bibtex - - -```r -cat(x$write("bibtex"), sep = "\n") -#> @article{https://doi.org/10.5438/4k3m-nyvg, -#> doi = {10.5438/4k3m-nyvg}, -#> author = {Martin Fenner}, -#> title = {Eating your own Dog Food}, -#> journal = {DataCite Blog}, -#> pages = {}, -#> publisher = {DataCite}, -#> year = {2016}, -#> } -``` - -## Choose your own adventure - -Instead of using the `HandlrClient`, you can use the regular functions for each -reader or writer. They are: - -- `citeproc_reader()` / `citeproc_writer()` -- `ris_reader()` / `ris_writer()` -- `bibtex_reader()` / `bibtex_writer()` -- `codemeta_reader()` / `codemeta_writer()` -- `schema_org_writer()` -- `rdf_xml_writer()` - -## Convert data to data.frame - - -```r -z <- system.file('extdata/bib-many.bib', package = "handlr") -res2 <- bibtex_reader(x = z) -#> Error: Please install bibtex -handl_to_df(res2) -#> Error in assert(x, "handl"): object 'res2' not found -``` - ## Meta * Please [report any issues or bugs](https://github.com/ropensci/handlr/issues). @@ -142,13 +66,3 @@ handl_to_df(res2) * Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms. [![ropensci_footer](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org) - - -[jsonld]: https://github.com/ropensci/jsonld/ -[codemeta]: https://codemeta.github.io/ -[citeproc]: https://en.wikipedia.org/wiki/CiteProc -[ris]: https://en.wikipedia.org/wiki/RIS_(file_format) -[bibtex]: http://www.bibtex.org/ -[schema.org]: https://schema.org/ -[rdfxml]: https://en.wikipedia.org/wiki/RDF/XML -[cff]: https://citation-file-format.github.io/ diff --git a/vignettes/.gitignore b/vignettes/.gitignore new file mode 100644 index 0000000..097b241 --- /dev/null +++ b/vignettes/.gitignore @@ -0,0 +1,2 @@ +*.html +*.R diff --git a/vignettes/handlr.Rmd b/vignettes/handlr.Rmd new file mode 100644 index 0000000..6a44b65 --- /dev/null +++ b/vignettes/handlr.Rmd @@ -0,0 +1,172 @@ +--- +title: "handlr" +author: "Scott Chamberlain" +date: "2020-10-14" +output: + html_document: + toc: true + toc_float: true + theme: readable +vignette: > + %\VignetteIndexEntry{Introduction to handlr} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + + + +**handlr**: convert among citation formats + +heavily influenced by, and code ported from + +supported readers: + +- [citeproc][] +- [ris][] +- [bibtex][] (requires suggested package `bibtex`) +- [codemeta][] +- [cff][] + +supported writers: + +- [citeproc][] +- [ris][] +- [bibtex][] +- [schema.org][] +- [rdfxml][] (requires suggested package [jsonld][]) +- [codemeta][] +- [cff][] + +not supported yet, but plan to: + +- crosscite + + +## Installation + +stable version + + +```r +install.packages("handlr") +# OR +install.packages("handlr", repos = "https://dev.ropensci.org") +``` + +dev version + + +```r +remotes::install_github("ropensci/handlr") +``` + + +```r +library("handlr") +``` + +## All in one + +There's a single R6 interface to all readers and writers + + +```r +z <- system.file("extdata/citeproc.json", package = "handlr") +x <- HandlrClient$new(x = z) +x +#> +#> doi: +#> ext: json +#> format (guessed): citeproc +#> path: /Library/Frameworks/R.framework/Versions/4.0/Resources/library/handlr/extdata/citeproc.json +#> string (abbrev.): none +``` + +read the file + + +```r +x$read(format = "citeproc") +``` + +the parsed content + + +```r +x$parsed +#> +#> from: citeproc +#> many: FALSE +#> count: 1 +#> first 10 +#> id/doi: https://doi.org/10.5438/4k3m-nyvg +``` + +write out bibtex + + +```r +cat(x$write("bibtex"), sep = "\n") +#> @article{https://doi.org/10.5438/4k3m-nyvg, +#> doi = {10.5438/4k3m-nyvg}, +#> author = {Martin Fenner}, +#> title = {Eating your own Dog Food}, +#> journal = {DataCite Blog}, +#> pages = {}, +#> publisher = {DataCite}, +#> year = {2016}, +#> } +``` + +## Choose your own adventure + +Instead of using the `HandlrClient`, you can use the regular functions for each +reader or writer. They are: + +- `citeproc_reader()` / `citeproc_writer()` +- `ris_reader()` / `ris_writer()` +- `bibtex_reader()` / `bibtex_writer()` +- `codemeta_reader()` / `codemeta_writer()` +- `schema_org_writer()` +- `rdf_xml_writer()` + +## Convert data to data.frame + + +```r +z <- system.file('extdata/bib-many.bib', package = "handlr") +res2 <- bibtex_reader(x = z) +handl_to_df(res2) +#> key id type bibtex_type +#> 1 Amano_2016 https://doi.org/10.1093%2fbiosci%2fbiw022 article article +#> 2 Bachelot_2016 https://doi.org/10.1890%2f15-1397.1 article article +#> citeproc_type ris_type resource_type_general additional_type +#> 1 article-journal JOUR JournalArticle +#> 2 article-journal JOUR JournalArticle +#> doi b_url +#> 1 10.1093/biosci/biw022 http://dx.doi.org/10.1093/biosci/biw022 +#> 2 10.1890/15-1397.1 http://dx.doi.org/10.1890/15-1397.1 +#> title +#> 1 Spatial Gaps in Global Biodiversity Information and the Role of Citizen Science +#> 2 Long-lasting effects of land use history on soil fungal communities in second-growth tropical rain forests +#> author +#> 1 Amano T., Lamming J., Sutherland W. +#> 2 Bachelot B., Uriarte M., Zimmerman J., Thompson J., Leff J., Asiaii A., Koshner J., McGuire K. +#> publisher is_part_of +#> 1 Oxford University Press ({OUP}) Periodical;{BioScience} +#> 2 Wiley-Blackwell Periodical;Ecological Applications +#> date_published volume first_page last_page state +#> 1 66 393 400 findable +#> 2 findable +``` + + + +[jsonld]: https://github.com/ropensci/jsonld/ +[codemeta]: https://codemeta.github.io/ +[citeproc]: https://en.wikipedia.org/wiki/CiteProc +[ris]: https://en.wikipedia.org/wiki/RIS_(file_format) +[bibtex]: http://www.bibtex.org/ +[schema.org]: https://schema.org/ +[rdfxml]: https://en.wikipedia.org/wiki/RDF/XML +[cff]: https://citation-file-format.github.io/ diff --git a/vignettes/handlr.Rmd.og b/vignettes/handlr.Rmd.og new file mode 100644 index 0000000..d136e2d --- /dev/null +++ b/vignettes/handlr.Rmd.og @@ -0,0 +1,127 @@ +--- +title: "handlr" +author: "Scott Chamberlain" +date: "`r Sys.Date()`" +output: + html_document: + toc: true + toc_float: true + theme: readable +vignette: > + %\VignetteIndexEntry{Introduction to handlr} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +knitr::opts_chunk$set( + collapse = TRUE, + comment = "#>" +) +``` + +**handlr**: convert among citation formats + +heavily influenced by, and code ported from + +supported readers: + +- [citeproc][] +- [ris][] +- [bibtex][] (requires suggested package `bibtex`) +- [codemeta][] +- [cff][] + +supported writers: + +- [citeproc][] +- [ris][] +- [bibtex][] +- [schema.org][] +- [rdfxml][] (requires suggested package [jsonld][]) +- [codemeta][] +- [cff][] + +not supported yet, but plan to: + +- crosscite + + +## Installation + +stable version + +```{r eval=FALSE} +install.packages("handlr") +# OR +install.packages("handlr", repos = "https://dev.ropensci.org") +``` + +dev version + +```{r eval=FALSE} +remotes::install_github("ropensci/handlr") +``` + +```{r} +library("handlr") +``` + +## All in one + +There's a single R6 interface to all readers and writers + +```{r} +z <- system.file("extdata/citeproc.json", package = "handlr") +x <- HandlrClient$new(x = z) +x +``` + +read the file + +```{r} +x$read(format = "citeproc") +``` + +the parsed content + +```{r} +x$parsed +``` + +write out bibtex + +```{r} +cat(x$write("bibtex"), sep = "\n") +``` + +## Choose your own adventure + +Instead of using the `HandlrClient`, you can use the regular functions for each +reader or writer. They are: + +- `citeproc_reader()` / `citeproc_writer()` +- `ris_reader()` / `ris_writer()` +- `bibtex_reader()` / `bibtex_writer()` +- `codemeta_reader()` / `codemeta_writer()` +- `schema_org_writer()` +- `rdf_xml_writer()` + +## Convert data to data.frame + +```{r} +z <- system.file('extdata/bib-many.bib', package = "handlr") +res2 <- bibtex_reader(x = z) +handl_to_df(res2) +``` + + + +[jsonld]: https://github.com/ropensci/jsonld/ +[codemeta]: https://codemeta.github.io/ +[citeproc]: https://en.wikipedia.org/wiki/CiteProc +[ris]: https://en.wikipedia.org/wiki/RIS_(file_format) +[bibtex]: http://www.bibtex.org/ +[schema.org]: https://schema.org/ +[rdfxml]: https://en.wikipedia.org/wiki/RDF/XML +[cff]: https://citation-file-format.github.io/