From aa46920289016169be13f9beeed84351abc63d5a Mon Sep 17 00:00:00 2001 From: Georgi Boshnakov Date: Sat, 3 Oct 2020 10:12:51 +0100 Subject: [PATCH] switch bib parser from bibtex to rbibutils --- .gitignore | 1 + DESCRIPTION | 10 +- NAMESPACE | 3 +- NEWS.md | 14 +- R/bib.R | 158 ++++++++++++++++----- docs/404.html | 2 +- docs/authors.html | 6 +- docs/index.html | 2 +- docs/news/index.html | 23 ++- docs/pkgdown.yml | 2 +- docs/reference/RStudio_reprompt.html | 2 +- docs/reference/Rd_combo.html | 2 +- docs/reference/Rdapply.html | 6 +- docs/reference/Rdo2Rdf.html | 2 +- docs/reference/Rdo_append_argument.html | 2 +- docs/reference/Rdo_collect_metadata.html | 2 +- docs/reference/Rdo_empty_sections.html | 2 +- docs/reference/Rdo_fetch.html | 2 +- docs/reference/Rdo_flatinsert.html | 2 +- docs/reference/Rdo_get_argument_names.html | 2 +- docs/reference/Rdo_get_insert_pos.html | 2 +- docs/reference/Rdo_get_item_labels.html | 2 +- docs/reference/Rdo_insert.html | 2 +- docs/reference/Rdo_insert_element.html | 2 +- docs/reference/Rdo_is_newline.html | 2 +- docs/reference/Rdo_locate.html | 2 +- docs/reference/Rdo_locate_leaves.html | 4 +- docs/reference/Rdo_macro.html | 2 +- docs/reference/Rdo_modify.html | 2 +- docs/reference/Rdo_modify_simple.html | 2 +- docs/reference/Rdo_piecetag.html | 2 +- docs/reference/Rdo_remove_srcref.html | 2 +- docs/reference/Rdo_reparse.html | 4 +- docs/reference/Rdo_sections.html | 4 +- docs/reference/Rdo_set_section.html | 8 +- docs/reference/Rdo_show.html | 2 +- docs/reference/Rdo_tag.html | 2 +- docs/reference/Rdo_tags.html | 2 +- docs/reference/Rdo_which.html | 55 +++---- docs/reference/Rdpack-package.html | 17 ++- docs/reference/Rdpack_bibstyles.html | 2 +- docs/reference/Rdreplace_section.html | 2 +- docs/reference/S4formals.html | 2 +- docs/reference/append_to_Rd_list.html | 2 +- docs/reference/bibentry_key.html | 2 +- docs/reference/c_Rd.html | 2 +- docs/reference/char2Rdpiece.html | 2 +- docs/reference/compare_usage1.html | 2 +- docs/reference/deparse_usage.html | 2 +- docs/reference/ereprompt.html | 2 +- docs/reference/format_funusage.html | 2 +- docs/reference/get_bibentries.html | 141 +++++++++--------- docs/reference/get_sig_text.html | 26 ++-- docs/reference/get_usage_text.html | 2 +- docs/reference/index.html | 2 +- docs/reference/insert_all_ref.html | 46 ++++-- docs/reference/insert_ref.html | 23 ++- docs/reference/inspect_Rd.html | 2 +- docs/reference/inspect_args.html | 2 +- docs/reference/inspect_signatures.html | 2 +- docs/reference/inspect_slots.html | 2 +- docs/reference/inspect_usage.html | 2 +- docs/reference/list_Rd.html | 4 +- docs/reference/makeVignetteReference.html | 8 +- docs/reference/parse_Rdname.html | 2 +- docs/reference/parse_Rdpiece.html | 2 +- docs/reference/parse_Rdtext.html | 2 +- docs/reference/parse_pairlist.html | 2 +- docs/reference/parse_text.html | 2 +- docs/reference/parse_usage_text.html | 2 +- docs/reference/predefined.html | 2 +- docs/reference/promptPackageSexpr.html | 2 +- docs/reference/promptUsage.html | 2 +- docs/reference/rdo_text_restore.html | 2 +- docs/reference/rebib.html | 2 +- docs/reference/reprompt.html | 2 +- docs/reference/set_Rdpack_bibstyle.html | 2 +- docs/reference/update_aliases_tmp.html | 2 +- docs/reference/viewRd.html | 2 +- docs/reference/zzasym_compare.html | 2 +- docs/reference/zzbsdup.html | 2 +- docs/reference/zzcapture_promptany.html | 2 +- inst/REFERENCES.bib | 10 +- man/Rdo_which.Rd | 30 ++-- man/Rdpack-package.Rd | 2 +- man/get_bibentries.Rd | 15 +- man/insert_all_ref.Rd | 4 +- man/insert_ref.Rd | 14 +- man/macros/refmacros.Rd | 5 +- vignettes/Inserting_bibtex_references.org | 3 - 90 files changed, 451 insertions(+), 317 deletions(-) diff --git a/.gitignore b/.gitignore index 60b2b4f..bf7d482 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +auto/ /vignettes/.RData /vignettes/Inserting_figures_and_evaluated_examples.tex /vignettes/Inserting_bibtex_references.tex diff --git a/DESCRIPTION b/DESCRIPTION index 2ae1cb5..4553923 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: Rdpack Type: Package Title: Update and Manipulate Rd Documentation Objects -Version: 1.0.1 -Date: 2020-07-02 +Version: 2.0.0 +Date: 2020-10-02 Authors@R: c( person(given = c("Georgi", "N."), family = "Boshnakov", role = c("aut", "cre"), @@ -26,8 +26,8 @@ Depends: Imports: tools, utils, - bibtex (>= 0.4.0), - gbRd + gbRd, + rbibutils (>= 1.3) Suggests: grDevices, testthat, @@ -35,4 +35,4 @@ Suggests: rprojroot License: GPL (>= 2) LazyLoad: yes -RoxygenNote: 7.1.0 +RoxygenNote: 7.1.1 diff --git a/NAMESPACE b/NAMESPACE index 2a803e8..a103c55 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,7 +9,8 @@ importFrom(tools, parse_Rd, toRd, checkRd, Rd2txt, #importFrom(grDevices, dev.off, png) importFrom(gbRd, Rd_help2txt) -importFrom(bibtex, read.bib) +#importFrom(bibtex, read.bib) +importFrom(rbibutils, readBib) S3method(as.character, f_usage) S3method(print, f_usage) diff --git a/NEWS.md b/NEWS.md index 56d31a5..de7ef17 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,15 @@ +# Rdpack 2.0.0 (CRAN) + +- removed `bibtex` from `Suggests` and elsewhere. + + +# Rdpack 1.1.0 + +- imported `rbibutils` and made suitable adjustments to the code. + +- moved `bibtex` to `Suggests` (since `bibtex` has been orphaned for several years). + + # Rdpack 1.0.1 - removed a documentation link to a function in `gbutils`, which is not among @@ -5,7 +17,7 @@ testing machines. -# Rdpack 1.0.0 +# Rdpack 1.0.0 (CRAN) - `viewRd()` now loads also Rd macros declared by the package to which the rendered Rd file belongs. Previously only macros from `Rdpack` were loaded diff --git a/R/bib.R b/R/bib.R index 3d7b02d..51450d3 100644 --- a/R/bib.R +++ b/R/bib.R @@ -73,11 +73,14 @@ get_bibentries <- function(..., package = NULL, bibfile = "REFERENCES.bib", ## This is really for the case when system.file() is the one from devtools, ## see the note above. TODO: check if this is the case? fn <- system.file("inst", ..., bibfile, package = package) - - if(length(fn) == 1 && fn == "") - ## if system.file() didn't find the bib file, check if file package.bib is - ## provided by package "bibtex" (it is for core R packages, such as "base") - fn <- system.file("bib", sprintf("%s.bib", package), package = "bibtex") + + ## 2020-09-27 removing this functionality since package 'bibtex' ca no longer be + ## relied upon and was dropped from the dependencies. + ## + ## if(length(fn) == 1 && fn == "") + ## ## if system.file() didn't find the bib file, check if file package.bib is + ## ## provided by package "bibtex" (it is for core R packages, such as "base") + ## fn <- system.file("bib", sprintf("%s.bib", package), package = "bibtex") } if(length(fn) > 1){ @@ -109,7 +112,17 @@ get_bibentries <- function(..., package = NULL, bibfile = "REFERENCES.bib", else "UTF-8" - res <- read.bib(file = fn, encoding = encoding) + ## 2020-09-22 switching to 'rbibutils + ## res <- read.bib(file = fn, encoding = encoding) + # rds <- tempfile(fileext = ".rds") + # if(encoding == "UTF-8") + # encoding = "utf8" + # be <- bibConvert(fn, rds, "bibtex", + # "bibentry", encoding = c(encoding, "utf8"), tex = "no_latex") + # res <- readRDS(rds) + # #print(res) + # unlink(rds) + res <- readBib(file = fn, encoding = encoding) # 2018-03-10 commenting out # since bibtex v. >= 0.4.0 has been required for a long time in DESCRIPTION @@ -120,33 +133,71 @@ get_bibentries <- function(..., package = NULL, bibfile = "REFERENCES.bib", # names(res) <- sapply(1:length(res), function(x) bibentry_key(res[[x]][[1]])) # } - for(nam in names(res)){ - ## unconditionaly recode %'s in filed URL - if(!is.null(res[nam]$url)) - res[nam]$url <- gsub("([^\\])%", "\\1\\\\%", res[nam]$url) - - if(url_only){ # process also other fields - ## TODO: currently all unescaped $'s in all fields are recoded; - ## Maybe do it more selectively, e.g. only for %'s inside \url{}, - ## or matching something like http(s):// - fields <- names(unclass(res[nam])[[1]]) - - unclassed <- unclass(res[nam]) - flag <- FALSE - for(field in fields){ - wrk <- unclass(res[nam])[[1]][[field]] - if(is.character(wrk) && any(grepl("([^\\])%", wrk))){ - flag <- TRUE - unclassed[[1]][[field]] <- gsub("([^\\])%", "\\1\\\\%", wrk) - } + ## 2020-10-02 commenting out since taken care (hopefully) by readBib + ## + # for(nam in names(res)){ + # ## unconditionaly recode %'s in filed URL + # if(!is.null(res[nam]$url)) { + # res[nam]$url <- gsub("([^\\])%", "\\1\\\\%", res[nam]$url) + # } + # + # if(url_only){ # process also other fields + # ## TODO: currently all unescaped %'s in all fields are recoded; + # ## Maybe do it more selectively, e.g. only for %'s inside \url{}, + # ## or matching something like http(s):// + # fields <- names(unclass(res[nam])[[1]]) + # + # unclassed <- unclass(res[nam]) + # flag <- FALSE + # for(field in fields){ + # wrk <- unclass(res[nam])[[1]][[field]] + # if(is.character(wrk) && any(grepl("([^\\])%", wrk))){ + # flag <- TRUE + # unclassed[[1]][[field]] <- gsub("([^\\])%", "\\1\\\\%", wrk) + # } + # } + # if(flag){ + # class(unclassed) <- class(res[nam]) + # res[nam] <- unclassed + # } + # } + # } + + ## new 2020-10-02 - allow \% in url's and doi's in the bib file + for(nam in names(res)){ +#print(res[nam], style = "R") + ## unconditionaly recode %'s in filed URL + if(!is.null(res[nam]$doi)) { + res[nam]$doi <- gsub("([^\\\\])[\\\\]%", "\\1%", res[nam]$doi) } - if(flag){ - class(unclassed) <- class(res[nam]) - res[nam] <- unclassed + + if(!is.null(res[nam]$url)) { + res[nam]$url <- gsub("([^\\\\])[\\\\]%", "\\1%", res[nam]$url) } + + # if(url_only){ # process also other fields + # ## TODO: currently all unescaped %'s in all fields are recoded; + # ## Maybe do it more selectively, e.g. only for %'s inside \url{}, + # ## or matching something like http(s):// + # fields <- names(unclass(res[nam])[[1]]) + # + # unclassed <- unclass(res[nam]) + # flag <- FALSE + # for(field in fields){ + # wrk <- unclass(res[nam])[[1]][[field]] + # if(is.character(wrk) && any(grepl("([^\\])%", wrk))){ + # flag <- TRUE + # unclassed[[1]][[field]] <- gsub("([^\\])%", "\\1\\\\%", wrk) + # } + # } + # if(flag){ + # class(unclassed) <- class(res[nam]) + # res[nam] <- unclassed + # } + # } } - } + ## 2018-03-03 new: class(res) <- c("bibentryRd", class(res)) @@ -315,12 +366,53 @@ Rdo_flatinsert <- function(rdo, val, pos, before = TRUE){ res } -## TODO: auto-deduce 'package'? -insert_ref <- function(key, package = NULL, ...) { # bibfile = "REFERENCES.bib" - if(is.null(package)) + +.get_bibs0 <- function(package, ..., cached_env) { + if(is.null(package)) stop("argument 'package' must be provided") - bibs <- get_bibentries(package = package, ..., stop_on_error = FALSE) + if(!is.null(cached_env)){ + if(is.null(cached_env$refsmat)) + cached_env$refsmat <- matrix(character(0), nrow = 0, ncol = 2) + if(is.null(cached_env$allbibs)) + cached_env$allbibs <- list() + } + + ## if(length(keys) > 1) + ## stop("`keys' must be a character string") + ## + ## if(!cite_only) + ## cached_env$refsmat <- rbind(cached_env$refsmat, c(keys, package)) + ## + ## if(dont_cite) + ## return(character(0)) + + + if(is.null(cached_env)){ + bibs <- get_bibentries(package = package, ..., stop_on_error = FALSE) + }else{ + bibs <- cached_env$allbibs[[package]] + if(is.null(bibs)){ + bibs <- get_bibentries(package = package, ..., stop_on_error = FALSE) + cached_env$allbibs[[package]] <- bibs + } + } + + bibs +} + + +## TODO: auto-deduce 'package'? +## 2020-09-30: changing to cache bib as \insertCite does (new arg. cached_env, etc) +insert_ref <- function(key, package = NULL, ..., cached_env = NULL) { # bibfile = "REFERENCES.bib" + + # 2020-09-30: replaced by a single call + # if(is.null(package)) + # stop("argument 'package' must be provided") + # + # bibs <- get_bibentries(package = package, ..., stop_on_error = FALSE) + # + bibs <- .get_bibs0(package, ..., cached_env = cached_env) if(length(bibs) == 0){ note <- paste0("\"Failed to insert reference with key = ", key, diff --git a/docs/404.html b/docs/404.html index d939e10..a49c9a7 100644 --- a/docs/404.html +++ b/docs/404.html @@ -71,7 +71,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/authors.html b/docs/authors.html index f4bf00e..6fbb7f4 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -71,7 +71,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -116,13 +116,13 @@

Citation

Boshnakov GN (2020). “Rdpack: Update and Manipulate Rd Documentation Objects.” -doi: 10.5281/zenodo.3925612, R package version 1.0.1. +doi: 10.5281/zenodo.3925612, R package version 2.0.0.

@Misc{,
   title = {{Rdpack}: Update and Manipulate Rd Documentation Objects},
   author = {Georgi N. Boshnakov},
   year = {2020},
-  note = {R package version 1.0.1},
+  note = {R package version 2.0.0},
   doi = {10.5281/zenodo.3925612},
 }
diff --git a/docs/index.html b/docs/index.html index bf793d5..3e9a9f9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -38,7 +38,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/news/index.html b/docs/news/index.html index ddfdae0..983522a 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -71,7 +71,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -114,6 +114,23 @@

Changelog

Source: NEWS.md +
+

+Rdpack 2.0.0 (CRAN) Unreleased +

+ +
+
+

+Rdpack 1.1.0 Unreleased +

+ +

Rdpack 1.0.1 Unreleased @@ -122,9 +139,9 @@

  • removed a documentation link to a function in gbutils, which is not among the dependencies of Rdpack. This was raising a NOTE on one of the CRAN testing machines.
  • -
    +

    -Rdpack 1.0.0 2020-07-01 +Rdpack 1.0.0 (CRAN) 2020-07-01

    • viewRd() now loads also Rd macros declared by the package to which the rendered Rd file belongs. Previously only macros from Rdpack were loaded but now there is at least one other package, mathjaxr, which defines Rd macros.

    • diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 2b13c1b..3e41c44 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -2,5 +2,5 @@ pandoc: '2.5' pkgdown: 1.5.1 pkgdown_sha: ~ articles: {} -last_built: 2020-07-02T08:12Z +last_built: 2020-10-03T09:03Z diff --git a/docs/reference/RStudio_reprompt.html b/docs/reference/RStudio_reprompt.html index f64aedf..624d878 100644 --- a/docs/reference/RStudio_reprompt.html +++ b/docs/reference/RStudio_reprompt.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0
    diff --git a/docs/reference/Rd_combo.html b/docs/reference/Rd_combo.html index c359878..8a21159 100644 --- a/docs/reference/Rd_combo.html +++ b/docs/reference/Rd_combo.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0
    diff --git a/docs/reference/Rdapply.html b/docs/reference/Rdapply.html index debb8b1..a2ca07c 100644 --- a/docs/reference/Rdapply.html +++ b/docs/reference/Rdapply.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -239,7 +239,7 @@

    Examp # (reprompt() takes care of this too as it uses Rdo2Rdf for saving) fn <- tempfile("u1", fileext="Rd") -Rdo2Rdf(u1, file = fn)
    #> The Rd content was written to file /tmp/RtmpYaQyun/u11a37c130258a6Rd
    +Rdo2Rdf(u1, file = fn)
    #> The Rd content was written to file /tmp/RtmpNJZtUt/u11b5c45aee5704Rd
    # the saved file contains escaped percents but they disappear in parsing: file.show(fn) Rdo_show(tools::parse_Rd(fn)) @@ -250,7 +250,7 @@

    Examp # todo: additional arg. for list_Rd for this? u2 <- Rdpack:::.Rd_tidy(u1) -Rdo2Rdf(u2, file = fn)

    #> The Rd content was written to file /tmp/RtmpYaQyun/u11a37c130258a6Rd
    file.show(fn) +Rdo2Rdf(u2, file = fn)
    #> The Rd content was written to file /tmp/RtmpNJZtUt/u11b5c45aee5704Rd
    diff --git a/docs/reference/Rdo2Rdf.html b/docs/reference/Rdo2Rdf.html index 1e592c6..7897d33 100644 --- a/docs/reference/Rdo2Rdf.html +++ b/docs/reference/Rdo2Rdf.html @@ -74,7 +74,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_append_argument.html b/docs/reference/Rdo_append_argument.html index b2b3f77..0a26cfc 100644 --- a/docs/reference/Rdo_append_argument.html +++ b/docs/reference/Rdo_append_argument.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_collect_metadata.html b/docs/reference/Rdo_collect_metadata.html index fa60bb0..bc95f08 100644 --- a/docs/reference/Rdo_collect_metadata.html +++ b/docs/reference/Rdo_collect_metadata.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_empty_sections.html b/docs/reference/Rdo_empty_sections.html index 58b4c26..30688e0 100644 --- a/docs/reference/Rdo_empty_sections.html +++ b/docs/reference/Rdo_empty_sections.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_fetch.html b/docs/reference/Rdo_fetch.html index 324bf29..7a2485f 100644 --- a/docs/reference/Rdo_fetch.html +++ b/docs/reference/Rdo_fetch.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_flatinsert.html b/docs/reference/Rdo_flatinsert.html index 71df766..1227f6e 100644 --- a/docs/reference/Rdo_flatinsert.html +++ b/docs/reference/Rdo_flatinsert.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_get_argument_names.html b/docs/reference/Rdo_get_argument_names.html index 40bec33..5828fe4 100644 --- a/docs/reference/Rdo_get_argument_names.html +++ b/docs/reference/Rdo_get_argument_names.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_get_insert_pos.html b/docs/reference/Rdo_get_insert_pos.html index ac07243..64ec0d7 100644 --- a/docs/reference/Rdo_get_insert_pos.html +++ b/docs/reference/Rdo_get_insert_pos.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_get_item_labels.html b/docs/reference/Rdo_get_item_labels.html index b645627..1f4284a 100644 --- a/docs/reference/Rdo_get_item_labels.html +++ b/docs/reference/Rdo_get_item_labels.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_insert.html b/docs/reference/Rdo_insert.html index f37e80a..80b1420 100644 --- a/docs/reference/Rdo_insert.html +++ b/docs/reference/Rdo_insert.html @@ -75,7 +75,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_insert_element.html b/docs/reference/Rdo_insert_element.html index 4279676..87b4673 100644 --- a/docs/reference/Rdo_insert_element.html +++ b/docs/reference/Rdo_insert_element.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_is_newline.html b/docs/reference/Rdo_is_newline.html index 2557342..ba868cc 100644 --- a/docs/reference/Rdo_is_newline.html +++ b/docs/reference/Rdo_is_newline.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_locate.html b/docs/reference/Rdo_locate.html index e5e64bb..f82277e 100644 --- a/docs/reference/Rdo_locate.html +++ b/docs/reference/Rdo_locate.html @@ -74,7 +74,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_locate_leaves.html b/docs/reference/Rdo_locate_leaves.html index 5932fb6..20eb70e 100644 --- a/docs/reference/Rdo_locate_leaves.html +++ b/docs/reference/Rdo_locate_leaves.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -161,7 +161,7 @@

    Examp fn <- tempfile("dummyfun", fileext = "Rd") reprompt(dummyfun, filename = fn)
    #> Rd source not supplied, looking for installed documentation. #> Rd source not supplied and installed documentation not found. -#> Trying a 'prompt' function to generate documentation for the object.
    #> Error in reprompt(dummyfun, filename = fn): unsuccessful attempt to create Rd doc. using a 'prompt' function.
    rdo <- tools::parse_Rd(fn)
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c7b548f33Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    +#> Trying a 'prompt' function to generate documentation for the object.
    #> Error in reprompt(dummyfun, filename = fn): unsuccessful attempt to create Rd doc. using a 'prompt' function.
    rdo <- tools::parse_Rd(fn)
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4527f3d936Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    f <- function(x) Rdo_is_newline(x) nl <- Rdo_locate_leaves(rdo, f )
    #> Error in fxx(object): object 'rdo' not found
    diff --git a/docs/reference/Rdo_macro.html b/docs/reference/Rdo_macro.html index 00f0286..2611eeb 100644 --- a/docs/reference/Rdo_macro.html +++ b/docs/reference/Rdo_macro.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0
    diff --git a/docs/reference/Rdo_modify.html b/docs/reference/Rdo_modify.html index cb6b753..48e8329 100644 --- a/docs/reference/Rdo_modify.html +++ b/docs/reference/Rdo_modify.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_modify_simple.html b/docs/reference/Rdo_modify_simple.html index 725e35b..ed279b3 100644 --- a/docs/reference/Rdo_modify_simple.html +++ b/docs/reference/Rdo_modify_simple.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_piecetag.html b/docs/reference/Rdo_piecetag.html index bd0c33c..b44d86a 100644 --- a/docs/reference/Rdo_piecetag.html +++ b/docs/reference/Rdo_piecetag.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_remove_srcref.html b/docs/reference/Rdo_remove_srcref.html index f59b3e0..d0f534f 100644 --- a/docs/reference/Rdo_remove_srcref.html +++ b/docs/reference/Rdo_remove_srcref.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_reparse.html b/docs/reference/Rdo_reparse.html index 9cf7b2d..32172f6 100644 --- a/docs/reference/Rdo_reparse.html +++ b/docs/reference/Rdo_reparse.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -147,7 +147,7 @@

    R

    Romain Francois (2014). bibtex: bibtex parser. -R package version 0.4.0, https://CRAN.R-project.org/package=bibtex.

    Duncan Murdoch (2010). +R package version 0.4.0.

    Duncan Murdoch (2010). “Parsing Rd files.” https://developer.r-project.org/parseRd.pdf.

    diff --git a/docs/reference/Rdo_sections.html b/docs/reference/Rdo_sections.html index e881f04..5c8a76e 100644 --- a/docs/reference/Rdo_sections.html +++ b/docs/reference/Rdo_sections.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -193,7 +193,7 @@

    R

    Romain Francois (2014). bibtex: bibtex parser. -R package version 0.4.0, https://CRAN.R-project.org/package=bibtex.

    Duncan Murdoch (2010). +R package version 0.4.0.

    Duncan Murdoch (2010). “Parsing Rd files.” https://developer.r-project.org/parseRd.pdf.

    diff --git a/docs/reference/Rdo_set_section.html b/docs/reference/Rdo_set_section.html index 0bc3342..d469aaa 100644 --- a/docs/reference/Rdo_set_section.html +++ b/docs/reference/Rdo_set_section.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -170,11 +170,11 @@

    Examp dummyfun <- function(x) x reprompt(dummyfun, filename = fnA)
    #> Rd source not supplied, looking for installed documentation. #> Rd source not supplied and installed documentation not found. -#> Trying a 'prompt' function to generate documentation for the object.
    #> Error in reprompt(dummyfun, filename = fnA): unsuccessful attempt to create Rd doc. using a 'prompt' function.
    Rdo_show(tools::parse_Rd(fnA))
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c49b304cbRd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    +#> Trying a 'prompt' function to generate documentation for the object.
    #> Error in reprompt(dummyfun, filename = fnA): unsuccessful attempt to create Rd doc. using a 'prompt' function.
    Rdo_show(tools::parse_Rd(fnA))
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4566f40e11Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    ## set the author section, create it if necessary. -Rdo_set_section("A.A. Author", "author", fnA, create = TRUE)
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c49b304cbRd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    Rdo_show(tools::parse_Rd(fnA))
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c49b304cbRd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    +Rdo_set_section("A.A. Author", "author", fnA, create = TRUE)
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4566f40e11Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    Rdo_show(tools::parse_Rd(fnA))
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4566f40e11Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    ## replace the author section -Rdo_set_section("Georgi N. Boshnakov", "author", fnA)
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c49b304cbRd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    Rdo_show(tools::parse_Rd(fnA))
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c49b304cbRd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    +Rdo_set_section("Georgi N. Boshnakov", "author", fnA)
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4566f40e11Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    Rdo_show(tools::parse_Rd(fnA))
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4566f40e11Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    unlink(fnA)
    diff --git a/docs/reference/Rdo_tag.html b/docs/reference/Rdo_tag.html index cd8b65e..85e33be 100644 --- a/docs/reference/Rdo_tag.html +++ b/docs/reference/Rdo_tag.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_tags.html b/docs/reference/Rdo_tags.html index ff30c4c..e2c3176 100644 --- a/docs/reference/Rdo_tags.html +++ b/docs/reference/Rdo_tags.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/Rdo_which.html b/docs/reference/Rdo_which.html index 82e5d76..289fcdb 100644 --- a/docs/reference/Rdo_which.html +++ b/docs/reference/Rdo_which.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -176,44 +176,21 @@

    Examp rdo_seq[ind] } -db_bibtex <- tools::Rd_db("bibtex") -names(db_bibtex)
    #> [1] "do_read_bib.Rd" "read.bib.Rd" "write.bib.Rd"
    ## Rdo object for read.bib() -rdo_read.bib <- db_bibtex[["read.bib.Rd"]] -Rdo_tags(rdo_read.bib)
    #> [1] "\\title" "\\name" "\\alias" "\\description" -#> [5] "\\usage" "\\arguments" "\\value" "\\references" -#> [9] "\\examples"
    -## which elements of read.bib are aliases? -Rdo_which_tag_eq(rdo_read.bib, "\alias")
    #> integer(0)
    rdo_read.bib[[3]]
    #> [[1]] -#> [1] "read.bib" -#> attr(,"Rd_tag") -#> [1] "VERB" -#> -#> attr(,"Rd_tag") -#> [1] "\\alias"
    -## which elements of read.bib contain R code? -Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "RCODE") )
    #> [1] 5 9
    rdo_read.bib[[5]]
    #> [[1]] -#> [1] "\n" -#> attr(,"Rd_tag") -#> [1] "RCODE" -#> -#> [[2]] -#> [1] "read.bib(file = findBibFile(package), package = \"bibtex\",\n" -#> attr(,"Rd_tag") -#> [1] "RCODE" -#> -#> [[3]] -#> [1] " encoding = \"unknown\", header = if (length(preamble)) paste(preamble, sep =\n" -#> attr(,"Rd_tag") -#> [1] "RCODE" -#> -#> [[4]] -#> [1] " \"\\n\") else \"\", footer = \"\")\n" -#> attr(,"Rd_tag") -#> [1] "RCODE" -#> -#> attr(,"Rd_tag") -#> [1] "\\usage"
    ## which contain prose? -Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "TEXT") )
    #> [1] 1 4 6 7 8
    +## db_bibtex <- tools::Rd_db("bibtex") +## names(db_bibtex) +## ## Rdo object for read.bib() +## rdo_read.bib <- db_bibtex[["read.bib.Rd"]] +## Rdo_tags(rdo_read.bib) +## +## ## which elements of read.bib are aliases? +## Rdo_which_tag_eq(rdo_read.bib, "\alias") +## rdo_read.bib[[3]] +## +## ## which elements of read.bib contain R code? +## Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "RCODE") ) +## rdo_read.bib[[5]] +## ## which contain prose? +## Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "TEXT") ) @@ -141,11 +141,11 @@

    Details

    - - + + - +
    Package:Rdpack
    Type:Package
    Version:1.0.1
    Date:2020-07-02
    Version:2.0.0
    Date:2020-10-02
    License:GPL (>= 2)
    LazyLoad:yes
    Built:R 4.0.1; ; 2020-07-02 08:12:52 UTC; unix
    Built:R 4.0.2; ; 2020-10-03 09:03:30 UTC; unix

    @@ -167,7 +167,7 @@

    Details

    A set of functions and macros support inclusion of references and citations from BibTeX files in R documentation (Rd and roxygen2). These tools use only facilities provided by base R and - package bibtex (Francois 2014) + package rbibutils (Francois 2014) .

    There are also convenience macros for inclusion of evaluated examples and graphs, which hide some of the hassle of doing this directly with @@ -455,15 +455,14 @@

    R

    ---

    Romain Francois (2014). bibtex: bibtex parser. -R package version 0.4.0, https://CRAN.R-project.org/package=bibtex.

    Duncan Murdoch (2010). +R package version 0.4.0.

    Duncan Murdoch (2010). “Parsing Rd files.” https://developer.r-project.org/parseRd.pdf.

    Hadley Wickham, Jim Hester, Winston Chang (2018). devtools: Tools to Make Developing R Packages Easier. -R package version 1.13.5, https://CRAN.R-project.org/package=devtools.

    A. ZZZ (2018). +R package version 1.13.5, https://CRAN.R-project.org/package=devtools.

    A ZZZ (2018). “A relation between several fundamental constants: \(e^{i\pi}=-1\).” A non-existent journal with the formula \(L_2\) in its name.. -This reference does not exist. It is a test/demo that simple formulas in BibTeX - files are OK. A formula in field 'note': \(c^2 = a^2 + b^2\).

    +This reference does not exist. It is a test/demo that simple formulas in BibTeX files are OK. A formula in field 'note': \(c^2 = a^2 + b^2\).

    Examples

    ## The examples below show typical use but are not executable. diff --git a/docs/reference/Rdpack_bibstyles.html b/docs/reference/Rdpack_bibstyles.html index ed5f961..0044d2b 100644 --- a/docs/reference/Rdpack_bibstyles.html +++ b/docs/reference/Rdpack_bibstyles.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0
    diff --git a/docs/reference/Rdreplace_section.html b/docs/reference/Rdreplace_section.html index 9aef452..5f9d2df 100644 --- a/docs/reference/Rdreplace_section.html +++ b/docs/reference/Rdreplace_section.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/S4formals.html b/docs/reference/S4formals.html index cc0a05a..ed10682 100644 --- a/docs/reference/S4formals.html +++ b/docs/reference/S4formals.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/append_to_Rd_list.html b/docs/reference/append_to_Rd_list.html index dfc589b..9e101d2 100644 --- a/docs/reference/append_to_Rd_list.html +++ b/docs/reference/append_to_Rd_list.html @@ -75,7 +75,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/bibentry_key.html b/docs/reference/bibentry_key.html index c44ceac..c472250 100644 --- a/docs/reference/bibentry_key.html +++ b/docs/reference/bibentry_key.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/c_Rd.html b/docs/reference/c_Rd.html index c9cf4f0..23211b9 100644 --- a/docs/reference/c_Rd.html +++ b/docs/reference/c_Rd.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/char2Rdpiece.html b/docs/reference/char2Rdpiece.html index 4667905..234979d 100644 --- a/docs/reference/char2Rdpiece.html +++ b/docs/reference/char2Rdpiece.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/compare_usage1.html b/docs/reference/compare_usage1.html index 7342ea0..b85c0b0 100644 --- a/docs/reference/compare_usage1.html +++ b/docs/reference/compare_usage1.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/deparse_usage.html b/docs/reference/deparse_usage.html index 233c0e0..539bdf4 100644 --- a/docs/reference/deparse_usage.html +++ b/docs/reference/deparse_usage.html @@ -75,7 +75,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/ereprompt.html b/docs/reference/ereprompt.html index f0d3229..a35795b 100644 --- a/docs/reference/ereprompt.html +++ b/docs/reference/ereprompt.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/format_funusage.html b/docs/reference/format_funusage.html index 5e52348..97969c7 100644 --- a/docs/reference/format_funusage.html +++ b/docs/reference/format_funusage.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/get_bibentries.html b/docs/reference/get_bibentries.html index fd75526..c5bb8c4 100644 --- a/docs/reference/get_bibentries.html +++ b/docs/reference/get_bibentries.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -154,9 +154,10 @@

    Details -

    get_bibentries parses the specified file using read.bib - from package bibtex (Francois 2014) - and sets its +

    get_bibentries parses the specified file. + + + and sets its names attribute to the keys of the bib elements (read.bib() does this since version version 0.4.0 of bibtex, as well). Here is what @@ -199,14 +200,16 @@

    Value

    a bibentryRd object inheriting from bibentry

    References

    -

    Romain Francois (2014). -bibtex: bibtex parser. -R package version 0.4.0, https://CRAN.R-project.org/package=bibtex.

    +

    There are no references for Rd macro \insertAllCites on this help page.

    Examples

    -
    r <- get_bibentries(package = "Rdpack") -r
    #> Francois R (2014). _bibtex: bibtex parser_. R package version 0.4.0, -#> <URL: https://CRAN.R-project.org/package=bibtex>. +
    r <- get_bibentries(package = "Rdpack")
    #> +#> count_type: +#> +#> no_type not_char Manual Misc Article +#> 0 0 2 1 1 +#> +#>
    r
    #> Francois R (2014). _bibtex: bibtex parser_. R package version 0.4.0. #> #> Murdoch D (2010). “Parsing Rd files.” <URL: #> https://developer.r-project.org/parseRd.pdf>. @@ -221,7 +224,7 @@

    Examp #> formulas in BibTeX files are OK. A formula in field 'note': $c^2 = a^2 #> + b^2$.

    print(r, style = "html")
    #> <p>Francois R (2014). #> <em>bibtex: bibtex parser</em>. -#> R package version 0.4.0, <a href="https://CRAN.R-project.org/package=bibtex">https://CRAN.R-project.org/package=bibtex</a>. +#> R package version 0.4.0. #> </p> #> #> <p>Murdoch D (2010). @@ -237,37 +240,24 @@

    Examp #> <p>ZZZ A (2018). #> &ldquo;A relation between several fundamental constants: $e^i\pi=-1$.&rdquo; #> <em>A non-existent journal with the formula $L_2$ in its name.</em>. -#> This reference does not exist. It is a test/demo that simple formulas in BibTeX -#> files are OK. A formula in field 'note': $c^2 = a^2 + b^2$. +#> This reference does not exist. It is a test/demo that simple formulas in BibTeX files are OK. A formula in field 'note': $c^2 = a^2 + b^2$. #> </p>

    -b <- get_bibentries(package = "stats") -print(b[[1]], style = "R")
    #> bibentry(bibtype = "Book", -#> key = "sakamoto+ishiguro+kitagawa:1986", -#> author = c(person(given = "Y.", -#> family = "Sakamoto"), -#> person(given = "M.", -#> family = "Ishiguro"), -#> person(given = "Kitagawa", -#> family = "G.")), -#> year = "1986", -#> title = "Akaike Information Criterion Statistics", -#> publisher = "Reidel Publishing Company")
    print(b[[1]], style = "citation")
    #> -#> Sakamoto Y, Ishiguro M, G. K (1986). _Akaike Information Criterion -#> Statistics_. Reidel Publishing Company. +## Bib from base R packages are disabled in Rdpack v2 (notify the +## maintainer of Rdpack or raise an issue on github if you wish this back). +## +## b <- get_bibentries(package = "stats") +## print(b[[1]], style = "R") +## print(b[[1]], style = "citation") + +## here the url field contains percent encoding +fn_url <- system.file("examples", "url_with_percents.bib", package = "Rdpack") +u <- get_bibentries(bibfile = fn_url)
    #> +#> count_type: #> -#> A BibTeX entry for LaTeX users is +#> no_type not_char Article +#> 0 0 1 #> -#> @Book{sakamoto+ishiguro+kitagawa:1986, -#> author = {Y. Sakamoto and M. Ishiguro and Kitagawa G.}, -#> year = {1986}, -#> title = {Akaike Information Criterion Statistics}, -#> publisher = {Reidel Publishing Company}, -#> } #>
    -## here the url field contains percent encoding -fn_url <- system.file("examples", "url_with_percents.bib", package = "Rdpack") -u <- get_bibentries(bibfile = fn_url) - ## the links produced by all of the following are valid ## and can be put in a browser print(u, style = "html")
    #> <p>Boshnakov GN (2018). @@ -275,22 +265,27 @@

    Examp #> <em>Example bibtex file</em>, <b>51</b>, 1&ndash;1. #> <a href="https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib">https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib</a>. #> </p>

    print(u, style = "bibtex")
    #> @Article{urlWithPercents, +#> author = {Georgi N Boshnakov}, #> title = {Dummy example of {URL} with percents}, -#> volume = {51}, -#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, -#> journal = {Example bibtex file}, -#> author = {Georgi N. Boshnakov}, #> year = {2018}, +#> genre = {academic journal}, +#> journal = {Example bibtex file}, +#> citekey = {urlWithPercents}, +#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, +#> volume = {51}, #> pages = {1--1}, #> }
    print(u, style = "R")
    #> bibentry(bibtype = "Article", #> key = "urlWithPercents", +#> author = person(given = c("Georgi", "N"), +#> family = "Boshnakov", +#> role = "aut"), #> title = "Dummy example of {URL} with percents", -#> volume = "51", -#> url = "https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib", -#> journal = "Example bibtex file", -#> author = person(given = c("Georgi", "N."), -#> family = "Boshnakov"), #> year = "2018", +#> genre = "academic journal", +#> journal = "Example bibtex file", +#> citekey = "urlWithPercents", +#> url = "https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib", +#> volume = "51", #> pages = "1--1")
    print(u, style = "text")
    #> Boshnakov GN (2018). “Dummy example of URL with percents.” _Example #> bibtex file_, *51*, 1-1. <URL: #> https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib>.
    print(u, style = "citation")
    #> @@ -301,12 +296,14 @@

    Examp #> A BibTeX entry for LaTeX users is #> #> @Article{urlWithPercents, +#> author = {Georgi N Boshnakov}, #> title = {Dummy example of {URL} with percents}, -#> volume = {51}, -#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, -#> journal = {Example bibtex file}, -#> author = {Georgi N. Boshnakov}, #> year = {2018}, +#> genre = {academic journal}, +#> journal = {Example bibtex file}, +#> citekey = {urlWithPercents}, +#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, +#> volume = {51}, #> pages = {1--1}, #> } #>

    @@ -319,28 +316,38 @@

    Examp #> \url{https://github.com/GeoBosh/zzfiles/blob/master/url\%20with\%20percents.bib}.

    ## here the journal field contains percent encoding fn_other <- system.file("examples", "journal_with_percents.bib", package = "Rdpack") -j <- get_bibentries(bibfile = fn_url) -print(j, style = "html")
    #> <p>Boshnakov GN (2018). +j <- get_bibentries(bibfile = fn_url)
    #> +#> count_type: +#> +#> no_type not_char Article +#> 0 0 1 +#> +#>
    print(j, style = "html")
    #> <p>Boshnakov GN (2018). #> &ldquo;Dummy example of URL with percents.&rdquo; #> <em>Example bibtex file</em>, <b>51</b>, 1&ndash;1. #> <a href="https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib">https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib</a>. #> </p>
    print(j, style = "bibtex")
    #> @Article{urlWithPercents, +#> author = {Georgi N Boshnakov}, #> title = {Dummy example of {URL} with percents}, -#> volume = {51}, -#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, -#> journal = {Example bibtex file}, -#> author = {Georgi N. Boshnakov}, #> year = {2018}, +#> genre = {academic journal}, +#> journal = {Example bibtex file}, +#> citekey = {urlWithPercents}, +#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, +#> volume = {51}, #> pages = {1--1}, #> }
    print(j, style = "R")
    #> bibentry(bibtype = "Article", #> key = "urlWithPercents", +#> author = person(given = c("Georgi", "N"), +#> family = "Boshnakov", +#> role = "aut"), #> title = "Dummy example of {URL} with percents", -#> volume = "51", -#> url = "https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib", -#> journal = "Example bibtex file", -#> author = person(given = c("Georgi", "N."), -#> family = "Boshnakov"), #> year = "2018", +#> genre = "academic journal", +#> journal = "Example bibtex file", +#> citekey = "urlWithPercents", +#> url = "https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib", +#> volume = "51", #> pages = "1--1")
    print(j, style = "text")
    #> Boshnakov GN (2018). “Dummy example of URL with percents.” _Example #> bibtex file_, *51*, 1-1. <URL: #> https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib>.
    print(j, style = "citation")
    #> @@ -351,12 +358,14 @@

    Examp #> A BibTeX entry for LaTeX users is #> #> @Article{urlWithPercents, +#> author = {Georgi N Boshnakov}, #> title = {Dummy example of {URL} with percents}, -#> volume = {51}, -#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, -#> journal = {Example bibtex file}, -#> author = {Georgi N. Boshnakov}, #> year = {2018}, +#> genre = {academic journal}, +#> journal = {Example bibtex file}, +#> citekey = {urlWithPercents}, +#> url = {https://github.com/GeoBosh/zzfiles/blob/master/url%20with%20percents.bib}, +#> volume = {51}, #> pages = {1--1}, #> } #>

    diff --git a/docs/reference/get_sig_text.html b/docs/reference/get_sig_text.html index 4f13927..c9a8699 100644 --- a/docs/reference/get_sig_text.html +++ b/docs/reference/get_sig_text.html @@ -75,7 +75,7 @@ Rdpack - 1.0.1 + 2.0.0
    @@ -152,11 +152,11 @@

    Details rdo &lt;- utils:::.getHelpFile(fn) head(get_sig_text(rdo)) ##: [1] "signature(object = \"ANY\")" -##: [2] "signature(object = \"C++Class\")" -##: [3] "signature(object = \"C++Function\")" -##: [4] "signature(object = \"C++Object\")" -##: [5] "signature(object = \"classGeneratorFunction\")" -##: [6] "signature(object = \"classRepresentation\")"

    +##: [2] "signature(object = \"classGeneratorFunction\")" +##: [3] "signature(object = \"classRepresentation\")" +##: [4] "signature(object = \"envRefClass\")" +##: [5] "signature(object = \"externalRefMethod\")" +##: [6] "signature(object = \"genericFunction\")"

    Value

    A character vector with one element for each method.

    @@ -181,11 +181,11 @@

    Examp ## this will find all methods for "show" in currently loaded packages ## (print only some of them) head(get_sig_text(rdo))
    #> [1] "signature(object = \"ANY\")" -#> [2] "signature(object = \"C++Class\")" -#> [3] "signature(object = \"C++Function\")" -#> [4] "signature(object = \"C++Object\")" -#> [5] "signature(object = \"classGeneratorFunction\")" -#> [6] "signature(object = \"classRepresentation\")"
    +#> [2] "signature(object = \"classGeneratorFunction\")" +#> [3] "signature(object = \"classRepresentation\")" +#> [4] "signature(object = \"envRefClass\")" +#> [5] "signature(object = \"externalRefMethod\")" +#> [6] "signature(object = \"genericFunction\")"
    ## this will select only the ones from package "stats4" get_sig_text(rdo, package = "stats4")
    #> [1] "signature(object = \"mle\")" "signature(object = \"summary.mle\")"
    ## this is also fine (interactively) but need to choose @@ -214,7 +214,7 @@

    Examp #> Rd source not supplied and installed documentation not found. #> Trying a 'prompt' function to generate documentation for the object. #> success: documentation generated using a 'prompt' function. -#> The Rd content was written to file /tmp/RtmpYaQyun/file1a37c3378299c

    #> [1] "/tmp/RtmpYaQyun/file1a37c3378299c"
    rdo <- tools::parse_Rd(fn) +#> The Rd content was written to file /tmp/RtmpNJZtUt/file1b5c4531a13cf7
    #> [1] "/tmp/RtmpNJZtUt/file1b5c4531a13cf7"
    rdo <- tools::parse_Rd(fn) get_sig_text(rdo)
    #> [1] "signature(x = \"ANY\")"
    setClass("aRdpack") setClass("bRdpack") @@ -229,7 +229,7 @@

    Examp #> Rd source not supplied and installed documentation not found. #> Trying a 'prompt' function to generate documentation for the object. #> success: documentation generated using a 'prompt' function. -#> The Rd content was written to file /tmp/RtmpYaQyun/file1a37c3378299c

    #> [1] "/tmp/RtmpYaQyun/file1a37c3378299c"
    rdo <- tools::parse_Rd(fn) +#> The Rd content was written to file /tmp/RtmpNJZtUt/file1b5c4531a13cf7
    #> [1] "/tmp/RtmpNJZtUt/file1b5c4531a13cf7"
    rdo <- tools::parse_Rd(fn) get_sig_text(rdo)
    #> [1] "signature(x = \"ANY\", y = \"ANY\")" #> [2] "signature(x = \"aRdpack\", y = \"bRdpack\")" #> [3] "signature(x = \"aRdpack\", y = \"numeric\")" diff --git a/docs/reference/get_usage_text.html b/docs/reference/get_usage_text.html index 17b6e72..d96f3d8 100644 --- a/docs/reference/get_usage_text.html +++ b/docs/reference/get_usage_text.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0
    diff --git a/docs/reference/index.html b/docs/reference/index.html index 780485b..d4e758f 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -71,7 +71,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/insert_all_ref.html b/docs/reference/insert_all_ref.html index f91876d..1c8f788 100644 --- a/docs/reference/insert_all_ref.html +++ b/docs/reference/insert_all_ref.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -168,32 +168,52 @@

    R

    There are no references for Rd macro \insertAllCites on this help page.

    Examples

    -
    bibs <- bibtex::read.bib(package = "tools") -bibs
    #> Murdoch D (2009). “Parsing Rd files.” <URL: -#> http://developer.r-project.org/parseRd.pdf>.
    +
    ## bibs <- bibtex::read.bib(package = "tools") +## bibs + ## a reference from package Rdpack -cat(insert_all_ref(matrix(c("Rpack:bibtex", "Rdpack"), ncol = 2)), "\n")
    #> Romain Francois (2014). +cat(insert_all_ref(matrix(c("Rpack:bibtex", "Rdpack"), ncol = 2)), "\n")
    #> +#> count_type: +#> +#> no_type not_char Manual Misc Article +#> 0 0 2 1 1 +#> +#> +#> Romain Francois (2014). #> \emph{bibtex: bibtex parser}. -#> R package version 0.4.0, \url{https://CRAN.R-project.org/package=bibtex}.
    +#> R package version 0.4.0.
    ## more than one reference from package Rdpack, separate the keys with commas -cat(insert_all_ref(matrix(c("parseRd,Rpack:bibtex", "Rdpack"), ncol = 2)), "\n")
    #> Romain Francois (2014). +cat(insert_all_ref(matrix(c("parseRd,Rpack:bibtex", "Rdpack"), ncol = 2)), "\n")
    #> +#> count_type: +#> +#> no_type not_char Manual Misc Article +#> 0 0 2 1 1 +#> +#> +#> Romain Francois (2014). #> \emph{bibtex: bibtex parser}. -#> R package version 0.4.0, \url{https://CRAN.R-project.org/package=bibtex}.\cr\cr Duncan Murdoch (2010). +#> R package version 0.4.0.\cr\cr Duncan Murdoch (2010). #> \dQuote{Parsing Rd files.} #> \url{https://developer.r-project.org/parseRd.pdf}.
    ## all references from package Rdpack -cat(insert_all_ref(matrix(c("*", "Rdpack"), ncol = 2)), "\n")
    #> Romain Francois (2014). +cat(insert_all_ref(matrix(c("*", "Rdpack"), ncol = 2)), "\n")
    #> +#> count_type: +#> +#> no_type not_char Manual Misc Article +#> 0 0 2 1 1 +#> +#> +#> Romain Francois (2014). #> \emph{bibtex: bibtex parser}. -#> R package version 0.4.0, \url{https://CRAN.R-project.org/package=bibtex}.\cr\cr Duncan Murdoch (2010). +#> R package version 0.4.0.\cr\cr Duncan Murdoch (2010). #> \dQuote{Parsing Rd files.} #> \url{https://developer.r-project.org/parseRd.pdf}.\cr\cr Hadley Wickham, Jim Hester, Winston Chang (2018). #> \emph{devtools: Tools to Make Developing R Packages Easier}. -#> R package version 1.13.5, \url{https://CRAN.R-project.org/package=devtools}.\cr\cr A. ZZZ (2018). +#> R package version 1.13.5, \url{https://CRAN.R-project.org/package=devtools}.\cr\cr A ZZZ (2018). #> \dQuote{A relation between several fundamental constants: \eqn{e^{i\pi}=-1}.} #> \emph{A non-existent journal with the formula \eqn{L_2} in its name.}. -#> This reference does not exist. It is a test/demo that simple formulas in BibTeX -#> files are OK. A formula in field 'note': \eqn{c^2 = a^2 + b^2}.
    +#> This reference does not exist. It is a test/demo that simple formulas in BibTeX files are OK. A formula in field 'note': \eqn{c^2 = a^2 + b^2}.
    @@ -132,7 +132,7 @@

    Insert bibtex references in Rd and roxygen2 documentation

    vignette.

    -
    insert_ref(key, package = NULL, ...)
    +
    insert_ref(key, package = NULL, ..., cached_env = NULL)

    Arguments

    @@ -149,6 +149,11 @@

    Arg

    + + + +
    ...

    further arguments to pass on to bibtex::read.bib

    cached_env

    environment, used to avoid repeatedly pasing the bib + file from scratch, mainly useful by the Rd macros.

    Details

    @@ -273,16 +278,13 @@

    R each reference:

    Romain Francois (2014). bibtex: bibtex parser. -R package version 0.4.0, https://CRAN.R-project.org/package=bibtex.

    -

    R Development Core Team (2009). -R: A Language and Environment for Statistical Computing. -R Foundation for Statistical Computing, Vienna, Austria. -ISBN 3-900051-07-0, https://www.R-project.org.

    +R package version 0.4.0.

    +

    ----

    The following references are obtained with a single \insertAllCited{}:

    Romain Francois (2014). bibtex: bibtex parser. -R package version 0.4.0, https://CRAN.R-project.org/package=bibtex.

    Duncan Murdoch (2010). +R package version 0.4.0.

    Duncan Murdoch (2010). “Parsing Rd files.” https://developer.r-project.org/parseRd.pdf.

    See also

    @@ -290,11 +292,6 @@

    See a

    Rdpack-package for overview, the vignettes

    -

    Examples

    -
    cat(insert_ref("R", package = "bibtex"), sep = "\n")
    #> R Development Core Team (2009). -#> \emph{R: A Language and Environment for Statistical Computing}. -#> R Foundation for Statistical Computing, Vienna, Austria. -#> ISBN 3-900051-07-0, \url{https://www.R-project.org}.
    diff --git a/docs/reference/inspect_args.html b/docs/reference/inspect_args.html index c2a7a7d..b2b032a 100644 --- a/docs/reference/inspect_args.html +++ b/docs/reference/inspect_args.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/inspect_signatures.html b/docs/reference/inspect_signatures.html index 51595ec..ebbaa8c 100644 --- a/docs/reference/inspect_signatures.html +++ b/docs/reference/inspect_signatures.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/inspect_slots.html b/docs/reference/inspect_slots.html index e34872d..a23f3e0 100644 --- a/docs/reference/inspect_slots.html +++ b/docs/reference/inspect_slots.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/inspect_usage.html b/docs/reference/inspect_usage.html index bd6bafe..114606a 100644 --- a/docs/reference/inspect_usage.html +++ b/docs/reference/inspect_usage.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/list_Rd.html b/docs/reference/list_Rd.html index 1263de0..690c367 100644 --- a/docs/reference/list_Rd.html +++ b/docs/reference/list_Rd.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 @@ -178,7 +178,7 @@

    Examp #> Rd source not supplied and installed documentation not found. #> Trying a 'prompt' function to generate documentation for the object.
    #> Error in reprompt(dummyfun, filename = fn): unsuccessful attempt to create Rd doc. using a 'prompt' function.
    # check that the result can be parsed and show it. -Rdo_show(tools::parse_Rd(fn))
    #> Warning: cannot open file '/tmp/RtmpYaQyun/dummyfun1a37c547736b3Rd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    +Rdo_show(tools::parse_Rd(fn))
    #> Warning: cannot open file '/tmp/RtmpNJZtUt/dummyfun1b5c4561e2022aRd': No such file or directory
    #> Error in file(con, "r"): cannot open the connection
    unlink(fn)

    @@ -229,21 +229,21 @@

    Examp vigbib("utils")
    #> @Article{vigutils:Sweave, #> title = {Sweave User Manual}, #> author = {R Core Team and contributors worldwide}, -#> journal = {URL https://CRAN.R-Project.org. Vignette included in R package utils (Part of R 4.0.1)}, +#> journal = {URL https://CRAN.R-Project.org. Vignette included in R package utils (Part of R 4.0.2)}, #> year = {2020}, #> publisher = {CRAN}, #> url = {https://CRAN.R-Project.org}, #> }
    makeVignetteReference("utils", vig = 1)
    #> @Article{vigutils:Sweave, #> title = {Sweave User Manual}, #> author = {R Core Team and contributors worldwide}, -#> journal = {URL https://CRAN.R-Project.org. Vignette included in R package utils (Part of R 4.0.1)}, +#> journal = {URL https://CRAN.R-Project.org. Vignette included in R package utils (Part of R 4.0.2)}, #> year = {2020}, #> publisher = {CRAN}, #> url = {https://CRAN.R-Project.org}, #> } #>
    #> Team RC, worldwide c (2020). “Sweave User Manual.” _URL #> https://CRAN.R-Project.org. Vignette included in R package utils (Part -#> of R 4.0.1)_. <URL: https://CRAN.R-Project.org>.
    ## commented out since can be slow: +#> of R 4.0.2)_. <URL: https://CRAN.R-Project.org>.
    ## commented out since can be slow: ## high <- installed.packages(priority = "high") ## highbib <- lapply(rownames(high), function(x) try(Rdpack:::vigbib(x, verbose = FALSE)))
    diff --git a/docs/reference/parse_Rdname.html b/docs/reference/parse_Rdname.html index cc48a72..751122e 100644 --- a/docs/reference/parse_Rdname.html +++ b/docs/reference/parse_Rdname.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/parse_Rdpiece.html b/docs/reference/parse_Rdpiece.html index b5a06ac..b63ac84 100644 --- a/docs/reference/parse_Rdpiece.html +++ b/docs/reference/parse_Rdpiece.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/parse_Rdtext.html b/docs/reference/parse_Rdtext.html index ed97403..392ed1d 100644 --- a/docs/reference/parse_Rdtext.html +++ b/docs/reference/parse_Rdtext.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/parse_pairlist.html b/docs/reference/parse_pairlist.html index c30cd61..0b8ce52 100644 --- a/docs/reference/parse_pairlist.html +++ b/docs/reference/parse_pairlist.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/parse_text.html b/docs/reference/parse_text.html index a4dc215..f9f7b98 100644 --- a/docs/reference/parse_text.html +++ b/docs/reference/parse_text.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/parse_usage_text.html b/docs/reference/parse_usage_text.html index 516cbe3..9f1d355 100644 --- a/docs/reference/parse_usage_text.html +++ b/docs/reference/parse_usage_text.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/predefined.html b/docs/reference/predefined.html index 6b863e5..fde1adc 100644 --- a/docs/reference/predefined.html +++ b/docs/reference/predefined.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/promptPackageSexpr.html b/docs/reference/promptPackageSexpr.html index 724188f..4ade3d8 100644 --- a/docs/reference/promptPackageSexpr.html +++ b/docs/reference/promptPackageSexpr.html @@ -74,7 +74,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/promptUsage.html b/docs/reference/promptUsage.html index c2e684d..0d8c3ff 100644 --- a/docs/reference/promptUsage.html +++ b/docs/reference/promptUsage.html @@ -76,7 +76,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/rdo_text_restore.html b/docs/reference/rdo_text_restore.html index b5ae8a4..188e5aa 100644 --- a/docs/reference/rdo_text_restore.html +++ b/docs/reference/rdo_text_restore.html @@ -77,7 +77,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/rebib.html b/docs/reference/rebib.html index 02a8fde..2864272 100644 --- a/docs/reference/rebib.html +++ b/docs/reference/rebib.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/reprompt.html b/docs/reference/reprompt.html index 3dd44c1..0c0229d 100644 --- a/docs/reference/reprompt.html +++ b/docs/reference/reprompt.html @@ -74,7 +74,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/set_Rdpack_bibstyle.html b/docs/reference/set_Rdpack_bibstyle.html index 64b79cb..61b742c 100644 --- a/docs/reference/set_Rdpack_bibstyle.html +++ b/docs/reference/set_Rdpack_bibstyle.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/update_aliases_tmp.html b/docs/reference/update_aliases_tmp.html index afa83ed..c256034 100644 --- a/docs/reference/update_aliases_tmp.html +++ b/docs/reference/update_aliases_tmp.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/viewRd.html b/docs/reference/viewRd.html index c051afa..603aa45 100644 --- a/docs/reference/viewRd.html +++ b/docs/reference/viewRd.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/zzasym_compare.html b/docs/reference/zzasym_compare.html index d230cdf..cf8aa6b 100644 --- a/docs/reference/zzasym_compare.html +++ b/docs/reference/zzasym_compare.html @@ -73,7 +73,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/zzbsdup.html b/docs/reference/zzbsdup.html index ca89640..04523c9 100644 --- a/docs/reference/zzbsdup.html +++ b/docs/reference/zzbsdup.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/docs/reference/zzcapture_promptany.html b/docs/reference/zzcapture_promptany.html index 6bd4da3..b88ac22 100644 --- a/docs/reference/zzcapture_promptany.html +++ b/docs/reference/zzcapture_promptany.html @@ -72,7 +72,7 @@ Rdpack - 1.0.1 + 2.0.0 diff --git a/inst/REFERENCES.bib b/inst/REFERENCES.bib index ace9c92..705cd01 100644 --- a/inst/REFERENCES.bib +++ b/inst/REFERENCES.bib @@ -1,31 +1,31 @@ @Manual{Rpack:bibtex, - title = {bibtex: bibtex parser}, author = {Romain Francois}, + title = {bibtex: bibtex parser}, year = {2014}, note = {R package version 0.4.0}, - url = {https://CRAN.R-project.org/package=bibtex}, } + @misc{parseRd, - title = {Parsing Rd files}, author = {Duncan Murdoch}, + title = {Parsing Rd files}, year = {2010}, url = {https://developer.r-project.org/parseRd.pdf}, } @Manual{Rdevtools, - title = {devtools: Tools to Make Developing R Packages Easier}, author = {Hadley Wickham and Jim Hester and Winston Chang}, + title = {devtools: Tools to Make Developing R Packages Easier}, year = {2018}, note = {R package version 1.13.5}, url = {https://CRAN.R-project.org/package=devtools}, } @Article{dummyArticle, + author = {A. ZZZ}, title = {A relation between several fundamental constants: $e^{i\pi}=-1$}, journal = {A non-existent journal with the formula $L_2$ in its name.}, - author = {A. ZZZ}, year = {2018}, note = {This reference does not exist. It is a test/demo that simple formulas in BibTeX files are OK. A formula in field 'note': $c^2 = a^2 + b^2$.}, diff --git a/man/Rdo_which.Rd b/man/Rdo_which.Rd index 8edfbc1..632aba4 100644 --- a/man/Rdo_which.Rd +++ b/man/Rdo_which.Rd @@ -62,20 +62,20 @@ rdo_seq[[ ind[1] ]] rdo_seq[ind] } -db_bibtex <- tools::Rd_db("bibtex") -names(db_bibtex) -## Rdo object for read.bib() -rdo_read.bib <- db_bibtex[["read.bib.Rd"]] -Rdo_tags(rdo_read.bib) - -## which elements of read.bib are aliases? -Rdo_which_tag_eq(rdo_read.bib, "\\alias") -rdo_read.bib[[3]] - -## which elements of read.bib contain R code? -Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "RCODE") ) -rdo_read.bib[[5]] -## which contain prose? -Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "TEXT") ) +## db_bibtex <- tools::Rd_db("bibtex") +## names(db_bibtex) +## ## Rdo object for read.bib() +## rdo_read.bib <- db_bibtex[["read.bib.Rd"]] +## Rdo_tags(rdo_read.bib) +## +## ## which elements of read.bib are aliases? +## Rdo_which_tag_eq(rdo_read.bib, "\\alias") +## rdo_read.bib[[3]] +## +## ## which elements of read.bib contain R code? +## Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "RCODE") ) +## rdo_read.bib[[5]] +## ## which contain prose? +## Rdo_which(rdo_read.bib, function(x) any(Rdo_tags(x) == "TEXT") ) } \keyword{Rd} diff --git a/man/Rdpack-package.Rd b/man/Rdpack-package.Rd index c9291ab..105243c 100644 --- a/man/Rdpack-package.Rd +++ b/man/Rdpack-package.Rd @@ -42,7 +42,7 @@ A set of functions and macros support inclusion of references and citations from BibTeX files in \R documentation (Rd and roxygen2). These tools use only facilities provided by base \R and - package \pkg{bibtex} \insertCite{Rpack:bibtex}{Rdpack}. + package \pkg{rbibutils} \insertCite{Rpack:bibtex}{Rdpack}. There are also convenience macros for inclusion of evaluated examples and graphs, which hide some of the hassle of doing this directly with diff --git a/man/get_bibentries.Rd b/man/get_bibentries.Rd index 6579a2e..434506c 100644 --- a/man/get_bibentries.Rd +++ b/man/get_bibentries.Rd @@ -22,8 +22,10 @@ get_bibentries(\dots, package = NULL, bibfile = "REFERENCES.bib", } \details{ - \code{get_bibentries} parses the specified file using \code{read.bib} - from package \pkg{bibtex} \insertCite{Rpack:bibtex}{Rdpack} and sets its + \code{get_bibentries} parses the specified file. + % using \code{read.bib} from package \pkg{bibtex} + % \insertCite{Rpack:bibtex}{Rdpack} + and sets its \code{names} attribute to the keys of the bib elements (\code{read.bib()} does this since version version 0.4.0 of \pkg{bibtex}, as well). Here is what @@ -90,9 +92,12 @@ r <- get_bibentries(package = "Rdpack") r print(r, style = "html") -b <- get_bibentries(package = "stats") -print(b[[1]], style = "R") -print(b[[1]], style = "citation") +## Bib from base R packages are disabled in Rdpack v2 (notify the +## maintainer of Rdpack or raise an issue on github if you wish this back). +## +## b <- get_bibentries(package = "stats") +## print(b[[1]], style = "R") +## print(b[[1]], style = "citation") ## here the url field contains percent encoding fn_url <- system.file("examples", "url_with_percents.bib", package = "Rdpack") diff --git a/man/insert_all_ref.Rd b/man/insert_all_ref.Rd index 2c6a21a..7e893de 100644 --- a/man/insert_all_ref.Rd +++ b/man/insert_all_ref.Rd @@ -58,8 +58,8 @@ insert_all_ref(refs, style = "") % %% ~~objects to See Also as \code{\link{help}}, ~~~ % } \examples{ -bibs <- bibtex::read.bib(package = "tools") -bibs +## bibs <- bibtex::read.bib(package = "tools") +## bibs ## a reference from package Rdpack diff --git a/man/insert_ref.Rd b/man/insert_ref.Rd index 3dcb611..c8cab28 100644 --- a/man/insert_ref.Rd +++ b/man/insert_ref.Rd @@ -13,12 +13,16 @@ } \usage{ -insert_ref(key, package = NULL, ...) +insert_ref(key, package = NULL, \dots, cached_env = NULL) } \arguments{ \item{key}{the bibtex key of the reference, a character string.} \item{package}{the package in which to look for the the bibtex file.} \item{\dots}{further arguments to pass on to \code{bibtex::read.bib}} + \item{cached_env}{ + environment, used to avoid repeatedly pasing the bib + file from scratch, mainly useful by the Rd macros. + } } \details{ \code{insert_ref} extracts a reference from a bibtex file, converts @@ -160,7 +164,7 @@ references for \code{\\insertAllCited}. \insertRef{Rpack:bibtex}{Rdpack} - \insertRef{R}{bibtex} + % \insertRef{R}{bibtex} ---- @@ -173,8 +177,8 @@ references for \code{\\insertAllCited}. \code{\link{Rdpack-package}} for overview, the vignettes } -\examples{ -cat(insert_ref("R", package = "bibtex"), sep = "\n") -} +% \examples{ +% cat(insert_ref("R", package = "bibtex"), sep = "\n") +% } \keyword{documentation} \keyword{Rd} diff --git a/man/macros/refmacros.Rd b/man/macros/refmacros.Rd index 483fcaa..455e606 100644 --- a/man/macros/refmacros.Rd +++ b/man/macros/refmacros.Rd @@ -1,5 +1,8 @@ % insert reference #1 - key, #2 - package -\newcommand{\insertRef}{\Sexpr[results=rd,stage=build]{Rdpack::insert_ref(key="#1",package="#2")}} +%% changing to cache bib as insertCite does +%% \newcommand{\insertRef}{\Sexpr[results=rd,stage=build]{Rdpack::insert_ref(key="#1",package="#2")}} +\newcommand{\insertRef}{\Sexpr[results=rd,stage=build]{if(!exists(".Rdpack.currefs")) .Rdpack.currefs <- new.env(); Rdpack::insert_ref(key="#1",package="#2", cached_env=.Rdpack.currefs)}} + % insert reference #1 - key, #2 - package \newcommand{\insertCiteOnly}{\Sexpr[results=rd,stage=build]{if(!exists(".Rdpack.currefs")) .Rdpack.currefs <- new.env();Rdpack::insert_citeOnly(key="#1",package="#2", cached_env=.Rdpack.currefs,cite_only=TRUE)}} diff --git a/vignettes/Inserting_bibtex_references.org b/vignettes/Inserting_bibtex_references.org index 955b2f7..57c32c9 100644 --- a/vignettes/Inserting_bibtex_references.org +++ b/vignettes/Inserting_bibtex_references.org @@ -102,7 +102,6 @@ example, the help page ~?Rdpack::insertRef~ contains the following lines in sect ``References'' of the Rd file: #+BEGIN_EXAMPLE \insertRef{Rpack:bibtex}{Rdpack} - \insertRef{R}{bibtex} #+END_EXAMPLE The first line above inserts the reference labeled =Rpack:bibtex= in Rdpack's =REFERENCES.bib=. The second line inserts the reference labeled =R= in file @@ -112,8 +111,6 @@ A roxygen2 documentation chunk might look like this: #+BEGIN_EXAMPLE #' @references #' \insertRef{Rpack:bibtex}{Rdpack} - #' - #' \insertRef{R}{bibtex} #+END_EXAMPLE