Skip to content

Commit 458d12a

Browse files
ben-schwenyihuirikivillalbaaitapMichaelChirico
authored
use litedown for rendering vignettes (#6583)
* add first steps * add litedown R CMD check occasional * remove knitr::opts_chunk * set comment char * add error option * update comment char * adjust print * remove space * fix namespace * Update vignettes/datatable-benchmarking.Rmd Co-authored-by: Yihui Xie <xie@yihui.name> * use yihuis suggestions * upd translation script and r -> {r} code blocks * move knitr tests * Enhances: knitr Since we register a method for knitr::knit_print, keep it mentioned in the DESCRIPTION. * Register xfun::record_print method for data.table As with knit_print, avoid printing x when !shouldPrint(x). Use the overloaded method in the vignettes instead of relying on the auto-printing detection in print.data.table. * add nocov * add nocov for knitr_print * nocov range * Add missing periods. * Fix footnote * Fix remaining `r ...` expressions * update joins vignette * set/unset threads * sys.date * add xfun to enhances * add litedown mock * fix translation links * more translation links * remove knitr in fread and fwrite vignette * add NEWS --------- Co-authored-by: Yihui Xie <xie@yihui.name> Co-authored-by: Ricardo Villalba <rikivillalba@gmail.com> Co-authored-by: Ivan K <krylov.r00t@gmail.com> Co-authored-by: Michael Chirico <chiricom@google.com> Co-authored-by: Christian Wia <w9204-gi@yahoo.com>
1 parent 6f8bb9e commit 458d12a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+245
-373
lines changed

.dev/CRAN_Release.cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ Rdevel-strict-[gcc|clang] CMD check data.table_1.16.99.tar.gz
323323
Rdevel-strict-[gcc|clang]
324324
isTRUE(.Machine$sizeof.longdouble==0) # check noLD is being tested
325325
options(repos = "http://cloud.r-project.org")
326-
install.packages(c("bit64", "bit", "R.utils", "xts", "zoo", "yaml", "knitr", "markdown"),
326+
install.packages(c("bit64", "bit", "R.utils", "xts", "zoo", "yaml", "litedown"),
327327
Ncpus=4)
328328
# Issue #5491 showed that CRAN is running UBSAN on .Rd examples which found an error so we now run full R CMD check
329329
q("no")

.github/workflows/R-CMD-check-occasional.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ jobs:
111111
TEST_DATA_TABLE_WITH_OTHER_PACKAGES=as.character(run_other)
112112
)
113113
114-
do_vignettes = requireNamespace("knitr", quietly=TRUE)
114+
do_vignettes = requireNamespace("litedown", quietly=TRUE)
115115
116116
build_args = NULL
117117
check_args = c("--no-manual", "--as-cran")

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ Version: 1.18.99
33
Title: Extension of `data.frame`
44
Depends: R (>= 3.5.0)
55
Imports: methods
6-
Suggests: bit64 (>= 4.0.0), bit (>= 4.0.4), R.utils (>= 2.13.0), xts, zoo (>= 1.8-1), yaml, knitr, markdown
6+
Suggests: bit64 (>= 4.0.0), bit (>= 4.0.4), R.utils, xts, zoo (>= 1.8-1), yaml, litedown
7+
Enhances: knitr, xfun
78
Description: Fast aggregation of large data (e.g. 100GB in RAM), fast ordered joins, fast add/modify/delete of columns by group using no copies at all, list columns, friendly and fast character-separated-value read/write. Offers a natural and flexible syntax, for faster development.
89
License: MPL-2.0 | file LICENSE
910
URL: https://r-datatable.com, https://Rdatatable.gitlab.io/data.table, https://github.com/Rdatatable/data.table
1011
BugReports: https://github.com/Rdatatable/data.table/issues
11-
VignetteBuilder: knitr
12+
VignetteBuilder: litedown
1213
Encoding: UTF-8
1314
ByteCompile: TRUE
1415
Authors@R: c(

NAMESPACE

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,10 @@ if (getRversion() >= "4.0.0") {
114114
# version of R (and that is checked in .onLoad with error if not).
115115
export(.rbind.data.table) # only export in R<4.0.0 where it is still used; R-devel now detects it is missing doc, #5600
116116
}
117-
if (getRversion() >= "3.6.0") S3method(knitr::knit_print, data.table) # else manual delayed registration from the onLoad hook
117+
if (getRversion() >= "3.6.0") {
118+
S3method(knitr::knit_print, data.table)
119+
S3method(xfun::record_print, data.table)
120+
} # else manual delayed registration from the onLoad hook
118121
S3method(dim, data.table)
119122
S3method(dimnames, data.table)
120123
S3method("dimnames<-", data.table)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
2. pydatatable compatibility layer in `fread()` and `fwrite()` has been removed, [#7069](https://github.com/Rdatatable/data.table/issues/7069). Thanks @badasahog for the report and the PR.
1212

13+
3. Vignettes are now built using `litedown` instead of `knitr`, [#6394](https://github.com/Rdatatable/data.table/issues/6394). Thanks @jangorecki for the suggestion and @ben-schwen and @aitap for the implementation.
14+
1315
### BUG FIXES
1416

1517
1. `fread()` with `skip=0` and `(header=TRUE|FALSE)` no longer skips the first row when it has fewer fields than subsequent rows, [#7463](https://github.com/Rdatatable/data.table/issues/7463). Thanks @emayerhofer for the report and @ben-schwen for the fix.

R/onLoad.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
setHook(packageEvent("knitr", "onLoad"), function(...) {
6868
registerS3method("knit_print", "data.table", knit_print.data.table, envir = asNamespace("knitr"))
6969
})
70+
if (isNamespaceLoaded("xfun")) {
71+
registerS3method("record_print", "data.table", record_print.data.table, envir = asNamespace("xfun"))
72+
}
73+
setHook(packageEvent("xfun", "onLoad"), function(...) {
74+
registerS3method("record_print", "data.table", record_print.data.table, envir = asNamespace("xfun"))
75+
})
7076
}
7177

7278
# Set options for the speed boost in v1.8.0 by avoiding 'default' arg of getOption(,default=)

R/print.data.table.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,13 @@ trunc_cols_message = function(not_printed, abbs, class, col.names){
294294
}
295295

296296
# Maybe add a method for repr::repr_text. See https://github.com/Rdatatable/data.table/issues/933#issuecomment-220237965
297+
# nocov start
297298
knit_print.data.table = function(x, ...) {
298299
if (!shouldPrint(x)) return(invisible(x))
299300
NextMethod()
300301
}
302+
record_print.data.table = function(x, ...) {
303+
if (!shouldPrint(x)) return(character())
304+
NextMethod()
305+
}
306+
# nocov end

inst/tests/other.Rraw

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,9 @@ if (loaded[["knitr"]]) {
182182
# Which is fine and works thanks to cedta().
183183
DT = data.table(x=1, y=2)
184184
test(11, kable(DT), output="x.*y.*1.*2")
185+
invisible(knit(testDir("knitr.Rmd"), quiet=TRUE))
186+
cat(readLines("knitr.md"), sep="\n")
187+
invisible(file.remove("knitr.md"))
185188
}
186189

187190
if (loaded[["parallel"]]) {

tests/knitr.R

Lines changed: 0 additions & 9 deletions
This file was deleted.

tests/knitr.Rout.save

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)