-
Notifications
You must be signed in to change notification settings - Fork 1k
Make litedown vignettes compatible with pkgdown #7402
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
rikivillalba
wants to merge
40
commits into
master
Choose a base branch
from
litedown.pkgdown_compat
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
fedc6ef
add first steps
ben-schwen b1f1adb
add litedown R CMD check occasional
ben-schwen 2fc3ddc
remove knitr::opts_chunk
ben-schwen ac1fb44
set comment char
ben-schwen 905586d
add error option
ben-schwen 1c14712
update comment char
ben-schwen aa7bdad
adjust print
ben-schwen 071078c
remove space
ben-schwen 1f347bd
fix namespace
ben-schwen e1d0c6f
Update vignettes/datatable-benchmarking.Rmd
ben-schwen 4e7809f
use yihuis suggestions
ben-schwen c653cf6
Merge branch 'master' into litedown
ben-schwen 4bacd15
upd translation script and r -> {r} code blocks
rikivillalba a1819e1
Merge branch 'master' into litedown
ben-schwen 5ed155d
move knitr tests
ben-schwen e1329dd
Merge branch 'master' into litedown
ben-schwen e4b7912
Enhances: knitr
aitap 1e191d5
Register xfun::record_print method for data.table
aitap 0cfa02a
Merge branch 'master' into litedown
ben-schwen 58b767d
add nocov
ben-schwen 9759281
add nocov for knitr_print
ben-schwen 9f35906
nocov range
MichaelChirico 9a49b1d
Add missing periods.
aitap 010c238
Fix footnote
aitap d01e83c
Fix remaining `r ...` expressions
aitap d9300ad
Merge branch 'master' into litedown
ben-schwen e32a5db
update joins vignette
ben-schwen a6afc0a
set/unset threads
ben-schwen bae1e3c
sys.date
ben-schwen ea7eec4
add xfun to enhances
ben-schwen cc9bf5d
add litedown mock
ben-schwen de27098
Merge branch 'master' into litedown
ChristianWia 3d62dc3
translation links knitr compatible
rikivillalba 55227bc
code block for automatic translation links
rikivillalba be197d9
change `{r} Sys.date()` by !r Sys.date() in YAML header
rikivillalba 1285908
translation script tweaks
rikivillalba f7c2dbf
Merge branch 'master' into litedown.pkgdown_compat
ben-schwen 72c8217
cleanup merge conflicts
ben-schwen d63ebed
cleanup merge
ben-schwen 74b213a
cleanup translation links
ben-schwen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,39 @@ | ||
| # build a link list of alternative languages (may be character(0)) | ||
| # idea is to look like 'Other languages: en | fr | de' | ||
| .write.translation.links <- function(fmt) { | ||
| url = "https://rdatatable.gitlab.io/data.table/articles" | ||
| path = dirname(litedown::get_context("input")) | ||
| if (basename(path) == "vignettes") { | ||
| lang = "en" | ||
| } else { | ||
| lang = basename(path) | ||
| path = dirname(path) | ||
| } | ||
| translation = dir(path, | ||
| recursive = TRUE, | ||
| pattern = glob2rx(litedown::get_context("input")) | ||
| ) | ||
| transl_lang = ifelse(dirname(translation) == ".", "en", dirname(translation)) | ||
| block = if (!all(transl_lang == lang)) { | ||
| linked_transl = sprintf("[%s](%s)", transl_lang, file.path(url, sub("(?i)\\.Rmd$", ".html", translation))) | ||
| linked_transl[transl_lang == lang] = lang | ||
| sprintf(fmt, paste(linked_transl, collapse = " | ")) | ||
| } else "" | ||
| litedown::raw_text(block) | ||
| .write.translation.links <- function() { | ||
| url = "https://rdatatable.gitlab.io/data.table/articles" | ||
| # this guard is needed because pkgdown::build_article does not use litedown | ||
| # https://github.com/yihui/knitr/issues/926#issuecomment-68503962 | ||
| knitr = isTRUE(getOption('knitr.in.progress')) | ||
| if (knitr) { | ||
| path = knitr::current_input(TRUE) | ||
| i18n_msg = knitr::opts_current$get("i18n_msg") | ||
| } else { | ||
| path = normalizePath(litedown::get_context("input")) | ||
| i18n_msg = litedown::reactor("i18n_msg") | ||
| } | ||
| rmdfile = basename(path) | ||
| rmddir = dirname(path) | ||
| if (basename(rmddir) == "vignettes") { | ||
| lang = "en" | ||
| main_dir = rmddir | ||
| } else { | ||
| lang = basename(rmddir) | ||
| main_dir = dirname(rmddir) # should be "vignettes" | ||
| } | ||
| # search for translated rmd's with same name in subfolders | ||
| translation = dir(main_dir, recursive = TRUE, pattern = glob2rx(rmdfile)) | ||
| transl_lang = dirname(translation) | ||
| transl_lang[transl_lang == "."] = "en" | ||
| if (any(transl_lang != lang)) { | ||
| link_path = file.path(url, sub("(?i)\\.Rmd$", ".html", translation)) | ||
| linked_transl = sprintf("[%s](%s)", transl_lang, link_path) | ||
| linked_transl[transl_lang == lang] = lang | ||
| block = sprintf(i18n_msg, paste(linked_transl, collapse = " | ")) | ||
| } else { | ||
| block = "" | ||
| } | ||
| cat(block) | ||
|
|
||
| } | ||
| .write.translation.links() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
@rikivillalba ? you do not change the date with date: !r Sys.Date()
Same remark applies to the EN vignette.