@@ -119,20 +119,58 @@ documentation more engaging and allows users to experiment with examples
119119without installing R locally.
120120
121121For this to work with developmental versions of your package, you will
122- need to use the following ` pkgdown ` + ` rwasm ` build action:
122+ need to either have an account with
123+ [ r-universe.dev] ( https://r-universe.dev/ ) or use the following
124+ ` pkgdown ` + ` rwasm ` build action:
123125
124126< https://github.com/r-wasm/actions/blob/main/examples/rwasm-binary-and-pkgdown-site.yml >
125127
126128For a fast setup, please use:
127129
128130``` r
129- usethis :: use_github_action(" https://github.com/r-wasm/actions/blob/main/examples/rwasm-binary-and-pkgdown-site.yml" )
131+ usethis :: use_github_action(repos = " https://github.com/r-wasm/actions/blob/main/examples/rwasm-binary-and-pkgdown-site.yml" )
130132```
131133
132134> \[ !IMPORTANT\]
133135>
134136> Please make sure to delete your old ` pkgdown.yml ` file.
135137
138+ ## Requirements
139+
140+ For ` @examplesWebR ` functionality, your package’s ` DESCRIPTION ` file
141+ must have:
142+
143+ Suggests:
144+ rocleteer
145+ Remotes: coatless-rpkg/rocleteer
146+
147+ Roxygen: list(..., packages = c("rocleteer"))
148+
149+ Config/rocleteer/webr-repo: https://user.github.io/pkgname/
150+
151+ For the package to be usable in webR examples, you must specify a
152+ webR-compatible repository in your ` DESCRIPTION ` file. This repository
153+ can be generated by [ ` r-universe ` ] ( https://r-universe.dev/ ) or by using
154+ the above GitHub Action to build and serve a webR R binary alongside
155+ your pkgdown site.
156+
157+ By default, the ` @examplesWebR ` tag will look for the following:
158+
159+ - ` Config/rocleteer/webr-repo: https://user.r-universe.dev/ `
160+ (recommended)
161+ - ` Config/rocleteer/webr-repo: https://user.github.io/pkgname/ `
162+ - ` URL ` field containing GitHub Pages or R-universe patterns (shown
163+ above)
164+
165+ If none of these are found, the tag will produce a warning during
166+ processing and will not generate the webR section in the Rd file.
167+
168+ #### WebR Version Support
169+
170+ Only webR versions v0.5.4 and higher are supported. The tag will
171+ validate the version parameter and produce an error if an unsupported
172+ version is specified.
173+
136174#### Generated Structure
137175
138176When you use ` @examplesWebR ` , it generates:
@@ -158,7 +196,8 @@ it generates:
158196\section {WebR }{
159197 \ifelse {html }{
160198 \out {
161- < a href = " webR_URL" > \U0001F310 View in webR REPL < / a >
199+ < button > \U0001F310 Try it in your browser ! < / button >
200+ < iframe href = " webR_URL" >< / iframe >
162201 }
163202 }{
164203 \ifelse {latex }{
@@ -181,23 +220,25 @@ plot(x, y, type = "b", main = "Interactive Example")
181220This creates:
182221
183222- Regular examples with your R code
184- - A “WebR” section with a “View in webR REPL” button in HTML
185- documentation or a URL in LaTeX documentation.
186- - The button opens the code in an interactive webR session
223+ - A “WebR” section with a “Try it in your browser” and “Open in Tab”
224+ buttons in HTML documentation or a URL in LaTeX documentation.
225+ - The button opens either an embedded webR session or a new tab with the
226+ code in an interactive webR REPL.
187227
188228> \[ !NOTE\]
189229>
190230> The ` @examplesWebR ` tag uses a simplified encoding scheme compatible
191231> with webR.
192232
193- #### Embedded Mode
233+ #### Standalone Mode
194234
195- For a more integrated experience, embed the webR REPL directly into the
196- Rd file with:
235+ To avoid embedding the webR REPL, you can use the
236+ ` @examplesWebR embed=false ` tag. This will generate a link to the webR
237+ REPL without embedding it directly in the documentation.
197238
198239``` r
199240# ' @examplesWebR embed
200- # ' # This code will be available in an embedded webR session
241+ # ' # This code will be available in a new web browser tab with the webR REPL
201242# ' library(ggplot2)
202243# ' ggplot(mtcars, aes(mpg, wt)) +
203244# ' geom_point() +
@@ -208,15 +249,20 @@ Rd file with:
208249
209250You can customize the ` @examplesWebR ` tag with additional options:
210251
211- - ` embed ` : Embed an iframe instead of showing a link
212- - ` height=N ` : Set iframe height in pixels (default: ` 300 ` )
252+ - ` autorun ` : Embed an iframe instead of showing a link (default:
253+ ` "false" ` )
254+ - ` embed ` : Embed an iframe instead of showing a link (default: ` "true" ` )
255+ - ` height=N ` : Set iframe height in pixels (default: ` 400 ` )
213256- ` version=X ` : Specify webR version (default: ` "latest" ` )
257+ - ` mode=X-Y ` : Configure embedded webR interface (editor, plot, terminal,
258+ files) (default: ` "editor-plot-terminal" ` )
259+ - ` channel=X ` : Set webR communication channel (default: ` "Automatic ` )
214260
215261For example, to embed with a specific height and version:
216262
217263``` r
218- # ' @examplesWebR embed height=500 version=v0.3.3
219- # ' # Custom height iframe with specific webR version
264+ # ' @examplesWebR autorun height=500 version=v0.5.4
265+ # ' # Custom height iframe with specific webR version that autoruns code
220266# ' summary(cars)
221267# ' plot(cars)
222268```
0 commit comments