Skip to content
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

Make topic intro shorter #1689

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion man/glue-operators.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions man/rmd/glue-operators.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
6 changes: 3 additions & 3 deletions man/rmd/topic-condition-formatting.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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/).

Expand All @@ -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):

Expand Down
6 changes: 4 additions & 2 deletions man/rmd/topic-defuse.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion man/rmd/topic-error-chaining.Rmd
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 5 additions & 7 deletions man/topic-condition-formatting.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/topic-defuse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/topic-error-call.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/topic-error-chaining.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading