Skip to content

Reworked vignette processing via new 'asis' driver #1394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2025-07-18 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version and date
* inst/include/Rcpp/config.h: Idem

* R/asis.R (asisWeave, asisTangle): Borrowed with thanks from R.rsp
and shortened / simplified to provide 'asis' vignette processor
* R/zzz.R (.onLoad): Register new vignette processor
* vignettes/*.asis: New files with vignette info from .Rnw files
* vignettes/pdf/*.pdf: Moved to directory vignettes/
* vignettes/*.Rnw: Removed
* man/asisWeave.Rd: Documentation

2025-07-01 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Date, Version): Release 1.1.0
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: Rcpp
Title: Seamless R and C++ Integration
Version: 1.1.0
Date: 2025-07-01
Version: 1.1.0.1
Date: 2025-07-18
Authors@R: c(person("Dirk", "Eddelbuettel", role = c("aut", "cre"), email = "edd@debian.org",
comment = c(ORCID = "0000-0001-6419-907X")),
person("Romain", "Francois", role = "aut",
Expand Down Expand Up @@ -35,3 +35,4 @@ BugReports: https://github.com/RcppCore/Rcpp/issues
MailingList: rcpp-devel@lists.r-forge.r-project.org
RoxygenNote: 6.1.1
Encoding: UTF-8
VignetteBuilder: Rcpp
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export(Module,
cpp_object_initializer,
cpp_object_dummy,
Rcpp.plugin.maker,
getRcppVersion
)
getRcppVersion)
S3method(print, bytes)
S3method(format, Rcpp_stack_trace)
S3method(str, Rcpp_stack_trace)
Expand Down
56 changes: 56 additions & 0 deletions R/asis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
## These two functions are borrowed with grateful appreciation from the R.rsp package
## by Henrik Bengtsson licensend under LPGL (>= 2.1) and somewhat simplified / shortened
## feature-reduced here. Please the R.rsp for a full-featured version and documentation

##' Simple \sQuote{asis} Vignette Processor
##'
##' To pass pre-made pdf vignette vignettes through \dQuote{as is}, a simple vignette
##' process is added. It is derived from the more feature-complete one in the \pkg{R.rsp}
##' package. To use it, add files named like the pdf file plus an appended \code{.asis}
##' with the vignette metainformation and register the vignette processor, see the examples.
##'
##' @title Process pdf vignettes \sQuote{asis}
##' @name asisWeave
##' @param file character Filename to be processed
##' @param ... dots Currently ignored
##' @param pattern character A regular expression describing the filename pattern
##' @return The respective filename is returned, invisibly
##' @author Henrik Bengtsson for the original versions in package \pkg{R.rsp},
##' Dirk Eddelbuettel for the shortened ones used here
##' @examples
##' # To register this vignette engine in another package, add
##' # \code{VignetteBuilder: Rcpp} as well as \code{Suggests: Rcpp} to \code{DESCRIPTON}
##' # which uses the registration this package provides via
##' \dontrun{tools::vignetteEngine("asis", package = pkgname, pattern = "[.](pdf|html)[.]asis$",
##' weave = asisWeave, tangle = asisTangle)}
##'
##' # Use a .asis file as in the Rcpp package, for example Rcpp-FAQ.pdf.asis has these lines:
##' # %\VignetteIndexEntry{Rcpp-FAQ}
##' # %\VignetteKeywords{Rcpp, FAQ, R, Cpp}
##' # %\VignettePackage{Rcpp}
##' # %\VignetteEncoding{UTF-8}
##' # %\VignetteEngine{Rcpp::asis}
asisWeave <- function (file, ...) {
output <- tools::file_path_sans_ext(basename(file))
if (!file.exists(output)) {
outputS <- file.path("..", "inst", "doc", output)
if (file.exists(outputS)) {
file.copy(outputS, output, overwrite = TRUE)
output <- outputS
} else {
stop("No file to process", call. = FALSE)
}
}
Sys.setFileTime(output, time = Sys.time())
invisible(output)
}

##' @rdname asisWeave
asisTangle <- function (file, ..., pattern = "(|[.][^.]*)[.]asis$") {
workdir <- "."
filename <- basename(file)
fullname <- gsub(pattern, "", filename)
filenameR <- sprintf("%s.R", fullname)
cat(sprintf("### This is an R script tangled from '%s'\n", filename), file = filenameR)
invisible(filenameR)
}
9 changes: 5 additions & 4 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2009 - 2016 Dirk Eddelbuettel and Romain Francois
# Copyright (C) 2009 - 2025 Dirk Eddelbuettel and Romain Francois
#
# This file is part of Rcpp.
#
Expand All @@ -20,7 +20,8 @@
.classes_map <- new.env()

.onLoad <- function(libname, pkgname){
new_dummyObject(.dummyInstancePointer) # nocov
}

new_dummyObject(.dummyInstancePointer) # nocov start

tools::vignetteEngine("asis", package = pkgname, pattern = "[.](pdf|html)[.]asis$",
weave = asisWeave, tangle = asisTangle) # nocov end
}
10 changes: 10 additions & 0 deletions inst/NEWS.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
\newcommand{\ghpr}{\href{https://github.com/RcppCore/Rcpp/pull/#1}{##1}}
\newcommand{\ghit}{\href{https://github.com/RcppCore/Rcpp/issues/#1}{##1}}

\section{Changes in Rcpp release version 1.1.1 (2026-01-xx)}{
\itemize{
\item Changes in Rcpp Documentation:
\itemize{
\item Vignettes are now processed via a new "asis" processor adopted
from \pkg{R.rsp} (Dirk in \ghpr{1394} fixing \ghit{1393})
}
}
}

\section{Changes in Rcpp release version 1.1.0 (2025-07-01)}{
\itemize{
\item Changes in Rcpp API:
Expand Down
4 changes: 2 additions & 2 deletions inst/include/Rcpp/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#define RCPP_VERSION_STRING "1.1.0"

// the current source snapshot (using four components, if a fifth is used in DESCRIPTION we ignore it)
#define RCPP_DEV_VERSION RcppDevVersion(1,1,0,0)
#define RCPP_DEV_VERSION_STRING "1.1.0.0"
#define RCPP_DEV_VERSION RcppDevVersion(1,1,0,1)
#define RCPP_DEV_VERSION_STRING "1.1.0.1"

#endif
48 changes: 48 additions & 0 deletions man/asisWeave.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/compilerCheck.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions vignettes/Rcpp-FAQ.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-FAQ.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-FAQ.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-FAQ}
%\VignetteKeywords{Rcpp, FAQ, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-attributes.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-attributes.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-attributes.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-attributes}
%\VignetteKeywords{Rcpp, attributes, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-extending.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-extending.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-extending.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-extending}
%\VignetteKeywords{Rcpp, extending, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
11 changes: 0 additions & 11 deletions vignettes/Rcpp-introduction.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-introduction.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-introduction.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-introduction}
%\VignetteKeywords{Rcpp, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
Binary file modified vignettes/Rcpp-jss-2011.pdf
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
\documentclass{article}
\usepackage{pdfpages}
%\VignetteIndexEntry{Rcpp-JSS-2011}
%\VignetteKeywords{Rcpp, foreign function interface, .Call, C++, R}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}

\begin{document}
\includepdf[pages=-, fitpaper=true]{pdf/Rcpp-jss-2011.pdf}
\end{document}

%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-libraries.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-libraries.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-libraries.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-libraries}
%\VignetteKeywords{Rcpp, Package, Library}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-modules.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-modules.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-modules.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-modules}
%\VignetteKeywords{Rcpp, modules, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-package.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-package.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-package.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-package}
%\VignetteKeywords{Rcpp, package, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-quickref.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-quickref.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-quickref.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-quickref}
%\VignetteKeywords{Rcpp, quickref, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
10 changes: 0 additions & 10 deletions vignettes/Rcpp-sugar.Rnw

This file was deleted.

Binary file modified vignettes/Rcpp-sugar.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions vignettes/Rcpp-sugar.pdf.asis
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
%\VignetteIndexEntry{Rcpp-sugar}
%\VignetteKeywords{Rcpp, sugar, R, Cpp}
%\VignettePackage{Rcpp}
%\VignetteEncoding{UTF-8}
%\VignetteEngine{Rcpp::asis}
Binary file removed vignettes/pdf/Rcpp-FAQ.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-attributes.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-extending.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-introduction.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-jss-2011.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-libraries.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-modules.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-package.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-quickref.pdf
Binary file not shown.
Binary file removed vignettes/pdf/Rcpp-sugar.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions vignettes/rmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rmdvignettes := $(rmdsources:.Rmd=.pdf)
%.pdf: %.Rmd
Rscript -e 'rmarkdown::render("$<")'
Rscript -e 'tools::compactPDF("$@", gs_quality="ebook")'
cp -vax $@ ../pdf
cp -vax $@ ..

all: ${rmdvignettes} Rcpp-jss-2011.pdf

Expand All @@ -19,7 +19,7 @@ Rcpp-jss-2011.pdf: Rcpp-jss-2011.tex
bibtex Rcpp-jss-2011.aux
Rscript -e 'tools::texi2pdf("$<", texi2dvi="pdflatex")'
Rscript -e 'tools::compactPDF("$@", gs_quality="ebook")'
cp -vax $@ ../pdf
cp -vax $@ ..

clean:
@rm -rf *.aux *.log *.out *.toc *.tex *.pdf Rcpp-introduction_cache Rcpp-libraries_cache pinp.cls Rcpp-jss-2011.bbl Rcpp-jss-2011.blg auto