Skip to content

Commit 8483e29

Browse files
committed
move to using markdown docs
1 parent 88fcfbf commit 8483e29

26 files changed

+135
-147
lines changed

R/commits.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' @param page (integer) Page number to return.
66
#' @param per_page (integer) Number of items to return per page.
77
#' Default 30. Max 100.
8-
#' @param ... Further named args to \code{\link[httr]{GET}}
8+
#' @param ... Further named args to [httr::GET()]
99
#' @examples \dontrun{
1010
#' gists()[[1]] %>% commits()
1111
#' gist(id = '1f399774e9ecc9153a6f') %>% commits(per_page = 5)

R/forks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' @param page (integer) Page number to return.
66
#' @param per_page (integer) Number of items to return per page. Default 30.
77
#' Max 100.
8-
#' @param ... Further named args to \code{\link[httr]{GET}}
8+
#' @param ... Further named args to [httr::GET()]
99
#' @return A list of gist class objects
1010
#' @examples \dontrun{
1111
#' gist(id='1642874') %>% forks(per_page=2)

R/gist.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#' @details If a file is larger than ~1 MB, the content of the file given back
1010
#' is truncated, so you won't get the entire contents. In the return S3 object
1111
#' that's printed, we tell you at the bottom whether each file is truncated or
12-
#' not. If a file is, simply get the \code{raw_url} URL for the file (see
12+
#' not. If a file is, simply get the `raw_url` URL for the file (see
1313
#' example below), then retrieve from that. If the file is very big, you may
1414
#' need to clone the file using git, etc.
1515
#' @examples \dontrun{

R/gist_auth.R

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
#' account.
55
#'
66
#' There are two ways to authorise gistr to work with your GitHub account:
7-
#' \itemize{
8-
#' \item Generate a personal access token at
9-
#' \url{https://help.github.com/articles/creating-an-access-token-for-command-line-use}
10-
#' and record in the \code{GITHUB_PAT} envar.
11-
#' \item Interactively login into your GitHub account and authorise with OAuth.
12-
#' }
7+
#'
8+
#' - Generate a personal access token at
9+
#' <https://help.github.com/articles/creating-an-access-token-for-command-line-use>
10+
#' and record in the `GITHUB_PAT` envar.
11+
#' - Interactively login into your GitHub account and authorise with OAuth.
1312
#'
14-
#' Using \code{GITHUB_PAT} is recommended.
13+
#' Using `GITHUB_PAT` is recommended.
1514
#'
1615
#' @export
17-
#' @param app An \code{\link[httr]{oauth_app}} for GitHub. The default uses an
18-
#' application \code{gistr_oauth} created by Scott Chamberlain.
16+
#' @param app An [httr::oauth_app()] for GitHub. The default uses an
17+
#' application `gistr_oauth` created by Scott Chamberlain.
1918
#' @param reauth (logical) Force re-authorization?
2019
#' @examples \dontrun{
2120
#' gist_auth()

R/gist_create.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
#'
33
#' @export
44
#' @template args
5-
#' @param rmarkdown (logical) If \code{TRUE}, use
6-
#' \code{\link[rmarkdown]{render}} instead of \code{\link[knitr]{knit}} to
7-
#' render the document.
8-
#' @seealso \code{\link{gist_create_obj}}, \code{\link{gist_create_git}}
5+
#' @param rmarkdown (logical) If `TRUE`, use [rmarkdown::render()] instead of
6+
#' [knitr::knit()] to render the document.
7+
#' @seealso [gist_create_obj()], [gist_create_git()]
98
#' @examples \dontrun{
109
#' file <- tempfile()
1110
#' cat("hello world", file = file)

R/gist_create_git.R

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@
44
#'
55
#' @template args
66
#' @param artifacts (logical/character) Include artifacts or not.
7-
#' If \code{TRUE}, includes all artifacts. Or you can pass in a file extension
8-
#' to only upload artifacts of certain file exensions. Default: \code{FALSE}
7+
#' If `TRUE`, includes all artifacts. Or you can pass in a file extension
8+
#' to only upload artifacts of certain file exensions. Default: `FALSE`
99
#' @param git_method (character) One of ssh (default) or https. If a remote
1010
#' already exists, we use that remote, and this parameter is ignored.
1111
#' @param sleep (integer) Seconds to sleep after creating gist, but before
1212
#' collecting metadata on the gist. If uploading a lot of stuff, you may want to
1313
#' set this to a higher value, otherwise, you may not get accurate metadata for
14-
#' your gist. You can of course always refresh afterwards by calling \code{gist}
14+
#' your gist. You can of course always refresh afterwards by calling `gist`
1515
#' with your gist id.
1616
#'
17-
#' @details Note that when \code{browse=TRUE} there is a slight delay in when
17+
#' @details Note that when `browse=TRUE` there is a slight delay in when
1818
#' we open up the gist in your default browser and when the data will display
1919
#' in the gist. We could have this function sleep a while and guess when it
2020
#' will be ready, but instead we open your gist right after we're done sending
@@ -23,32 +23,30 @@
2323
#'
2424
#' Likewise, the object that is returned from this function call may not have
2525
#' the updated and correct file information. You can retrieve that easily by
26-
#' calling \code{\link{gist}} with the gist id.
26+
#' calling [gist()] with the gist id.
2727
#'
2828
#' This function uses git instead of the HTTP API, and thus requires
29-
#' the R package \code{git2r}. If you don't have \code{git2r} installed, and
30-
#' try to use this function, it will stop and tell you to install \code{git2r}.
29+
#' the R package `git2r`. If you don't have `git2r` installed, and
30+
#' try to use this function, it will stop and tell you to install `git2r`.
3131
#'
32-
#' This function using git is better suited than \code{\link{gist_create}}
32+
#' This function using git is better suited than [gist_create()]
3333
#' for use cases involving:
3434
#'
35-
#' \itemize{
36-
#' \item Big files - The GitHub API allows only files of up to 1 MB in size.
35+
#' - Big files - The GitHub API allows only files of up to 1 MB in size.
3736
#' Using git we can get around that limit.
38-
#' \item Binary files - Often artifacts created are binary files like
39-
#' \code{.png}. The GitHub API doesn't allow transport of binary files, but
37+
#' - Binary files - Often artifacts created are binary files like
38+
#' `.png`. The GitHub API doesn't allow transport of binary files, but
4039
#' we can do that with git.
41-
#' }
4240
#'
43-
#' Another difference between this function and \code{\link{gist_create}} is
41+
#' Another difference between this function and [gist_create()] is
4442
#' that this function can collect all artifacts coming out of a knit process.
4543
#'
4644
#' If a gist is somehow deleted, or the remote changes, when you try to push
4745
#' to the same gist again, everything should be fine. We now use
48-
#' \code{tryCatch} on the push attempt, and if it fails, we'll add a new
46+
#' `tryCatch` on the push attempt, and if it fails, we'll add a new
4947
#' remote (which means a new gist), and push again.
5048
#'
51-
#' @seealso \code{\link{gist_create}}, \code{\link{gist_create_obj}}
49+
#' @seealso [gist_create()], [gist_create_obj()]
5250
#'
5351
#' @examples \dontrun{
5452
#' # prepare a directory and a file

R/gist_create_obj.R

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
#'
55
#' @param x An R object, any of data.frame, matrix, list, character, numeric
66
#' @param description (character) Brief description of gist (optional)
7-
#' @param public (logical) Whether gist is public (default: TRUE)
8-
#' @param browse (logical) To open newly create gist in default browser
9-
#' (default: TRUE)
7+
#' @param public (logical) Whether gist is public (default: `TRUE`)
8+
#' @param browse (logical) To open newly create gist in default browser
9+
#' (default: `TRUE`)
1010
#' @param pretty (logical) For data.frame and matrix objects, create
11-
#' a markdown table. If FALSE, pushes up json. (default: TRUE)
12-
#' @param filename Name of the file to create. Default: \code{file.txt}
13-
#' @param ... Further args passed on to \code{link[httr]{POST}}
14-
#' @details This function is specifically for going from R objects to a gist,
15-
#' whereas \code{\link{gist_create}} is for going from files or executing code
16-
#' @seealso \code{\link{gist_create}}, \code{\link{gist_create_git}}
11+
#' a markdown table. If FALSE, pushes up json. (default: `TRUE`)
12+
#' @param filename Name of the file to create. Default: `file.txt`
13+
#' @param ... Further args passed on to [httr::POST()]
14+
#' @details This function is specifically for going from R objects to a gist,
15+
#' whereas [gist_create()] is for going from files or executing code
16+
#' @seealso [gist_create()], [gist_create_git()]
1717
#' @examples \dontrun{
1818
#' ## data.frame
1919
#' ### by default makes pretty table in markdown format
@@ -39,49 +39,49 @@
3939
#' hey there!", filename = "my_markdown.md")
4040
#' }
4141
gist_create_obj <- function(x = NULL, description = "", public = TRUE,
42-
browse = TRUE, pretty = TRUE,
42+
browse = TRUE, pretty = TRUE,
4343
filename = "file.txt", ...) {
4444
UseMethod("gist_create_obj")
4545
}
4646

4747
#' @export
4848
gist_create_obj.data.frame <- function(x = NULL, description = "", public = TRUE,
49-
browse = TRUE, pretty = TRUE,
49+
browse = TRUE, pretty = TRUE,
5050
filename = "file.txt", ...) {
5151
gc_robjs(x, description, public, browse, pretty, filename, ...)
5252
}
5353

5454
#' @export
5555
gist_create_obj.character <- function(x = NULL, description = "", public = TRUE,
56-
browse = TRUE, pretty = TRUE,
56+
browse = TRUE, pretty = TRUE,
5757
filename = "file.txt", ...) {
5858
gc_robjs(x, description, public, browse, pretty, filename, ...)
5959
}
6060

6161
#' @export
6262
gist_create_obj.list <- function(x = NULL, description = "", public = TRUE,
63-
browse = TRUE, pretty = TRUE,
63+
browse = TRUE, pretty = TRUE,
6464
filename = "file.txt", ...) {
6565
gc_robjs(x, description, public, browse, pretty, filename, ...)
6666
}
6767

6868
#' @export
6969
gist_create_obj.matrix <- function(x = NULL, description = "", public = TRUE,
70-
browse = TRUE, pretty = TRUE,
70+
browse = TRUE, pretty = TRUE,
7171
filename = "file.txt", ...) {
7272
gc_robjs(x, description, public, browse, pretty, filename, ...)
7373
}
7474

7575
#' @export
7676
gist_create_obj.numeric <- function(x = NULL, description = "", public = TRUE,
77-
browse = TRUE, pretty = TRUE,
77+
browse = TRUE, pretty = TRUE,
7878
filename = "file.txt", ...) {
7979
gc_robjs(x, description, public, browse, pretty, filename, ...)
8080
}
8181

8282
#' @export
8383
gist_create_obj.json <- function(x = NULL, description = "", public = TRUE,
84-
browse = TRUE, pretty = TRUE,
84+
browse = TRUE, pretty = TRUE,
8585
filename = "file.txt", ...) {
8686
gc_robjs(unclass(x), description, public, browse, pretty, filename, ...)
8787
}

R/gist_map.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#' Takes a gist object and a input geojson file name and renders fullscreen map
44
#'
55
#' @export
6-
#' @param x An object of class \code{gist} generated by
7-
#' \code{\link{gist_create}} or \code{\link{gist_create_obj}}
8-
#' @param browse Default: \code{TRUE}. Set to \code{FALSE} if you don't want to
6+
#' @param x An object of class `gist` generated by
7+
#' [gist_create()] or [gist_create_obj()]
8+
#' @param browse Default: `TRUE`. Set to `FALSE` if you don't want to
99
#' automatically browse to the URL.
1010
#' @examples \dontrun{
1111
#' file <- system.file("examples", "ecoengine_eg.geojson", package = "gistr")

R/gist_save.R

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
#'
33
#' @export
44
#' @param gist A gist object or something coerceable to a gist
5-
#' @param path Root path to write to, a directory, not a file b/c a gist can
6-
#' contain many files. A folder is created with name of the gist id within
5+
#' @param path Root path to write to, a directory, not a file b/c a gist can
6+
#' contain many files. A folder is created with name of the gist id within
77
#' this root directory. File names will be the same as given in the gist.
8-
#' @param x An object of class \code{gist_files} (the output from
9-
#' \code{gist_save})
10-
#' @return An object of class \code{gist_files}, S3 object containing file
8+
#' @param x An object of class `gist_files` (the output from
9+
#' [gist_save()]
10+
#' @return An object of class `gist_files`, S3 object containing file
1111
#' paths
12-
#' @details
13-
#' \code{gist_save}: files are written into a new folder, named by the gist id,
14-
#' e.g., \code{a65ac7e56b7b3f746913}
15-
#'
16-
#' \code{gist_open}: opens files in your editor/R GUI. Internally, uses
17-
#' \code{\link{file.edit}} to open files, using \code{getOption("editor")} to
18-
#' open the files. If you're in R.app or RStudio, or other IDE's, files will
12+
#' @details
13+
#' `gist_save`: files are written into a new folder, named by the gist id,
14+
#' e.g., `a65ac7e56b7b3f746913`
15+
#'
16+
#' `gist_open`: opens files in your editor/R GUI. Internally, uses
17+
#' [file.edit()] to open files, using `getOption("editor")` to
18+
#' open the files. If you're in R.app or RStudio, or other IDE's, files will
1919
#' open in the IDE (I think).
2020
#' @examples \dontrun{
2121
#' gist("a65ac7e56b7b3f746913") %>% gist_save()
2222
#' gist("a65ac7e56b7b3f746913") %>% gist_save() %>% gist_open()
23-
#' gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>%
23+
#' gist("https://gist.github.com/expersso/4ac33b9c00751fddc7f8") %>%
2424
#' gist_save()
2525
#' }
2626

@@ -44,7 +44,7 @@ gist_save <- function(gist, path = ".") {
4444
#' @export
4545
print.gist_files <- function(x, ...) {
4646
cat("<gist> ", attr(x, "id"), "\n", sep = "")
47-
cat(g_wrap(sprintf("Files:\n %s ...", paste0(x, collapse = "\n")),
47+
cat(g_wrap(sprintf("Files:\n %s ...", paste0(x, collapse = "\n")),
4848
indent = 3), "\n\n")
4949
}
5050

@@ -67,6 +67,6 @@ isDir <- function(path) {
6767
file.info(path)$isdir
6868
}
6969

70-
is.string <- function(x) {
70+
is.string <- function(x) {
7171
is.character(x) && length(x) == 1
7272
}

R/gistr-package.R

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
#' R client for GitHub gists.
22
#'
3-
#' gistr allows you to peform actions on gists, including listing, forking,
3+
#' gistr allows you to peform actions on gists, including listing, forking,
44
#' starring, creating, deleting, updating, etc.
55
#'
66
#' There are two ways to authorise gistr to work with your GitHub account:
77
#'
8-
#' \itemize{
9-
#' \item Generate a personal access token (PAT) at
10-
#' \url{https://help.github.com/articles/creating-an-access-token-for-command-line-use}
11-
#' and record it in the \code{GITHUB_PAT} envar.
12-
#' \item Interactively login into your GitHub account and authorise with OAuth.
13-
#' }
8+
#' - Generate a personal access token (PAT) at
9+
#' <https://help.github.com/articles/creating-an-access-token-for-command-line-use>
10+
#' and record it in the `GITHUB_PAT` envar.
11+
#' - Interactively login into your GitHub account and authorise with OAuth.
1412
#'
15-
#' Using the \code{GITHUB_PAT} is recommended.
13+
#' Using the `GITHUB_PAT` is recommended.
1614
#'
1715
#' @importFrom magrittr %>%
1816
#' @importFrom knitr knit
1917
#' @importFrom rmarkdown render
20-
#' @importFrom httr GET POST PATCH PUT DELETE content stop_for_status
18+
#' @importFrom httr GET POST PATCH PUT DELETE content stop_for_status
2119
#' add_headers warn_for_status
2220
#' @importFrom assertthat assert_that has_extension
23-
#' @importFrom dplyr bind_rows as_data_frame
21+
#' @importFrom dplyr bind_rows as_data_frame
2422
#' @importFrom jsonlite flatten
2523
#' @name gistr-package
2624
#' @aliases gistr
@@ -34,30 +32,28 @@ NULL
3432

3533
#' @title Create gists
3634
#'
37-
#' @description Creating gists in \code{gistr} can be done with any of
35+
#' @description Creating gists in `gistr` can be done with any of
3836
#' three functions:
39-
#'
40-
#' \itemize{
41-
#' \item \code{\link{gist_create}} - Create gists from files or code blocks,
42-
#' using the GitHub HTTP API. Because this function uses the GitHub HTTP API,
43-
#' it does not work for binary files. However, you can get around this for
44-
#' images by using knitr's hook to upload images to eg., imgur. In addition,
37+
#'
38+
#' - [gist_create()] - Create gists from files or code blocks,
39+
#' using the GitHub HTTP API. Because this function uses the GitHub HTTP API,
40+
#' it does not work for binary files. However, you can get around this for
41+
#' images by using knitr's hook to upload images to eg., imgur. In addition,
4542
#' it's difficult to include artifacts from the knit-ing process.
46-
#' \item \code{\link{gist_create_git}} - Create gists from files or code
47-
#' blocks, using git. Because this function uses git, you have more
48-
#' flexibility than with the above function: you can include any binary files,
49-
#' and can easily upload all artifacts. \item \code{\link{gist_create_obj}} -
50-
#' Create gists from R objects: data.frame, list,
43+
#' - [gist_create_git()] - Create gists from files or code
44+
#' blocks, using git. Because this function uses git, you have more
45+
#' flexibility than with the above function: you can include any binary files,
46+
#' and can easily upload all artifacts.
47+
#' - [gist_create_obj()] - Create gists from R objects: data.frame, list,
5148
#' character string, matrix, or numeric. Uses the GitHub HTTP API.
52-
#' }
53-
#'
54-
#' It may seem a bit odd to have three separate functions for creating gists.
55-
#' \code{\link{gist_create}} was created first, and was out for a bit, so when
56-
#' we had the idea to create gists via git (\code{\link{gist_create_git}}) and
57-
#' from R objects (\code{\link{gist_create_obj}}), it made sense to have a
58-
#' different API for creating gists via the HTTP API, git, and from R objects.
59-
#' We could have thrown everything into \code{\link{gist_create}}, but it would
60-
#' have been a massive function, with far too many parameters.
49+
#'
50+
#' It may seem a bit odd to have three separate functions for creating gists.
51+
#' [gist_create()] was created first, and was out for a bit, so when
52+
#' we had the idea to create gists via git ([gist_create_git()]) and
53+
#' from R objects ([gist_create_obj()]), it made sense to have a
54+
#' different API for creating gists via the HTTP API, git, and from R objects.
55+
#' We could have thrown everything into [gist_create()], but it would
56+
#' have been a massive function, with far too many parameters.
6157
#'
6258
#' @name create_gists
6359
NULL

0 commit comments

Comments
 (0)