diff --git a/man/glue-operators.Rd b/man/glue-operators.Rd index 1e9ed4831..95e103c58 100644 --- a/man/glue-operators.Rd +++ b/man/glue-operators.Rd @@ -42,7 +42,8 @@ See also \code{\link[=englue]{englue()}} to string-embrace outside of dynamic do g(1 + 1) #> [1] "var: 1 + 1" }\if{html}{\out{}} - +} +\section{Examples}{ Technically, \verb{"\{\{"} \link[=topic-defuse]{defuses} a function argument, calls \code{\link[=as_label]{as_label()}} on the expression supplied as argument, and inserts the result in the string. \subsection{\verb{"\{"} and \verb{"\{\{"}}{ @@ -152,3 +153,4 @@ Since rlang does not depend directly on glue, you will have to ensure that glue }\if{html}{\out{}} } } + diff --git a/man/rmd/glue-operators.Rmd b/man/rmd/glue-operators.Rmd index 3d6e09b8a..754b37eb5 100644 --- a/man/rmd/glue-operators.Rmd +++ b/man/rmd/glue-operators.Rmd @@ -30,6 +30,8 @@ g <- function(x) { g(1 + 1) ``` +# Examples + Technically, `r text("'{{'")` [defuses][topic-defuse] a function argument, calls [as_label()] on the expression supplied as argument, and inserts the result in the string. diff --git a/man/rmd/topic-condition-formatting.Rmd b/man/rmd/topic-condition-formatting.Rmd index f534ca09a..1ce4f88ce 100644 --- a/man/rmd/topic-condition-formatting.Rmd +++ b/man/rmd/topic-condition-formatting.Rmd @@ -21,7 +21,7 @@ Condition formatting is a set of operations applied to raw inputs for error mess While the rlang package embeds rudimentary formatting routines, the main formatting engine is implemented in the [cli package](https://cli.r-lib.org/). -## Formatting messages with cli +# Formatting messages with cli By default, rlang uses an internal mechanism to format bullets. It is preferable to delegate formatting to the [cli package](https://cli.r-lib.org/) by using [cli::cli_abort()], [cli::cli_warn()], and [cli::cli_inform()] instead of the rlang versions. These wrappers enable cli formatting with sophisticated paragraph wrapping and bullet indenting that make long lines easier to read. In the following example, a long `!` bullet is broken with an indented newline: @@ -53,7 +53,7 @@ inform_marbles(2) ``` -## Transitioning from `abort()` to `cli_abort()` +# Transitioning from `abort()` to `cli_abort()` If you plan to mass-rename calls from `abort()` to `cli::cli_abort()`, be careful if you assemble error messages from user inputs. If these individual pieces contain cli or glue syntax, this will result in hard-to-debug errors and possibly [unexpected behaviour](https://xkcd.com/327/). @@ -70,7 +70,7 @@ cli::cli_abort("Can't handle input {.code {user_input}}.") ``` -## Enabling cli formatting globally +# Enabling cli formatting globally To enable cli formatting for all `abort()` calls in your namespace, call [local_use_cli()] in the `onLoad` hook of your package. Using [on_load()] (make sure to call [run_on_load()] in your hook): diff --git a/man/rmd/topic-defuse.Rmd b/man/rmd/topic-defuse.Rmd index 0556bb92a..8388dd20c 100644 --- a/man/rmd/topic-defuse.Rmd +++ b/man/rmd/topic-defuse.Rmd @@ -5,6 +5,10 @@ When a piece of R code is defused, R doesn't return its value like it normally w Using [expr()] we can observe the difference between computing an expression and defusing it: +Evaluation of a defused expression can be resumed at any time with [eval()] (see also [eval_tidy()]). + +# Example + ```{r, comment = "#>", collapse = TRUE} # Return the result of `1 + 1` 1 + 1 @@ -13,8 +17,6 @@ Using [expr()] we can observe the difference between computing an expression and expr(1 + 1) ``` -Evaluation of a defused expression can be resumed at any time with [eval()] (see also [eval_tidy()]). - ```{r, comment = "#>", collapse = TRUE} # Return the expression `1 + 1` e <- expr(1 + 1) diff --git a/man/rmd/topic-error-chaining.Rmd b/man/rmd/topic-error-chaining.Rmd index 9079e1681..96653e2fe 100644 --- a/man/rmd/topic-error-chaining.Rmd +++ b/man/rmd/topic-error-chaining.Rmd @@ -1,7 +1,9 @@ ```{r, child = "setup.Rmd", include = FALSE} ``` -Error chaining is a mechanism for providing contextual information when an error occurs. There are multiple situations in which you might be able to provide context that is helpful to quickly understand the cause or origin of an error: +Error chaining is a mechanism for providing contextual information when an error occurs. There are multiple situations in which you might be able to provide context that is helpful to quickly understand the cause or origin of an error. + +# Context where chaining is useful - Mentioning the _high level context_ in which a low level error arised. E.g. chaining a low-level HTTP error to a high-level download error. diff --git a/man/topic-condition-formatting.Rd b/man/topic-condition-formatting.Rd index 0fd2e908c..b879a0e9f 100644 --- a/man/topic-condition-formatting.Rd +++ b/man/topic-condition-formatting.Rd @@ -26,8 +26,8 @@ See the \href{https://style.tidyverse.org/error-messages.html}{tidyverse error s } While the rlang package embeds rudimentary formatting routines, the main formatting engine is implemented in the \href{https://cli.r-lib.org/}{cli package}. -\subsection{Formatting messages with cli}{ - +} +\section{Formatting messages with cli}{ By default, rlang uses an internal mechanism to format bullets. It is preferable to delegate formatting to the \href{https://cli.r-lib.org/}{cli package} by using \code{\link[cli:cli_abort]{cli::cli_abort()}}, \code{\link[cli:cli_abort]{cli::cli_warn()}}, and \code{\link[cli:cli_abort]{cli::cli_inform()}} instead of the rlang versions. These wrappers enable cli formatting with sophisticated paragraph wrapping and bullet indenting that make long lines easier to read. In the following example, a long \code{!} bullet is broken with an indented newline: \if{html}{\out{