-
Notifications
You must be signed in to change notification settings - Fork 1k
use litedown for rendering vignettes #6583
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #6583 +/- ##
==========================================
- Coverage 98.77% 98.77% -0.01%
==========================================
Files 81 81
Lines 15215 15213 -2
==========================================
- Hits 15029 15027 -2
Misses 186 186 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This PR is on hold until current GH version of |
Earmark: after #6589, if {knitr} is not in |
NB: After #6618, we'll also want to check this issue whether it should be included, or left as a TODO: yihui/litedown#67 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: After #6618, we'll also want to check this issue whether it should be included, or left as a TODO: yihui/litedown#67
It's safe to use litedown:::.env$input
with the current CRAN version of litedown. The next CRAN release should take place in a few weeks, and you'll be able to use litedown::get_context('input')
.
Co-authored-by: Yihui Xie <xie@yihui.name>
Sorry I meant to push a sub-branch to merge but instead forget to switch and pushed the commit directly. |
@@ -26,9 +26,9 @@ h2 { | |||
} | |||
</style> | |||
|
|||
```{r echo=FALSE, file='_translation_links.R'} | |||
```{r, echo=FALSE, file='_translation_links.R'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i imagine this will later trigger a test for un-named chunks, are names supported in this context?
xfun is fixed on CRAN so we could proceed with this issue, isn't it? @ben-schwen |
Yes. Only blocker, I'm aware of now is that |
Since we register a method for knitr::knit_print, keep it mentioned in the DESCRIPTION.
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.
This can be solved similarly to #6589, except that methods for library(data.table)
library(xfun)
x <- data.table(a = 1)
xfun::record('x[,a:=1]') |> print(browse = FALSE)
# x[,a:=1]
#
# #> a
# #> <num>
# #> 1: 1
#
.S3method(
'record_print', 'data.table',
\(x, ...) if (!shouldPrint(x)) character() else NextMethod()
)
xfun::record('x[,a:=1]') |> print(browse = FALSE)
# x[,a:=1]
#
xfun::record('x[,a:=1][]') |> print(browse = FALSE)
# x[,a:=1][]
#
# #> a
# #> <num>
# #> 1: 1
# Additionally, inline expressions of the form
...and with At some point we'll need to transition the translated vignettes too, right? |
@@ -182,6 +182,9 @@ if (loaded[["knitr"]]) { | |||
# Which is fine and works thanks to cedta(). | |||
DT = data.table(x=1, y=2) | |||
test(11, kable(DT), output="x.*y.*1.*2") | |||
invisible(knit(testDir("knitr.Rmd"), quiet=TRUE)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can delete the Rout.mock, right? IIRC that only exists to mock out when {knitr} is not installed, but other.Rraw should always be run where all the required packages are available, in dev.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may way to migrate this check to litedown
tests/knitr.R
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead replace this with tests/litedown.R?
At a minimum we should add a regression test of the new xfun method in other.Rraw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready to ship after maybe another round of touch-up as commented.
Feel free to mark any of my comments for follow-up.
Great work!
Are there links for rendered versions? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In datatable-intro.Rmd
, by-group j
-expressions that call print()
render like:
DT[, print(.SD), by = ID]
# a b c # <int> <int> <int> # 1: 1 7 13 # 2: 2 8 14 # 3: 3 9 15 # a b c # <int> <int> <int> # 1: 4 10 16 # 2: 5 11 17 # a b c # <int> <int> <int> # 1: 6 12 18
ID
I wonder where is the last ID
coming from.
I couldn't make the
`some text `r expression(...)``
syntax work in Litedown and wrote a replacement function for datatable-intro.Rmd
.
In datatable-reference-semantics.Rmd
, the CSS class syntax #### {.bs-callout .bs-callout-info}
does not work; it produces a level-4 heading titled {.bs-callout .bs-callout-info}
instead.
NB: please |
Unfortunately, |
Per the {litedown} README, {litedown} itself is supposed to do the site rendering, right? Otherwise, we should ask the {pkgdown} maintainers to support {litedown} rendering; IINM, the issue is that {pkgdown} relies on {rmarkdown} to render: https://github.com/r-lib/pkgdown/blob/824ab4a4f20ecd895282b434d8652120e1f62ba4/R/build-article.R#L294 |
It does support basic website. pkgdown could support it anyway, but not sure if and how fast that will happen. |
comparing the results of html vignette generation with knitr and litedown on "data-table-joins.Rmd" : knitr/litedown diff screenshot section 7.2: litedown resulting file to follow the comments: My Windows environment : R version 4.0.2 (2020-06-22) -- "Taking Off Again" installation from CRAN source packages : ‘commonmark’, ‘xfun’, ‘litedown’ URL 'https://pbil.univ-lyon1.fr/CRAN/src/contrib/commonmark_2.0.0.tar.gz' |
This may be as well interesting for @yihui |
Closes #6394
Towards #6584