11---
2- title : " echogithub: Getting started"
3- author : " <h4>Author: <i>Brian M. Schilder</i></h4>"
2+ title : " echogithub: Getting started"
3+ author : " <h4>Author: <i>Brian M. Schilder</i></h4>"
44date : " <h4>Most recent update: <i>`r format( Sys.Date(), '%b-%d-%Y')`</i></h4>"
55output :
66 BiocStyle::html_document
77vignette : >
8- %\VignetteIndexEntry{echogithub}
8+ %\VignetteIndexEntry{echogithub}
99 %\usepackage[utf8]{inputenc}
1010 %\VignetteEngine{knitr::rmarkdown}
1111---
1212
13- ``` {r setup}
13+ ``` {r setup, include = FALSE }
1414library(echogithub)
15+ has_internet <- function() {
16+ tryCatch({
17+ con <- url("https://github.com", open = "r")
18+ close(con)
19+ TRUE
20+ }, error = function(e) FALSE)
21+ }
1522```
1623
1724# GitHub branches
@@ -20,7 +27,7 @@ library(echogithub)
2027
2128Easily find all available branches for a given GitHub repo.
2229
23- ``` {r}
30+ ``` {r, eval = has_internet() }
2431branches <- echogithub::github_branches(owner = "RajLabMSSM",
2532 repo = "echolocatoR")
2633print(branches)
@@ -29,35 +36,35 @@ print(branches)
2936## Check
3037
3138You can also check whether a particular branch exists.
32- By default, ` github_branches() ` interprets "master" and "main" as synonymous and
39+ By default, ` github_branches() ` interprets "master" and "main" as synonymous and
3340returns whichever one actually exists.
3441
35- ``` {r}
36- branches <- echogithub::github_branches(owner = "RajLabMSSM",
37- repo = "echolocatoR",
42+ ``` {r, eval = has_internet() }
43+ branches <- echogithub::github_branches(owner = "RajLabMSSM",
44+ repo = "echolocatoR",
3845 branch = "main")
3946print(branches)
4047```
4148
4249
43- # GitHub files
50+ # GitHub files
4451
4552` github_files() ` lets you easily:
46- 1 . Search any GitHub repo
47- (that you have access to) for files.
48- 2 . Filter those files by a * regex* ` query ` ,
49- 3 . Download those files to your local compute
50- (can increase ` nThread ` to speed up download via parallelization).
5153
52- * NOTE* :
53- To search your private repos, make sure you
54- GitHub token is supplied to the ` token ` argument, or is saved as in your
55- * ~ .Renviron* file, e.g.: ` GITHUB_TOKEN=<token_here> `
54+ 1 . Search any GitHub repo (that you have access to) for files.
55+ 2 . Filter those files by a * regex* ` query ` .
56+ 3 . Download those files to your local computer
57+ (can increase ` nThread ` to speed up download via parallelisation).
58+
59+ * NOTE* :
60+ To search your private repos, make sure your
61+ GitHub token is supplied to the ` token ` argument, or is saved in your
62+ * ~ /.Renviron* file, e.g.: ` GITHUB_TOKEN=<token_here> `
5663
57- ## Search / filter / downlaod
64+ ## Search / filter / download
5865
59- ``` {r}
60- files <- echogithub::github_files(owner = "RajLabMSSM",
66+ ``` {r, eval = has_internet() }
67+ files <- echogithub::github_files(owner = "RajLabMSSM",
6168 repo = "Fine_Mapping_Shiny",
6269 query = ".md$",
6370 ignore.case = TRUE,
@@ -67,89 +74,93 @@ knitr::kable(utils::head(files))
6774
6875# GitHub Pages
6976
70- There are several functions to searching GitHub Pages websites associated
77+ There are several functions for searching GitHub Pages websites associated
7178with specific GitHub repos.
7279
7380## Find GitHub Pages URL
7481
82+ First, since not all GitHub repos use GitHub Pages, we should find out
83+ whether the one we are interested in exists.
7584
76- First, since not all GitHub repo have use GitHub Pages, we should find out
77- whether the one we're interested in exist.
78-
79- ``` {r}
80- ghpages_url <- echogithub::github_pages(owner ="RajLabMSSM",
85+ ``` {r, eval = has_internet()}
86+ ghpages_url <- echogithub::github_pages(owner = "RajLabMSSM",
8187 repo = "echolocatoR")
8288print(ghpages_url)
8389```
8490
85- If it doesn't exist, the function will simply return ` NULL ` when you set
86- ` error= FALSE ` .
91+ If it does not exist, the function will simply return ` NULL ` when you set
92+ ` error = FALSE ` .
8793
88- ``` {r}
89- ghpages_null <- echogithub::github_pages(owner ="RajLabMSSM",
90- repo = "Fine_Mapping_Shiny",
91- error = FALSE)
94+ ``` {r, eval = has_internet() }
95+ ghpages_null <- echogithub::github_pages(owner = "RajLabMSSM",
96+ repo = "Fine_Mapping_Shiny",
97+ error = FALSE)
9298print(ghpages_null)
9399```
94100
95101
96102## Find vignettes
97103
98- ` github_pages_vignettes ` allows you to easily gather all vignettes
104+ ` github_pages_vignettes ` allows you to easily gather all vignettes
99105across multiple GitHub Pages websites at once.
100106
101107### As ` data.table `
102108
103- ``` {r}
104- vdt <- echogithub::github_pages_vignettes(owner = c("RajLabMSSM","neurogenomics"),
105- repo = c("echodata","MungeSumstats"))
109+ ``` {r, eval = has_internet()}
110+ vdt <- echogithub::github_pages_vignettes(
111+ owner = c("RajLabMSSM", "neurogenomics"),
112+ repo = c("echodata", "MungeSumstats")
113+ )
106114knitr::kable(utils::head(vdt))
107115```
108116
109117### As table of contents
110118
111- You can also use the ` as_toc= TRUE ` argument to turn the vignettes ` data.table `
112- into an HTML Table of Contents (TOC).
119+ You can also use the ` as_toc = TRUE ` argument to turn the vignettes
120+ ` data.table ` into an HTML Table of Contents (TOC).
113121
114- ``` {r, results='asis'}
115- toc <- echogithub::github_pages_vignettes(owner = c("RajLabMSSM","neurogenomics"),
116- repo = c("echodata","MungeSumstats"),
117- as_toc = TRUE)
122+ ``` {r, results='asis', eval = has_internet()}
123+ toc <- echogithub::github_pages_vignettes(
124+ owner = c("RajLabMSSM", "neurogenomics"),
125+ repo = c("echodata", "MungeSumstats"),
126+ as_toc = TRUE
127+ )
118128```
119129
120130# * DESCRIPTION* files
121131
122- * DESCRIPTION* files contains essential information about each R package.
123- However finding and importing them is not always straightforward
132+ * DESCRIPTION* files contain essential information about each R package.
133+ However, finding and importing them is not always straightforward
124134(e.g. when the package is not yet installed).
125- ` echogithub::description_extract ` searches a variety of sources
126- (e.g. local files, local installations, GitHub) to find the correct
135+ ` echogithub::description_extract ` searches a variety of sources
136+ (e.g. local files, local installations, GitHub) to find the correct
127137* DESCRIPTION* file and import it into the easy-to-use ` description ` format.
128138
129139It then parses it to extract the relevant information.
130-
140+
131141## Find and extract
132142
133- ` description_extract ` then takes that object and extracts and parses
143+ ` description_extract ` takes that object and extracts and parses
134144just the fields you need, returning them as a named list.
135145
136- ``` {r}
137- res <- echogithub::description_extract(refs = c("RajLabMSSM/echolocatoR",
138- "RajLabMSSM/echogithub",
139- "RajLabMSSM/rworkflows"))
146+ ``` {r, eval = has_internet()}
147+ res <- echogithub::description_extract(
148+ refs = c("RajLabMSSM/echolocatoR",
149+ "RajLabMSSM/echogithub",
150+ "RajLabMSSM/rworkflows")
151+ )
140152methods::show(res)
141153```
142154
143155
144- # Session Info
156+ # Session Info
145157
146- <details >
158+ <details >
147159
148160``` {r Session Info}
149161utils::sessionInfo()
150162```
151163
152- </details >
164+ </details >
153165
154166<hr >
155-
0 commit comments