Skip to content

Commit

Permalink
Use roxygenlabs for examplesIf
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Jan 13, 2020
1 parent d10356d commit 528380a
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 35 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ Imports:
jsonlite,
httr
RoxygenNote: 7.0.2.9000
Roxygen: list(markdown = TRUE)
Roxygen: { loadNamespace("roxygenlabs"); list(markdown = TRUE) }
Encoding: UTF-8
6 changes: 3 additions & 3 deletions R/gh_whoami.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@
#' @return A `gh_response` object, which is also a `list`.
#' @export
#'
#' @examples
#' \dontrun{
#' @examplesIf identical(Sys.getenv("IN_PKGDOWN"), "true")
#' gh_whoami()
#'
#' @examplesIf FALSE
#' ## explicit token + use with GitHub Enterprise
#' gh_whoami(.token = "8c70fd8419398999c9ac5bacf3192882193cadf2",
#' .api_url = "https://github.foobar.edu/api/v3")
#' }

gh_whoami <- function(.token = NULL, .api_url = NULL, .send_headers = NULL) {
.token <- .token %||% gh_token()
if (isTRUE(.token == "")) {
Expand Down
5 changes: 2 additions & 3 deletions R/git.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
#' @return If the repo has a github remote, a list containing `username`
#' and `repo`. Otherwise, an error.
#' @export
#' @examples
#' \dontrun{
#' @examplesIf interactive()
#' gh_tree_remote()
#' }

gh_tree_remote <- function(path = ".") {
github_remote(git_remotes(path))
}
Expand Down
12 changes: 7 additions & 5 deletions R/package.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
#' @importFrom utils URLencode capture.output
#' @export
#' @seealso [gh_whoami()] for details on GitHub API token management.
#' @examples
#' \dontrun{
#' @examplesIf identical(Sys.getenv("IN_PKGDOWN"), "true")
#' ## Repositories of a user, these are equivalent
#' gh("/users/hadley/repos")
#' gh("/users/:username/repos", username = "hadley")
Expand All @@ -81,10 +80,12 @@
#' gh("/users/hadley/starred")
#' gh("/users/:username/starred", username = "hadley")
#'
#' @examplesIf FALSE
#' ## Create a repository, needs a token in GITHUB_PAT (or GITHUB_TOKEN)
#' ## environment variable
#' gh("POST /user/repos", name = "foobar")
#'
#' @examplesIf identical(Sys.getenv("IN_PKGDOWN"), "true")
#' ## Issues of a repository
#' gh("/repos/hadley/dplyr/issues")
#' gh("/repos/:owner/:repo/issues", owner = "hadley", repo = "dplyr")
Expand All @@ -93,22 +94,23 @@
#' users <- gh("/users", .limit = 50)
#' length(users)
#'
#' @examplesIf FALSE
#' ## Access developer preview of Licenses API (in preview as of 2015-09-24)
#' gh("/licenses") # error code 415
#' gh("/licenses") # used to error code 415
#' gh("/licenses",
#' .send_headers = c("Accept" = "application/vnd.github.drax-preview+json"))
#'
#' @examplesIf FALSE
#' ## Access Github Enterprise API
#' ## Use GITHUB_API_URL environment variable to change the default.
#' gh("/user/repos", type = "public", .api_url = "https://github.foobar.edu/api/v3")
#'
#' @examplesIf FALSE
#' ## Use I() to force body part to be sent as an array, even if length 1
#' ## This works whether assignees has length 1 or > 1
#' assignees <- "gh_user"
#' assignees <- c("gh_user1", "gh_user2")
#' gh("PATCH /repos/OWNER/REPO/issues/1", assignees = I(assignees))
#' }
#'

gh <- function(endpoint, ..., per_page = NULL, .token = NULL, .destfile = NULL,
.overwrite = FALSE, .api_url = NULL, .method = "GET",
Expand Down
8 changes: 3 additions & 5 deletions R/pagination.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@ gh_link <- function(gh_response, link) {
#'
#' @name gh_next
#' @export
#' @examples
#' \dontrun{
#' @examplesIf identical(Sys.getenv("IN_PKGDOWN"), "true")
#' x <- gh("/users")
#' sapply(x, "[[", "login")
#' vapply(x, "[[", character(1), "login")
#' x2 <- gh_next(x)
#' sapply(x2, "[[", "login")
#' }
#' vapply(x2, "[[", character(1), "login")

gh_next <- function(gh_response) gh_link(gh_response, "next")

Expand Down
22 changes: 13 additions & 9 deletions man/gh.Rd

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

8 changes: 4 additions & 4 deletions man/gh_next.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/gh_tree_remote.Rd

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

7 changes: 4 additions & 3 deletions man/gh_whoami.Rd

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

0 comments on commit 528380a

Please sign in to comment.