Skip to content

Commit b363be8

Browse files
committed
chore: Add examples
1 parent 1731960 commit b363be8

8 files changed

+50
-0
lines changed

R/btw_this.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ as_btw_capture <- function(x) {
105105
#' Includes the `.Last.value`, i.e. the result of the last expression
106106
#' evaluated in your R console.
107107
#'
108+
#' @examples
109+
#' btw_this("?btw::btw_this")
110+
#'
108111
#' @param x A character string
109112
#' @param ... Ignored.
110113
#' @param caller_env The caller environment.

R/tool-environment.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ btw_this.environment <- function(x, ..., items = NULL) {
2424

2525
#' Tool: Describe an environment
2626
#'
27+
#' @examples
28+
#' my_cars <- mtcars[mtcars$mpg > 25, ]
29+
#' btw_tool_env_describe_environment("my_cars")
30+
#'
2731
#' @param environment An environment to describe.
2832
#' @param ... Ignored.
2933
#' @inheritParams btw_this.environment

R/tool-files.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ NULL
33

44
#' Tool: List files
55
#'
6+
#' @examples
7+
#' withr::with_tempdir({
8+
#' write.csv(mtcars, "mtcars.csv")
9+
#'
10+
#' btw_tool_files_list_files(type = "file")
11+
#' })
12+
#'
613
#' @param path Path to a directory or file for which to get information. The
714
#' `path` must be in the current working directory. If `path` is a directory,
815
#' we use [fs::dir_info()] to list information about files and directories in
@@ -104,6 +111,13 @@ btw_tool_files_list_files <- function(
104111

105112
#' Tool: Read a file
106113
#'
114+
#' @examples
115+
#' withr::with_tempdir({
116+
#' write.csv(mtcars, "mtcars.csv")
117+
#'
118+
#' btw_tool_files_read_text_file("mtcars.csv", max_lines = 5)
119+
#' })
120+
#'
107121
#' @param path Path to a file for which to get information. The `path` must be
108122
#' in the current working directory.
109123
#' @param max_lines Number of lines to include. Defaults to 1,000 lines.

R/tool-rstudioapi.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ NULL
77
#' Reads the current file using the \pkg{rstudioapi}, which works in RStudio,
88
#' Positron and VS Code (with the vscode-r extension).
99
#'
10+
#' @examplesIf rstudioapi::hasFun("getSourceEditorContext")
11+
#' btw_tool_ide_read_current_editor(consent = TRUE)
12+
#'
1013
#' @param selection Should only the selected text be included? If no text is
1114
#' selected, the full file contents are returned.
1215
#' @param consent Boolean indicating whether the user has consented to reading

man/btw_tool_env_describe_environment.Rd

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

man/btw_tool_files_list_files.Rd

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

man/btw_tool_files_read_text_file.Rd

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

man/btw_tool_ide_read_current_editor.Rd

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

0 commit comments

Comments
 (0)