Skip to content

Commit fa9d649

Browse files
committed
change vignette setup for make cmd to render prebuilt vignette; update some man files
1 parent 228a251 commit fa9d649

18 files changed

+310
-1529
lines changed

CODE_OF_CONDUCT.md

Lines changed: 0 additions & 25 deletions
This file was deleted.

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Description: Work with 'GitHub' 'gists' from 'R' (e.g.,
1010
'gist' 'commits', and get rate limit information when 'authenticated'. Some
1111
requests require authentication and some do not. 'Gists' website:
1212
<https://gist.github.com/>.
13-
Version: 0.5.1.91
13+
Version: 0.5.2.91
1414
Authors@R: c(
1515
person("Scott", "Chamberlain", role = c("aut", "cre"),
1616
email = "[email protected]",

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
PACKAGE := $(shell grep '^Package:' DESCRIPTION | sed -E 's/^Package:[[:space:]]+//')
22
RSCRIPT = Rscript --no-init-file
33

4-
move:
5-
cp inst/vign/gistr.md vignettes/
6-
cp -rf inst/vign/img/* vignettes/img/
7-
8-
rmd2md:
4+
vign:
95
cd vignettes;\
10-
mv gistr.md gistr.Rmd
6+
${RSCRIPT} -e "Sys.setenv(NOT_CRAN='true'); knitr::knit('gistr.Rmd.og', output = 'gistr.Rmd')";\
7+
cd ..
118

129
install: doc build
1310
R CMD INSTALL . && rm *.tar.gz
@@ -29,3 +26,6 @@ check: build
2926
test:
3027
${RSCRIPT} -e 'devtools::test()'
3128

29+
readme:
30+
${RSCRIPT} -e 'knitr::knit("README.Rmd")'
31+

README.Rmd

Lines changed: 3 additions & 295 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,11 @@ knitr::opts_chunk$set(
2121

2222
## See also:
2323

24-
* [rgithub](https://github.com/cscheid/rgithub) an R client for the Github API by Carlos Scheidegger
2524
* [git2r](https://github.com/ropensci/git2r) an R client for the libgit2 C library by Stefan Widgren
2625
* [gert](https://github.com/r-lib/gert) Simple git client for R by Jeroen Ooms
2726
* [gistfo](https://github.com/MilesMcBain/gistfo) for turning your untitled RStudio tabs into gists!
2827

29-
## Quick start
30-
31-
### Install
28+
## Install
3229

3330
Stable version from CRAN
3431

@@ -39,307 +36,18 @@ install.packages("gistr")
3936
Or dev version from GitHub.
4037

4138
```{r eval=FALSE}
42-
devtools::install_github("ropensci/gistr")
39+
remotes::install_github("ropensci/gistr")
4340
```
4441

4542
```{r}
4643
library("gistr")
4744
```
4845

49-
### Authentication
50-
51-
There are two ways to authorise gistr to work with your GitHub account:
52-
53-
* Generate a personal access token (PAT) **with the gist scope selected** at [https://help.github.com/articles/creating-an-access-token-for-command-line-use](https://help.github.com/articles/creating-an-access-token-for-command-line-use) and record it in the `GITHUB_PAT` environment variable.
54-
- To test out this approach, execute this in R: `Sys.setenv(GITHUB_PAT = "blahblahblah")`, where "blahblahblah" is the PAT you got from GitHub. Then take `gistr` out for a test drive.
55-
- If that works, you will probably want to define the GITHUB_PAT environment variable in a file such as `~/.bash_profile` or `~/.Renviron`.
56-
* Interactively login into your GitHub account and authorise with OAuth.
57-
58-
Using the PAT is recommended.
59-
60-
Using the `gist_auth()` function you can authenticate separately first, or if you're not authenticated, this function will run internally with each function call. If you have a PAT, that will be used, if not, OAuth will be used.
61-
62-
```{r eval=FALSE}
63-
gist_auth()
64-
```
65-
66-
### Workflow
67-
68-
In `gistr` you can use pipes, introduced perhaps first in R in the package `magrittr`, to pass outputs from one function to another. If you have used `dplyr` with pipes you can see the difference, and perhaps the utility, of this workflow over the traditional workflow in R. You can use a non-piping or a piping workflow with `gistr`. Examples below use a mix of both workflows. Here is an example of a piping workflow (with some explanation):
69-
70-
```{r eval=FALSE}
71-
file <- system.file("examples", "alm.md", package = "gistr")
72-
gists(what = "minepublic")[[1]] %>% # List my public gists, and index to get just the 1st one
73-
add_files(file) %>% # Add a new file to that gist
74-
update() # update sends a PATCH command to the Gists API to add the file to your gist online
75-
```
76-
77-
And a non-piping workflow that does the same exact thing:
78-
79-
```{r eval=FALSE}
80-
file <- system.file("examples", "alm.md", package = "gistr")
81-
g <- gists(what = "minepublic")[[1]]
82-
g <- add_files(g, file)
83-
update(g)
84-
```
85-
86-
Or you could string them all together in one line (but it's rather difficult to follow what's going on because you have to read from the inside out)
87-
88-
```{r eval=FALSE}
89-
file <- system.file("examples", "alm.md", package = "gistr")
90-
update(add_files(gists(what = "minepublic")[[1]], file))
91-
```
92-
93-
### Rate limit information
94-
95-
```{r}
96-
rate_limit()
97-
```
98-
99-
### List gists
100-
101-
Limiting to a few results here to keep it brief
102-
103-
```{r}
104-
gists(per_page = 2)
105-
```
106-
107-
Since a certain date/time
108-
109-
```{r}
110-
gists(since='2014-05-26T00:00:00Z', per_page = 2)
111-
```
112-
113-
Request different types of gists, one of public, minepublic, mineall, or starred.
114-
115-
```{r}
116-
gists('minepublic', per_page = 2)
117-
```
118-
119-
120-
### List a single commit
121-
122-
```{r}
123-
gist(id = 'f1403260eb92f5dfa7e1')
124-
```
125-
126-
### Create gist
127-
128-
You can pass in files
129-
130-
```{r}
131-
file <- system.file("examples", "stuff.md", package = "gistr")
132-
gist_create(file, description='a new cool gist', browse = FALSE)
133-
```
134-
135-
Or, wrap `gist_create()` around some code in your R session/IDE, with just the function name, and a `{'` at the start and a `}'` at the end.
136-
137-
```{r eval=FALSE}
138-
gist_create(code={'
139-
x <- letters
140-
numbers <- runif(8)
141-
numbers
142-
143-
[1] 0.3229318 0.5933054 0.7778408 0.3898947 0.1309717 0.7501378 0.3206379 0.3379005
144-
'})
145-
```
146-
147-
```{r}
148-
gist_create(code={'
149-
x <- letters
150-
numbers <- runif(8)
151-
numbers
152-
153-
[1] 0.3229318 0.5933054 0.7778408 0.3898947 0.1309717 0.7501378 0.3206379 0.3379005
154-
'}, browse=FALSE)
155-
```
156-
157-
#### knit and create
158-
159-
You can also knit an input file before posting as a gist:
160-
161-
```{r eval=FALSE}
162-
file <- system.file("examples", "stuff.Rmd", package = "gistr")
163-
gist_create(file, description='a new cool gist', knit=TRUE)
164-
#> <gist>4162b9c53479fbc298db
165-
#> URL: https://gist.github.com/4162b9c53479fbc298db
166-
#> Description: a new cool gist
167-
#> Public: TRUE
168-
#> Created/Edited: 2014-10-27T16:07:31Z / 2014-10-27T16:07:31Z
169-
#> Files: stuff.md
170-
```
171-
172-
Or code blocks before (note that code blocks without knitr block demarcations will result in unexecuted code):
173-
174-
```{r eval=FALSE}
175-
gist_create(code={'
176-
x <- letters
177-
(numbers <- runif(8))
178-
'}, knit=TRUE)
179-
#> <gist>ec45c396dee4aa492139
180-
#> URL: https://gist.github.com/ec45c396dee4aa492139
181-
#> Description:
182-
#> Public: TRUE
183-
#> Created/Edited: 2014-10-27T16:09:09Z / 2014-10-27T16:09:09Z
184-
#> Files: file81720d1ceff.md
185-
```
186-
187-
### knit code from file path, code block, or gist file
188-
189-
knit a local file
190-
191-
```{r}
192-
file <- system.file("examples", "stuff.Rmd", package = "gistr")
193-
run(file, knitopts = list(quiet=TRUE)) %>% gist_create(browse = FALSE)
194-
```
195-
196-
```{r echo=FALSE}
197-
gists('minepublic')[[1]] %>% delete
198-
```
199-
200-
knit a code block (knitr code block notation missing, do add that in) (result not shown)
201-
202-
```{r eval=FALSE}
203-
run({'
204-
x <- letters
205-
(numbers <- runif(8))
206-
'}) %>% gist_create
207-
```
208-
209-
knit a file from a gist, has to get file first (result not shown)
210-
211-
```{r eval=FALSE}
212-
gists('minepublic')[[1]] %>% run() %>% update()
213-
```
214-
215-
### working with images
216-
217-
The GitHub API doesn't let you upload binary files (e.g., images) via their HTTP API, which we use in `gistr`. There is a workaround.
218-
219-
If you are using `.Rmd` or `.Rnw` files, you can set `imgur_inject = TRUE` in `gistr_create()` so that imgur knit options are injected at the top of your file so that images will be uploaded to imgur. Alternatively, you can do this yourself, setting knit options to use imgur.
220-
221-
A file already using imgur
222-
223-
```{r eval=FALSE}
224-
file <- system.file("examples", "plots_imgur.Rmd", package = "gistr")
225-
gist_create(file, knit=TRUE)
226-
#> <gist>1a6e7f7d6ddb739fce0b
227-
#> URL: https://gist.github.com/1a6e7f7d6ddb739fce0b
228-
#> Description:
229-
#> Public: TRUE
230-
#> Created/Edited: 2015-03-19T00:20:48Z / 2015-03-19T00:20:48Z
231-
#> Files: plots_imgur.md
232-
```
233-
234-
A file _NOT_ already using imgur
235-
236-
```{r eval=FALSE}
237-
file <- system.file("examples", "plots.Rmd", package = "gistr")
238-
gist_create(file, knit=TRUE, imgur_inject = TRUE)
239-
#> <gist>ec9987ad245bbc668c72
240-
#> URL: https://gist.github.com/ec9987ad245bbc668c72
241-
#> Description:
242-
#> Public: TRUE
243-
#> Created/Edited: 2015-03-19T00:21:13Z / 2015-03-19T00:21:13Z
244-
#> Files: plots.md
245-
```
246-
247-
### List commits on a gist
248-
249-
```{r}
250-
gists()[[1]] %>% commits()
251-
```
252-
253-
### Star a gist
254-
255-
Star
256-
257-
```{r eval = FALSE}
258-
gist('cbb0507082bb18ff7e4b') %>% star()
259-
#> <gist>cbb0507082bb18ff7e4b
260-
#> URL: https://gist.github.com/cbb0507082bb18ff7e4b
261-
#> Description: This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
262-
#> Public: TRUE
263-
#> Created/Edited: 2014-05-02T19:43:13Z / 2018-04-16T21:11:53Z
264-
#> Files: The Technical Interview Cheat Sheet.md
265-
#> Truncated?: FALSE
266-
```
267-
268-
Unstar
269-
270-
```{r eval = FALSE}
271-
gist('cbb0507082bb18ff7e4b') %>% unstar()
272-
#> <gist>cbb0507082bb18ff7e4b
273-
#> URL: https://gist.github.com/cbb0507082bb18ff7e4b
274-
#> Description: This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.
275-
#> Public: TRUE
276-
#> Created/Edited: 2014-05-02T19:43:13Z / 2018-04-16T21:27:36Z
277-
#> Files: The Technical Interview Cheat Sheet.md
278-
#> Truncated?: FALSE
279-
```
280-
281-
### Edit a gist
282-
283-
Add files
284-
285-
```{r}
286-
file <- system.file("examples", "alm.md", package = "gistr")
287-
gists(what = "minepublic")[[1]] %>%
288-
add_files(file) %>%
289-
update()
290-
```
291-
292-
Delete files
293-
294-
```{r}
295-
file <- system.file("examples", "alm.md", package = "gistr")
296-
gists(what = "minepublic")[[1]] %>%
297-
delete_files(file) %>%
298-
update()
299-
```
300-
301-
### Open a gist in your default browser
302-
303-
```{r eval=FALSE}
304-
gists()[[1]] %>% browse()
305-
```
306-
307-
> Opens the gist in your default browser
308-
309-
### Get embed script
310-
311-
```{r}
312-
gists()[[1]] %>% embed()
313-
```
314-
315-
### List forks
316-
317-
Returns a list of `gist` objects, just like `gists()`
318-
319-
```{r}
320-
gist(id='1642874') %>% forks(per_page=2)
321-
```
322-
323-
### Fork a gist
324-
325-
Returns a `gist` object
326-
327-
```{r}
328-
g <- gists()
329-
(forked <- g[[ sample(seq_along(g), 1) ]] %>% fork())
330-
```
331-
332-
```{r echo=FALSE}
333-
gist(forked$id) %>% delete()
334-
```
335-
33646
## Meta
33747

33848
* Please [report any issues or bugs](https://github.com/ropensci/gistr/issues).
33949
* License: MIT
34050
* Get citation information for `gistr` in R doing `citation(package = 'gistr')`
341-
* Please note that this project is released with a [Contributor Code of Conduct][coc]. By participating in this project you agree to abide by its terms.
51+
* Please note that this package is released with a [Contributor Code of Conduct](https://ropensci.org/code-of-conduct/). By contributing to this project, you agree to abide by its terms.
34252

34353
[![rofooter](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org)
344-
345-
[coc]: https://github.com/ropensci/gistr/blob/master/CODE_OF_CONDUCT.md

0 commit comments

Comments
 (0)