diff --git a/DESCRIPTION b/DESCRIPTION index d4553c4..5c75393 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rdpack Type: Package Title: Update and Manipulate Rd Documentation Objects -Version: 2.5.9000 +Version: 2.6 Authors@R: c( person(given = c("Georgi", "N."), family = "Boshnakov", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 1e9a81b..c72aa52 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,16 @@ +# Rdpack 2.6 + +- fixed issues causing 'lost braces' (actually, superfluous braces) NOTEs from + checks in R-devel occuring with some accented LaTeX characters. These NOTEs + are not yet activated on CRAN but if/when they do, developers using Rd macros + `\insertRef` and `\insertCite` can eliminate them by building their packages + with Rdpack (> 2.5) and rbibutils (>= 2.2.16). Thanks to Sebastian Meyer for + tracing down the issues. + +- fixed a `Sweave` expression in 'man/predefined.Rd' to not emit unnecessary + braces (see the note above). + + # Rdpack 2.5 - Rd macros `insertCite` and friends were calling `insert_citeOnly` with diff --git a/R/bib.R b/R/bib.R index a33a279..de16dc0 100644 --- a/R/bib.R +++ b/R/bib.R @@ -1052,49 +1052,50 @@ insert_all_ref <- function(refs, style = "", empty_cited = FALSE){ paste0(res, collapse = "\\cr\\cr ") } -deparseLatexToRd <- function(x, dropBraces = FALSE) -{ - result <- character() - lastTag <- "TEXT" - for (i in seq_along(x)) { - a <- x[[i]] - tag <- attr(a, "latex_tag") - if (is.null(tag)) tag <- "NULL" - switch(tag, - VERB = , - TEXT = , - COMMENT = result <- c(result, a), - MACRO = { - ## see issue #26 - ## regex in r-devel/R/src/library/tools/R/RdConv2.R: - ## pat <- "([^\\]|^)\\\\[#$&_^~]" - ## here we add grouping for substitution - pat <- "([^\\]|^)(\\\\)([#$&_^~])" # with more grouping - if(grepl(pat, a)){ - a <- gsub(pat, "\\1\\3", a) - } - result <- c(result, a) - }, - BLOCK = result <- c(result, if (dropBraces && lastTag == "TEXT") Recall(a) else c("{", Recall(a), "}")), - ENVIRONMENT = result <- c(result, - "\\begin{", a[[1L]], "}", - Recall(a[[2L]]), - "\\end{", a[[1L]], "}"), - ## MATH = result <- c(result, "$", Recall(a), "$"), - MATH = result <- c(result, "\\eqn{", Recall(a), "}"), - NULL = stop("Internal error, no tag", domain = NA) - ) - lastTag <- tag - } - paste(result, collapse="") -} - - +## deparseLatexToRd <- function(x, dropBraces = FALSE) +## { +## result <- character() +## lastTag <- "TEXT" +## for (i in seq_along(x)) { +## a <- x[[i]] +## tag <- attr(a, "latex_tag") +## if (is.null(tag)) tag <- "NULL" +## switch(tag, +## VERB = , +## TEXT = , +## COMMENT = result <- c(result, a), +## MACRO = { +## ## see issue #26 +## ## regex in r-devel/R/src/library/tools/R/RdConv2.R: +## ## pat <- "([^\\]|^)\\\\[#$&_^~]" +## ## here we add grouping for substitution +## pat <- "([^\\]|^)(\\\\)([#$&_^~])" # with more grouping +## if(grepl(pat, a)){ +## a <- gsub(pat, "\\1\\3", a) +## } +## result <- c(result, a) +## }, +## BLOCK = result <- c(result, if (dropBraces && lastTag == "TEXT") Recall(a) else c("{", Recall(a), "}")), +## ENVIRONMENT = result <- c(result, +## "\\begin{", a[[1L]], "}", +## Recall(a[[2L]]), +## "\\end{", a[[1L]], "}"), +## ## MATH = result <- c(result, "$", Recall(a), "$"), +## MATH = result <- c(result, "\\eqn{", Recall(a), "}"), +## NULL = stop("Internal error, no tag", domain = NA) +## ) +## lastTag <- tag +## } +## paste(result, collapse="") +## } `%notin%` <- function(x, y) is.na(match(x, y)) +## tools::deparseLatex() is by Sebastian Meyer and Duncan Murdoc. Below is a +## version suitable for Rdpack. +## ## This converts a latex object into a single element character vector deparseLatexToRd <- function(x, dropBraces = FALSE) { diff --git a/inst/CITATION b/inst/CITATION old mode 100644 new mode 100755 diff --git a/inst/REFERENCES.bib b/inst/REFERENCES.bib old mode 100644 new mode 100755 diff --git a/inst/RStudio/addins.dcf b/inst/RStudio/addins.dcf old mode 100644 new mode 100755 diff --git a/inst/examples/Rdpack-package.Rd b/inst/examples/Rdpack-package.Rd old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester.pdf b/inst/examples/RdpackTester.pdf old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester/DESCRIPTION b/inst/examples/RdpackTester/DESCRIPTION old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester/NAMESPACE b/inst/examples/RdpackTester/NAMESPACE old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester/R/RdpackTester-internal.R b/inst/examples/RdpackTester/R/RdpackTester-internal.R old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester/inst/REFERENCES.bib b/inst/examples/RdpackTester/inst/REFERENCES.bib old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester/inst/auto/REFERENCES.el b/inst/examples/RdpackTester/inst/auto/REFERENCES.el old mode 100644 new mode 100755 diff --git a/inst/examples/RdpackTester/man/RdpackTester-package.Rd b/inst/examples/RdpackTester/man/RdpackTester-package.Rd old mode 100644 new mode 100755 diff --git a/inst/examples/journal_with_percents.bib b/inst/examples/journal_with_percents.bib old mode 100644 new mode 100755 diff --git a/inst/examples/reprompt.Rd b/inst/examples/reprompt.Rd old mode 100644 new mode 100755 diff --git a/inst/examples/tz.Rd b/inst/examples/tz.Rd old mode 100644 new mode 100755 diff --git a/inst/examples/url_with_percents.bib b/inst/examples/url_with_percents.bib old mode 100644 new mode 100755 diff --git a/man/Rdpack-package.Rd b/man/Rdpack-package.Rd index 6e9c447..8b64a9a 100644 --- a/man/Rdpack-package.Rd +++ b/man/Rdpack-package.Rd @@ -280,7 +280,7 @@ R 3.6.0. \verb{\printExample} is typically placed in section Details of an object's documentation, see section Details of \code{\link{get_usage}} -for anumber of examples produced mostly with \verb{\printExample}. +for a number of examples produced mostly with \verb{\printExample}. The macro \verb{\runExamples} can be used as a replacement of section \verb{Examples}. diff --git a/man/Rdpack_bibstyles.Rd b/man/Rdpack_bibstyles.Rd index 61c34e3..58d9dd4 100644 --- a/man/Rdpack_bibstyles.Rd +++ b/man/Rdpack_bibstyles.Rd @@ -1,25 +1,28 @@ \name{Rdpack_bibstyles} \alias{Rdpack_bibstyles} -%- Also NEED an '\alias' for EACH other topic documented here. + \title{Set up a custom style for references in help pages} + \description{Set up a custom style for references in help pages.} + \usage{ Rdpack_bibstyles(package, authors) } -%- maybe also 'usage' for other objects documented here. + \arguments{ \item{package}{the name of a package, a character string.} \item{authors}{if equal to "LongNames", use full names of authors in reference lists, see Details.} } + \details{ This is the initial implementation of support for styles for lists of bibliography references. - Currently setting "authors" to "LongNames" will cause the references - to appear with full names, eg John Smith rather than in the default - Smith J style. + Currently setting \code{authors} to \code{"LongNames"} will cause the + references to appear with full names, eg John Smith rather than in the + default Smith J style. Package authors can request this feature by adding the following line to their \code{.onLoad} function (if their package has one): diff --git a/man/insert_all_ref.Rd b/man/insert_all_ref.Rd index c707a97..9e09bf9 100644 --- a/man/insert_all_ref.Rd +++ b/man/insert_all_ref.Rd @@ -37,16 +37,16 @@ insert_all_ref(refs, style = "", empty_cited = FALSE) } \value{ - for \code{insert_all_ref}, a character string containing a textual - representation of the references, suitable for inclusion in an Rd - file + a character string containing a textual representation of the + references, suitable for inclusion in an Rd file } \references{ - Currently there are no citations. Nevethelese, I have put - \verb{\insertAllCited{}} just after this paragraph to show the message - that it prints when there are no citations. This seems better than - printing nothing but it may be argued also that there should be a - warning as well. + + Currently there are no citations on this help page. Nevetheless, I + have put \verb{\insertAllCited{}} just after this paragraph to show + the message that it prints when there are no citations. This seems + better than printing nothing but it may be argued also that there + should be a warning as well. \insertAllCited{} } @@ -75,4 +75,3 @@ m <- matrix(c("*", "Rdpack", "*", "rbibutils"), ncol = 2, byrow = TRUE) cat(insert_all_ref(m), "\n") } \keyword{documentation} -% use one of RShowDoc("KEYWORDS") diff --git a/man/insert_citeOnly.Rd b/man/insert_citeOnly.Rd index cc89c3a..12c783f 100644 --- a/man/insert_citeOnly.Rd +++ b/man/insert_citeOnly.Rd @@ -1,12 +1,16 @@ \name{insert_citeOnly} \alias{insert_citeOnly} + \title{Generate citations from bibtex keys} + \description{Generate citations from bibtex keys.} + \usage{ insert_citeOnly(keys, package = NULL, before = NULL, after = NULL, bibpunct = NULL, ..., cached_env = NULL, cite_only = FALSE, dont_cite = FALSE) } + \arguments{ \item{keys}{ @@ -15,7 +19,8 @@ insert_citeOnly(keys, package = NULL, before = NULL, after = NULL, Rd macro \verb{\\insertCite}. Put \verb{;textual} at the end of the string to get a textual citation. Similarly, \verb{;nobrackets} requests parenthesised citation without the enclosing parentheses. - + Alternatively, \code{keys} can contain one or more keys, separated + by commas. } \item{package}{name of an R package.} \item{before}{see \code{\link{citeNatbib}}.} @@ -26,13 +31,15 @@ insert_citeOnly(keys, package = NULL, before = NULL, after = NULL, \item{cite_only}{for internal use.} \item{dont_cite}{for internal use.} } + \details{ This is the function behind \verb{\\insertCite} and related macros. Argument \code{"keys"} has the syntax of the first argument of - \verb{\\insertCite}. + \verb{\\insertCite}, see \code{\link{insertRef}} for full details. } + \value{ a character vector containing the references with Rd markup } @@ -40,9 +47,11 @@ insert_citeOnly(keys, package = NULL, before = NULL, after = NULL, %%% ~put references to the literature/web site here ~ %} \author{Georgi N. Boshnakov} + \seealso{ \code{\link{insert_ref}} for description of all available Rd macros } + \examples{ insert_citeOnly("@see also @Rpackage:rbibutils and @parseRd", package = "Rdpack") ## (see also Boshnakov and Putman 2020 and Murdoch 2010) @@ -55,4 +64,6 @@ insert_citeOnly("@see also @Rpackage:rbibutils and @parseRd;textual", package = "Rdpack") ## see also Boshnakov and Putman (2020) and Murdoch (2010) } + \keyword{documentation} + diff --git a/man/insert_ref.Rd b/man/insert_ref.Rd index d866cb5..c1d4a8f 100644 --- a/man/insert_ref.Rd +++ b/man/insert_ref.Rd @@ -1,7 +1,14 @@ \name{insert_ref} \alias{insert_ref} + \alias{insertRef} + +\concept{Rd macros} +\concept{bibtex} + + \title{Insert bibtex references in Rd and roxygen2 documentation} + \description{ Package Rdpack provides Rd macros for inserting references and @@ -11,9 +18,11 @@ see the vignette. } + \usage{ 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 bibtex file.} @@ -23,10 +32,11 @@ insert_ref(key, package = NULL, \dots, cached_env = NULL) "REFERENCES.bib", see \code{\link{get_bibentries}}. } \item{cached_env}{ - environment, used to avoid repeatedly pasing the bib - file from scratch, mainly useful by the Rd macros. + environment, used to avoid repeatedly passing the bib + file from scratch, mainly used by the Rd macros. } } + \details{ \code{insert_ref} extracts a bibliograhic reference from a bibtex diff --git a/man/macros/refmacros.Rd b/man/macros/refmacros.Rd old mode 100644 new mode 100755 diff --git a/man/predefined.Rd b/man/predefined.Rd index 6beee08..53b644a 100644 --- a/man/predefined.Rd +++ b/man/predefined.Rd @@ -2,6 +2,7 @@ \alias{Rdo_predefined_sections} \alias{Rdo_piece_types} \alias{rdo_top_tags} + \title{ Tables of predefined sections and types of pieces of Rd objects } @@ -21,8 +22,8 @@ rdo_top_tags \insertCite{parseRd}{Rdpack}. \pkg{Rdpack} stores them in the variables described here. - \code{Rdo_predefined_sections} is a named character vector of types of the - top level sections of an Rd object. + \code{Rdo_predefined_sections} is a named character vector providing + the types of the top level sections in an Rd object. \code{Rdo_piece_types} is a named character vector giving the types of the core (all possible?) Rd macros. @@ -36,9 +37,8 @@ rdo_top_tags \value{ for \code{Rdo_predefined_sections}, the name-value pairs are given in - the following table. For example, - \code{Rdo_predefined_sections["examples"]} is - \Sexpr[stage=build,results=rd]{Rdo_predefined_sections["examples"]}. + the following table. For example, \code{Rdo_predefined_sections["examples"]} results + in \Sexpr[stage=build,results=rd]{Rdo_predefined_sections["examples"]}. \Sexpr[stage=build,results=rd]{require(Rdpack); paste( @@ -88,12 +88,12 @@ rdo_top_tags \Sexpr[stage=build,results=rd]{ paste("\\\\tabular{lllll}{", - paste(sub("^[#]", "\\\\\\\\verb{#}", sub("^([\\\\])", "{\\\\\\\\\\\\1}", rdo_top_tags)), + paste(sub("^[#]", "\\\\\\\\verb{#}", sub("^([\\\\])", "\\\\\\\\\\\\1", rdo_top_tags)), c(rep("\\\\tab ",4),"\\\\cr"), sep="", collapse="\n"), "}")} - Note that most, but not all, are prefixed with backaslash. + Note that most, but not all, are prefixed with a backslash. } \references{ \insertAllCited{} diff --git a/tests/testthat/StructureClasses.Rd b/tests/testthat/StructureClasses.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat/as.character.f_usage.Rd b/tests/testthat/as.character.f_usage.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat/char2Rdpiece_a.RDS b/tests/testthat/char2Rdpiece_a.RDS old mode 100644 new mode 100755 diff --git a/tests/testthat/char2Rdpiece_b.RDS b/tests/testthat/char2Rdpiece_b.RDS old mode 100644 new mode 100755 diff --git a/tests/testthat/char2Rdpiece_c.RDS b/tests/testthat/char2Rdpiece_c.RDS old mode 100644 new mode 100755 diff --git a/tests/testthat/classRepresentation-class.Rd b/tests/testthat/classRepresentation-class.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat/get_sig_text_f1.RDS b/tests/testthat/get_sig_text_f1.RDS old mode 100644 new mode 100755 diff --git a/tests/testthat/get_sig_text_f4.RDS b/tests/testthat/get_sig_text_f4.RDS old mode 100644 new mode 100755 diff --git a/tests/testthat/initialize-methods.Rd b/tests/testthat/initialize-methods.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat/myshow-methods.Rd b/tests/testthat/myshow-methods.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat/show.Rd b/tests/testthat/show.Rd old mode 100644 new mode 100755 diff --git a/tests/testthat/test-bib.R b/tests/testthat/test-bib.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-char2Rdpiece.R b/tests/testthat/test-char2Rdpiece.R old mode 100644 new mode 100755 diff --git a/tests/testthat/test-reprompt.R b/tests/testthat/test-reprompt.R old mode 100644 new mode 100755