Skip to content

Commit e637b1e

Browse files
committed
use Markdown in roxygen comments so \link{} targets can be automatically generated
1 parent 0f942ca commit e637b1e

File tree

8 files changed

+162
-180
lines changed

8 files changed

+162
-180
lines changed

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: xaringan
22
Type: Package
33
Title: Presentation Ninja
4-
Version: 0.30.1
4+
Version: 0.30.2
55
Authors@R: c(
66
person("Yihui", "Xie", role = c("aut", "cre"), email = "xie@yihui.name", comment = c(ORCID = "0000-0003-0645-5666")),
77
person(given = "Posit Software, PBC", role = c("cph", "fnd")),
@@ -55,4 +55,5 @@ URL: https://github.com/yihui/xaringan
5555
BugReports: https://github.com/yihui/xaringan/issues
5656
VignetteBuilder: knitr
5757
Encoding: UTF-8
58-
RoxygenNote: 7.3.1
58+
RoxygenNote: 7.3.2
59+
Roxygen: list(markdown = TRUE)

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# CHANGES IN xaringan VERSION 0.31
22

3+
- Switched to Markdown for roxygen comments (addressing the `\link{}` target issue that CRAN reported).
34

45
# CHANGES IN xaringan VERSION 0.30
56

R/render.R

Lines changed: 82 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,89 @@
11
#' An R Markdown output format for remark.js slides
22
#'
33
#' This output format produces an HTML file that contains the Markdown source
4-
#' (knitted from R Markdown) and JavaScript code to render slides.
5-
#' \code{tsukuyomi()} is an alias of \code{moon_reader()}.
4+
#' (knitted from R Markdown) and JavaScript code to render slides. `tsukuyomi()`
5+
#' is an alias of `moon_reader()`.
66
#'
77
#' Tsukuyomi is a genjutsu to trap the target in an illusion on eye contact.
88
#'
9-
#' If you are unfamiliar with CSS, please see the
10-
#' \href{https://github.com/yihui/xaringan/wiki}{xaringan wiki on Github}
11-
#' providing CSS slide modification examples.
9+
#' If you are unfamiliar with CSS, please see the [xaringan wiki on
10+
#' Github](https://github.com/yihui/xaringan/wiki) providing CSS slide
11+
#' modification examples.
1212
#' @param css A vector of CSS file paths. Two default CSS files
1313
#' (\file{default.css} and \file{default-fonts.css}) are provided in this
14-
#' package, which was borrowed from \url{https://remarkjs.com}. If the
15-
#' character vector \code{css} contains a value that does not end with
16-
#' \code{.css}, it is supposed to be a built-in CSS file in this package,
17-
#' e.g., for \code{css = c('default', 'extra.css')}), it means
18-
#' \code{default.css} in this package and a user-provided \code{extra.css}. To
19-
#' find out all built-in CSS files, use \code{xaringan:::list_css()}. With
20-
#' \pkg{rmarkdown} >= 2.8, Sass files (filenames ending with \file{.scss} or
21-
#' \file{.sass}) can also be used, and they will be processed by the
22-
#' \pkg{sass} package, which needs to be installed.
14+
#' package, which was borrowed from <https://remarkjs.com>. If the character
15+
#' vector `css` contains a value that does not end with `.css`, it is supposed
16+
#' to be a built-in CSS file in this package, e.g., for `css = c('default',
17+
#' 'extra.css')`), it means `default.css` in this package and a user-provided
18+
#' `extra.css`. To find out all built-in CSS files, use
19+
#' `xaringan:::list_css()`. With \pkg{rmarkdown} >= 2.8, Sass files (filenames
20+
#' ending with \file{.scss} or \file{.sass}) can also be used, and they will
21+
#' be processed by the \pkg{sass} package, which needs to be installed.
2322
#' @param self_contained Whether to produce a self-contained HTML file by
2423
#' embedding all external resources into the HTML file. See the \sQuote{Note}
2524
#' section below.
2625
#' @param seal Whether to generate a title slide automatically using the YAML
27-
#' metadata of the R Markdown document (if \code{FALSE}, you should write the
28-
#' title slide by yourself).
29-
#' @param yolo Whether to insert the
30-
#' \href{https://kbroman.wordpress.com/2014/08/28/the-mustache-photo/}{Mustache
31-
#' Karl (TM)} randomly in the slides. \code{TRUE} means insert his picture on
32-
#' one slide, and if you want him to be on multiple slides, set \code{yolo} to
33-
#' a positive integer or a percentage (e.g. 0.3 means 30\% of your slides will
34-
#' be the Mustache Karl). Alternatively, \code{yolo} can also be a list of the
35-
#' form \code{list(times = n, img = path)}: \code{n} is the number of times to
36-
#' show an image, and \code{path} is the path to an image (by default, it is
37-
#' Karl).
26+
#' metadata of the R Markdown document (if `FALSE`, you should write the title
27+
#' slide by yourself).
28+
#' @param yolo Whether to insert the [Mustache Karl
29+
#' (TM)](https://kbroman.wordpress.com/2014/08/28/the-mustache-photo/)
30+
#' randomly in the slides. `TRUE` means insert his picture on one slide, and
31+
#' if you want him to be on multiple slides, set `yolo` to a positive integer
32+
#' or a percentage (e.g. 0.3 means 30\% of your slides will be the Mustache
33+
#' Karl). Alternatively, `yolo` can also be a list of the form `list(times =
34+
#' n, img = path)`: `n` is the number of times to show an image, and `path` is
35+
#' the path to an image (by default, it is Karl).
3836
#' @param chakra A path to the remark.js library (can be either local or
3937
#' remote). Please note that if you use the default remote latest version of
4038
#' remark.js, your slides will not work when you do not have Internet access.
4139
#' They might also be broken after a newer version of remark.js is released.
4240
#' If these issues concern you, you should download remark.js locally (e.g.,
43-
#' via \code{\link{summon_remark}()}), and use the local version instead.
41+
#' via [summon_remark()]), and use the local version instead.
4442
#' @param nature (Nature transformation) A list of configurations to be passed
45-
#' to \code{remark.create()}, e.g. \code{list(ratio = '16:9', navigation =
46-
#' list(click = TRUE))}; see
47-
#' \url{https://github.com/gnab/remark/wiki/Configuration}. Besides the
48-
#' options provided by remark.js, you can also set \code{autoplay} to a number
49-
#' (the number of milliseconds) so the slides will be played every
50-
#' \code{autoplay} milliseconds; alternatively, \code{autoplay} can be a list
51-
#' of the form \code{list(interval = N, loop = TRUE)}, so the slides will go
52-
#' to the next page every \code{N} milliseconds, and optionally go back to the
53-
#' first page to restart the play when \code{loop = TRUE}. You can also set
54-
#' \code{countdown} to a number (the number of milliseconds) to include a
55-
#' countdown timer on each slide. If using \code{autoplay}, you can optionally
56-
#' set \code{countdown} to \code{TRUE} to include a countdown equal to
57-
#' \code{autoplay}. To alter the set of classes applied to the title slide,
58-
#' you can optionally set \code{titleSlideClass} to a vector of classes; the
59-
#' default is \code{c("center", "middle", "inverse")}.
60-
#' @param anchor_sections,... For \code{tsukuyomi()}, arguments passed to
61-
#' \code{moon_reader()}; for \code{moon_reader()}, arguments passed to
62-
#' \code{rmarkdown::\link{html_document}()}.
43+
#' to `remark.create()`, e.g. `list(ratio = '16:9', navigation = list(click =
44+
#' TRUE))`; see <https://github.com/gnab/remark/wiki/Configuration>. Besides
45+
#' the options provided by remark.js, you can also set `autoplay` to a number
46+
#' (the number of milliseconds) so the slides will be played every `autoplay`
47+
#' milliseconds; alternatively, `autoplay` can be a list of the form
48+
#' `list(interval = N, loop = TRUE)`, so the slides will go to the next page
49+
#' every `N` milliseconds, and optionally go back to the first page to restart
50+
#' the play when `loop = TRUE`. You can also set `countdown` to a number (the
51+
#' number of milliseconds) to include a countdown timer on each slide. If
52+
#' using `autoplay`, you can optionally set `countdown` to `TRUE` to include a
53+
#' countdown equal to `autoplay`. To alter the set of classes applied to the
54+
#' title slide, you can optionally set `titleSlideClass` to a vector of
55+
#' classes; the default is `c("center", "middle", "inverse")`.
56+
#' @param anchor_sections,... For `tsukuyomi()`, arguments passed to
57+
#' `moon_reader()`; for `moon_reader()`, arguments passed to
58+
#' [rmarkdown::html_document()].
6359
#' @note Do not stare at Karl's picture for too long after you turn on the
64-
#' \code{yolo} mode. I believe he has Sharingan.
60+
#' `yolo` mode. I believe he has Sharingan.
6561
#'
66-
#' For the option \code{self_contained = TRUE}, it encodes images as base64
67-
#' data in the HTML output file. The image path should not contain the string
68-
#' \code{")"} when the image is written with the syntax \verb{![](PATH)} or
69-
#' \verb{background-image: url(PATH)}, and should not contain the string
70-
#' \code{"/>"} when it is written with the syntax \verb{<img src="PATH" />}.
71-
#' Rendering slides in the self-contained mode can be time-consuming when you
72-
#' have remote resources (such as images or JS libraries) in your slides
73-
#' because these resources need to be downloaded first. We strongly recommend
74-
#' that you download remark.js (via \code{\link{summon_remark}()}) and use a
75-
#' local copy instead of the default \code{chakra} argument when
76-
#' \code{self_contained = TRUE}, so remark.js does not need to be downloaded
77-
#' each time you compile your slides.
62+
#' For the option `self_contained = TRUE`, it encodes images as base64 data in
63+
#' the HTML output file. The image path should not contain the string `")"`
64+
#' when the image is written with the syntax `![](PATH)` or `background-image:
65+
#' url(PATH)`, and should not contain the string `"/>"` when it is written
66+
#' with the syntax `<img src="PATH" />`. Rendering slides in the
67+
#' self-contained mode can be time-consuming when you have remote resources
68+
#' (such as images or JS libraries) in your slides because these resources
69+
#' need to be downloaded first. We strongly recommend that you download
70+
#' remark.js (via [summon_remark()]) and use a local copy instead of the
71+
#' default `chakra` argument when `self_contained = TRUE`, so remark.js does
72+
#' not need to be downloaded each time you compile your slides.
7873
#'
79-
#' When the slides are previewed via \code{xaringan::\link{inf_mr}()},
80-
#' \code{self_contained} will be temporarily changed to \code{FALSE} even if
81-
#' the author of the slides set it to \code{TRUE}. This will make it faster to
82-
#' preview slides locally (by avoiding downloading remote resources explicitly
83-
#' and base64 encoding them). You can always click the Knit button in RStudio
84-
#' or call \code{rmarkdown::render()} to render the slides in the
85-
#' self-contained mode (these approaches will respect the
86-
#' \code{self_contained} setting).
74+
#' When the slides are previewed via [xaringan::inf_mr()], `self_contained`
75+
#' will be temporarily changed to `FALSE` even if the author of the slides set
76+
#' it to `TRUE`. This will make it faster to preview slides locally (by
77+
#' avoiding downloading remote resources explicitly and base64 encoding them).
78+
#' You can always click the Knit button in RStudio or call
79+
#' `rmarkdown::render()` to render the slides in the self-contained mode
80+
#' (these approaches will respect the `self_contained` setting).
8781
#'
88-
#' Each page has its own countdown timer (when the option \code{countdown} is
89-
#' set in \code{nature}), and the timer is (re)initialized whenever you
90-
#' navigate to a new page. If you need a global timer, you can use the
91-
#' presenter's mode (press \kbd{P}).
92-
#' @references \url{https://naruto.fandom.com/wiki/Tsukuyomi}
82+
#' Each page has its own countdown timer (when the option `countdown` is set
83+
#' in `nature`), and the timer is (re)initialized whenever you navigate to a
84+
#' new page. If you need a global timer, you can use the presenter's mode
85+
#' (press \kbd{P}).
86+
#' @references <https://naruto.fandom.com/wiki/Tsukuyomi>
9387
#' @importFrom htmltools tagList tags htmlEscape HTML
9488
#' @export
9589
#' @examples
@@ -257,23 +251,23 @@ tsukuyomi = function(...) moon_reader(...)
257251
#' Serve and live reload slides
258252
#'
259253
#' Use the \pkg{servr} package to serve and reload slides on change.
260-
#' \code{inf_mr()} and \code{mugen_tsukuyomi()} are aliases of
261-
#' \code{infinite_moon_reader()}.
254+
#' `inf_mr()` and `mugen_tsukuyomi()` are aliases of
255+
#' `infinite_moon_reader()`.
262256
#'
263257
#' The Rmd document is compiled continuously to trap the world in the Infinite
264258
#' Tsukuyomi. The genjutsu is cast from the directory specified by
265-
#' \code{cast_from}, and the Rinne Sharingan will be reflected off of the
266-
#' \code{moon}. Use \code{servr::daemon_stop()} to perform a genjutsu Kai and
259+
#' `cast_from`, and the Rinne Sharingan will be reflected off of the
260+
#' `moon`. Use `servr::daemon_stop()` to perform a genjutsu Kai and
267261
#' break the spell.
268262
#' @param moon The input Rmd file path (if missing and in RStudio, the current
269263
#' active document is used).
270264
#' @param cast_from The root directory of the server.
271-
#' @param ... Passed to \code{rmarkdown::\link[rmarkdown]{render}()}.
272-
#' @references \url{https://naruto.fandom.com/wiki/Infinite_Tsukuyomi}
265+
#' @param ... Passed to [rmarkdown::render()].
266+
#' @references <https://naruto.fandom.com/wiki/Infinite_Tsukuyomi>
273267
#' @note This function is not really tied to the output format
274-
#' \code{\link{moon_reader}()}. You can use it to serve any single-HTML-file R
268+
#' [moon_reader()]. You can use it to serve any single-HTML-file R
275269
#' Markdown output.
276-
#' @seealso \code{servr::\link{httw}}
270+
#' @seealso [servr::httw()]
277271
#' @export
278272
#' @rdname inf_mr
279273
infinite_moon_reader = function(moon, cast_from = '.', ...) {
@@ -383,24 +377,24 @@ mugen_tsukuyomi = infinite_moon_reader
383377
#' This function can use either the \command{decktape} command or the hosted
384378
#' docker image of the \pkg{decktape} library to convert HTML slides to PDF
385379
#' (including slides produced by \pkg{xaringan}).
386-
#' @param file The path to the HTML presentation file. When \code{docker =
387-
#' FALSE}, this path could be a URL to online slides.
380+
#' @param file The path to the HTML presentation file. When `docker = FALSE`,
381+
#' this path could be a URL to online slides.
388382
#' @param output The desired output path of the PDF file.
389-
#' @param args Command-line arguments to be passed to \code{decktape}.
390-
#' @param docker Whether to use Docker (\code{TRUE}) or use the
391-
#' \command{decktape} command directly (\code{FALSE}). By default, if
392-
#' \pkg{decktape} has been installed in your system and can be found via
393-
#' \code{Sys.which('decktape')}, it will be uesd directly.
383+
#' @param args Command-line arguments to be passed to `decktape`.
384+
#' @param docker Whether to use Docker (`TRUE`) or use the \command{decktape}
385+
#' command directly (`FALSE`). By default, if \pkg{decktape} has been
386+
#' installed in your system and can be found via `Sys.which('decktape')`, it
387+
#' will be uesd directly.
394388
#' @param version The \pkg{decktape} version when you use Docker.
395389
#' @param open Whether to open the resulting PDF with your system PDF viewer.
396390
#' @note For some operating systems you may need to
397391
#' \href{https://stackoverflow.com/questions/48957195}{add yourself to the
398392
#' \command{docker} group} and restart your machine if you use DeckTape via
399393
#' Docker. By default, the latest version of the \pkg{decktape} Docker image
400394
#' is used. In case of errors, you may want to try older versions (e.g.,
401-
#' \code{version = '2.8.0'}).
402-
#' @references DeckTape: \url{https://github.com/astefanutti/decktape}. Docker:
403-
#' \url{https://www.docker.com}.
395+
#' `version = '2.8.0'`).
396+
#' @references DeckTape: <https://github.com/astefanutti/decktape>. Docker:
397+
#' <https://www.docker.com>.
404398
#' @return The output file path (invisibly).
405399
#' @export
406400
#' @examplesIf interactive()

R/utils.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,9 @@ sample2 = function(x, size, ...) {
7474
#' Summon remark.js to your local disk
7575
#'
7676
#' Download a version of the remark.js script to your local disk, so you can
77-
#' render slides offline. You need to change the \code{chakra} argument of
78-
#' \code{\link{moon_reader}()} after downloading remark.js.
79-
#' @param version The version of remark.js (e.g. \code{latest}, \code{0.13}, or
80-
#' \code{0.14.1}).
77+
#' render slides offline. You need to change the `chakra` argument of
78+
#' [moon_reader()] after downloading remark.js.
79+
#' @param version The version of remark.js (e.g. `latest`, `0.13`, or `0.14.1`).
8180
#' @param to The destination directory.
8281
#' @export
8382
summon_remark = function(version = 'latest', to = 'libs/') {

man/decktape.Rd

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/inf_mr.Rd

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)