Skip to content

Commit

Permalink
Documentation improvements (#633)
Browse files Browse the repository at this point in the history
* Fix `is_online()` exports
* Improve `req_url()` docs
  • Loading branch information
hadley authored Jan 7, 2025
1 parent 2659643 commit 015c492
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 32 deletions.
1 change: 1 addition & 0 deletions R/is-online.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#' exported from httr2 for convenience.
#'
#' @export
#' @examples
#' is_online()
is_online <- function() {
curl::has_internet()
Expand Down
39 changes: 23 additions & 16 deletions R/req-url.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
#' Modify request URL
#'
#' @description
#' * `req_url()` replaces the entire url
#' * `req_url_query()` modifies the components of the query
#' * `req_url_path()` modifies the path
#' * `req_url_path_append()` adds to the path
#'
#' Alternatively, to modify only a URL without creating a request,
#' you can instead use [url_modify()] and friends.
#' * `req_url()` replaces the entire URL.
#' * `req_url_relative()` navigates to a relative URL.
#' * `req_url_query()` modifies individual query components.
#' * `req_url_path()` modifies just the path.
#' * `req_url_path_append()` adds to the path.
#'
#' @seealso
#' * To modify a URL without creating a request, see [url_modify()] and
#' friends.
#' * To use a template like `GET /user/{user}`, see [req_template()].
#' @inheritParams req_perform
#' @param url New URL; completely replaces existing.
#' @param url A new URL; either an absolute URL for `req_url()` or a
#' relative URL for `req_url_relative()`.
#' @param ... For `req_url_query()`: <[`dynamic-dots`][rlang::dyn-dots]>
#' Name-value pairs that define query parameters. Each value must be either
#' an atomic vector or `NULL` (which removes the corresponding parameters).
Expand All @@ -21,7 +24,14 @@
#' @returns A modified HTTP [request].
#' @export
#' @examples
#' # Change complete url
#' req <- request("http://example.com")
#' req |> req_url("http://google.com")
#'
#' # Use a relative url
#' req <- request("http://example.com/a/b/c")
#' req |> req_url_relative("..")
#' req |> req_url_relative("/d/e/f")
#'
#' # Change url components
#' req |>
Expand All @@ -30,14 +40,11 @@
#' req_url_path_append("search.html") |>
#' req_url_query(q = "the cool ice")
#'
#' # Change complete url
#' req |>
#' req_url("http://google.com")
#'
#' # Use a relative url
#' req <- request("http://example.com/a/b/c")
#' req |> req_url_relative("..")
#' req |> req_url_relative("/d/e/f")
#' # Modify individual query parameters
#' req <- request("http://example.com?a=1&b=2")
#' req |> req_url_query(a = 10)
#' req |> req_url_query(a = NULL)
#' req |> req_url_query(c = 3)
#'
#' # Use .multi to control what happens with vector parameters:
#' req |> req_url_query(id = 100:105, .multi = "comma")
Expand Down
3 changes: 3 additions & 0 deletions man/is_online.Rd

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

42 changes: 26 additions & 16 deletions man/req_url.Rd

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

0 comments on commit 015c492

Please sign in to comment.