Skip to content

Commit 86c73ad

Browse files
committed
Improve clarity of accessing repo locations
1 parent ea8ea29 commit 86c73ad

File tree

2 files changed

+76
-47
lines changed

2 files changed

+76
-47
lines changed

README.md

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,40 @@ the total compressed space.
197197

198198
## Accessing Binaries
199199

200-
Inside of a webR session, you can access the built binaries by using the
201-
repository’s GitHub Pages URL, e.g.
202-
203-
``` default
204-
https://gh-username.github.io/repo-name
200+
In a webR session, access the built binaries using the repository’s
201+
GitHub Pages URL, for example:
202+
203+
https://gh-username.github.io/repo-name
204+
205+
Depending on where you are using the custom R WASM package binary, you
206+
can register this repository in different ways:
207+
208+
1. Using the `repos` key inside of the `quarto-webr` extension;
209+
2. Using `options()` to set values for both `repos` and
210+
`webr_pkg_repos`; or,
211+
3. Using the `repos` parameter in each `webr::install()` call.
212+
213+
### `repos` Document key in `{quarto-webr}`
214+
215+
With version v0.4.0 of the `{quarto-webr}` extension, the repository can
216+
be included by using the [`repos` key in the document
217+
header](https://quarto-webr.thecoatlessprofessor.com/qwebr-using-r-packages.html#custom-repositories):
218+
219+
``` md
220+
---
221+
webr:
222+
packages: ['pkgname']
223+
repos:
224+
- https://gh-username.github.io/repo-name
225+
filters:
226+
- webr
227+
---
205228
```
206229

207-
This can be set either using `options()` or specifying the location in
208-
each `webr::install()` call.
230+
### Specifying repo urls with `options()`
209231

210-
The easiest is probably to define the location webR should search for in
211-
`options()`.
232+
To define the location webR should search for in `options()`, we need to
233+
set both `repos` and `webr_pkg_repos`.
212234

213235
``` r
214236
## Run once at the start of the session
@@ -217,6 +239,7 @@ The easiest is probably to define the location webR should search for in
217239
list_of_repos = c(
218240
"https://gh-username.github.io/repo-name",
219241
"https://other-gh-username.github.io/another-repo",
242+
"https://username.r-universe.dev",
220243
"https://repo.r-wasm.org/"
221244
)
222245

@@ -238,37 +261,25 @@ webr::install("pkgname")
238261
> however, other R functions like `available.packages()` check the
239262
> `repos` parameter.
240263
241-
Otherwise, you can specify it each time in the `webr::install()`
242-
command:
264+
### Specifying `repos` in `webr::install()`
265+
266+
The `repos` parameter may also be specified in the `webr::install()`
267+
command each time you need to install a package from a custom location:
243268

244269
``` r
245270
webr::install("pkgname", repos = "https://gh-username.github.io/repo-name")
246271

247272
webr::install("pkgname", repos = list_of_repos)
248273
```
249274

250-
> [!NOTE]
251-
>
252-
> We do not suggest modifying at the initialization phase the
253-
> [`repoUrl`](https://docs.r-wasm.org/webr/latest/api/js/interfaces/WebR.WebROptions.html#repourl)
254-
> option in
255-
> [`WebR({})`](https://docs.r-wasm.org/webr/latest/api/js/classes/WebR.WebR.html)
256-
> as that will limit the packages to only one repository (e.g. the
257-
> custom repository).
258-
259275
> [!IMPORTANT]
260276
>
261-
> Please make sure the repository’s [GitHub Pages website is available
262-
> over
277+
> Ensure the repository’s [GitHub Pages website is available over
263278
> `HTTPS`](https://docs.github.com/en/pages/getting-started-with-github-pages/securing-your-github-pages-site-with-https#enforcing-https-for-your-github-pages-site)
264-
> not `HTTP` (notice the lack of an `s`). You can verify this option was
265-
> selected by:
266-
>
267-
> 1. Going to the repository’s **Settings** page
268-
> 2. Selecting **Pages** under **Code and automation**
269-
> 3. Checking the **Enforce HTTPS** button.
279+
> (not `HTTP`). Verify this option in the repository’s **Settings** page
280+
> under **Code and automation** \> **Pages** \> **Enforce HTTPS**.
270281
>
271-
> Otherwise, you will receive the error message of:
282+
> Otherwise, you might encounter an error:
272283
>
273284
> Warning: unable to access index for repository http://gh-username.github.io/repo-name/bin/emscripten/contrib/4.3
274285

README.qmd

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -169,18 +169,39 @@ while the size of the `rwasmrepo` is only 6.87 MB of the total compressed space.
169169

170170
## Accessing Binaries
171171

172-
Inside of a webR session, you can access the built binaries by using
173-
the repository's GitHub Pages URL, e.g.
172+
In a webR session, access the built binaries using the repository's GitHub Pages URL, for example:
174173

175-
```default
174+
```
176175
https://gh-username.github.io/repo-name
177176
```
178177

179-
This can be set either using `options()` or specifying the location in each
180-
`webr::install()` call.
178+
Depending on where you are using the custom R WASM package binary, you can
179+
register this repository in different ways:
180+
181+
1. Using the `repos` key inside of the `quarto-webr` extension;
182+
2. Using `options()` to set values for both `repos` and `webr_pkg_repos`; or,
183+
3. Using the `repos` parameter in each `webr::install()` call.
184+
185+
### `repos` Document key in `{quarto-webr}`
186+
187+
With version v0.4.0 of the `{quarto-webr}` extension, the repository
188+
can be included by using the [`repos` key in the document header](https://quarto-webr.thecoatlessprofessor.com/qwebr-using-r-packages.html#custom-repositories):
189+
190+
```md
191+
---
192+
webr:
193+
packages: ['pkgname']
194+
repos:
195+
- https://gh-username.github.io/repo-name
196+
filters:
197+
- webr
198+
---
199+
```
200+
201+
### Specifying repo urls with `options()`
181202

182-
The easiest is probably to define the location webR should search for in
183-
`options()`.
203+
To define the location webR should search for in `options()`, we need to
204+
set both `repos` and `webr_pkg_repos`.
184205

185206
```r
186207
## Run once at the start of the session
@@ -189,6 +210,7 @@ The easiest is probably to define the location webR should search for in
189210
list_of_repos = c(
190211
"https://gh-username.github.io/repo-name",
191212
"https://other-gh-username.github.io/another-repo",
213+
"https://username.r-universe.dev",
192214
"https://repo.r-wasm.org/"
193215
)
194216

@@ -207,33 +229,29 @@ This is different than the `repos` option one would usually set since webR only
207229
check the `repos` parameter.
208230
:::
209231

210-
Otherwise, you can specify it each time in the `webr::install()` command:
232+
### Specifying `repos` in `webr::install()`
233+
234+
The `repos` parameter may also be specified in the `webr::install()` command
235+
each time you need to install a package from a custom location:
211236

212237
```r
213238
webr::install("pkgname", repos = "https://gh-username.github.io/repo-name")
214239

215240
webr::install("pkgname", repos = list_of_repos)
216241
```
217242

218-
:::{.callout-note}
219-
We do not suggest modifying at the initialization phase the [`repoUrl`](https://docs.r-wasm.org/webr/latest/api/js/interfaces/WebR.WebROptions.html#repourl) option in [`WebR({})`](https://docs.r-wasm.org/webr/latest/api/js/classes/WebR.WebR.html) as that will limit the packages to only one repository (e.g. the custom repository).
220-
:::
221-
222243
:::{.callout-important}
223-
Please make sure the repository's [GitHub Pages website is available over `HTTPS`](https://docs.github.com/en/pages/getting-started-with-github-pages/securing-your-github-pages-site-with-https#enforcing-https-for-your-github-pages-site) not `HTTP` (notice the lack of an `s`).
224-
You can verify this option was selected by:
225244

226-
1. Going to the repository's **Settings** page
227-
2. Selecting **Pages** under **Code and automation**
228-
3. Checking the **Enforce HTTPS** button.
245+
Ensure the repository's [GitHub Pages website is available over `HTTPS`](https://docs.github.com/en/pages/getting-started-with-github-pages/securing-your-github-pages-site-with-https#enforcing-https-for-your-github-pages-site) (not `HTTP`). Verify this option in the repository's **Settings** page under **Code and automation** > **Pages** > **Enforce HTTPS**.
229246

230-
Otherwise, you will receive the error message of:
247+
Otherwise, you might encounter an error:
231248

232249
```
233250
Warning: unable to access index for repository http://gh-username.github.io/repo-name/bin/emscripten/contrib/4.3
234251
```
235252
:::
236253

254+
237255
## Verify
238256

239257
Go to the [webR REPL Editor](https://webr.r-wasm.org/v0.2.2/) (pinned to v0.2.2)

0 commit comments

Comments
 (0)