Skip to content

Commit

Permalink
ShinyLive to Shinylive; spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelru committed Aug 20, 2024
1 parent f576c90 commit 7ec7bf2
Show file tree
Hide file tree
Showing 10 changed files with 123 additions and 117 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: roxy.shinylive
Title: A roxygen2 Extension for Shinylive
Version: 0.0.0.9000
Version: 0.0.0.9001
Authors@R: c(
person("Pawel Rucki", , , "[email protected]", role = c("aut", "cre")),
person("F. Hoffmann-La Roche AG", role = c("cph", "fnd"))
Expand Down Expand Up @@ -36,5 +36,5 @@ Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.2
Config/testthat/edition: 3
Collate:
'examplesShinyLive.R'
'examplesShinylive.R'
'parse_url.R'
6 changes: 3 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generated by roxygen2: do not edit by hand

S3method(format,rd_section_examplesShinyLive)
S3method(roxygen2::roxy_tag_parse,roxy_tag_examplesShinyLive)
S3method(roxygen2::roxy_tag_rd,roxy_tag_examplesShinyLive)
S3method(format,rd_section_examplesShinylive)
S3method(roxygen2::roxy_tag_parse,roxy_tag_examplesShinylive)
S3method(roxygen2::roxy_tag_rd,roxy_tag_examplesShinylive)
importFrom(glue,glue_data)
importFrom(jsonlite,toJSON)
importFrom(jsonlite,unbox)
Expand Down
46 changes: 23 additions & 23 deletions R/examplesShinyLive.R
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#' Custom `examplesShinyLive` tag.
#' Custom `examplesShinylive` tag.
#'
#' This function generates a new section with ShinyLive links to the applications from this tag content.
#' This function generates a new section with Shinylive links to the applications from this tag content.
#' If no code is provided then the code from the following `@examples` tag is used.
#'
#' The application code must be executable inside ShinyLive. If the application code includes functions from your
#' The application code must be executable inside Shinylive. If the application code includes functions from your
#' package, you must add `library(<your package>)` beforehand. For more information, refer to the Decoration section
#' on how to use and decorate existing examples.
#'
Expand All @@ -12,8 +12,8 @@
#'
#' @section Decoration:
#'
#' To avoid repetition between the `@examplesShinyLive` and `@examples` sections, there are special string literals
#' that provide access to the `@examples` content from within `@examplesShinyLive`.
#' To avoid repetition between the `@examplesShinylive` and `@examples` sections, there are special string literals
#' that provide access to the `@examples` content from within `@examplesShinylive`.
#' These literals should be used as expressions embraced with `{{ }}`, which are then interpolated using
#' `glue::glue_data(..., .open = "{{", .close = "}}")`.
#'
Expand All @@ -23,26 +23,26 @@
#' * `"{{ next_example }}"` - "raw" element of the next example
#' * `"{{ prev_example }}"` - "raw" element of the previous example
#'
#' This allows you to access and decorate existing example code to create executable application code for ShinyLive.
#' This allows you to access and decorate existing example code to create executable application code for Shinylive.
#' Refer to the examples section for possible use cases.
#'
#' @name tag-examplesShinyLive
#' @name tag-examplesShinylive
#'
#' @usage
#' #' @examplesShinyLive${1:# example code (optional)}
#' #' @examplesShinylive${1:# example code (optional)}
#'
#' @examples
#' # As a part of documentation:
#'
#' # basic example:
#' #' (docs)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' @examples
#' #' (example code)
#'
#' # using keywords:
#' #' (docs)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' foo <- 1
#' #' {{ next_example }}
#' #' bar <- 2
Expand All @@ -51,7 +51,7 @@
#'
#' # A typical example would be:
#' #' (docs)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' library(<your package>)
#' #' interactive <- function() TRUE
#' #' {{ next_example }}
Expand All @@ -63,41 +63,41 @@
#'
#' # multiple apps:
#' #' (docs)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' @examples
#' #' (your example app 1)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' @examples
#' #' (your example app 2)
#'
#' # skip parts of example code:
#' #' (docs)
#' #' @examples
#' #' (your example code - skipped)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' @examples
#' #' (your example code - included)
#'
#' # multiple apps with keywords:
#' #' (docs)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' x <- 1
#' #' {{ next_example }}
#' #' @examples
#' #' (your example app 1)
#' #' @examplesShinyLive
#' #' @examplesShinylive
#' #' y <- 1
#' #' {{ next_example }}
#' #' @examples
#' #' (your example app 2)
NULL

#' @noRd
#' @exportS3Method roxygen2::roxy_tag_parse roxy_tag_examplesShinyLive
#' @exportS3Method roxygen2::roxy_tag_parse roxy_tag_examplesShinylive
#' @importFrom glue glue_data
#' @importFrom stringr str_trim
#' @importFrom roxygen2 warn_roxy_tag
roxy_tag_parse.roxy_tag_examplesShinyLive <- function(x) {
roxy_tag_parse.roxy_tag_examplesShinylive <- function(x) {
if (stringr::str_trim(x$raw) == "") {
x$raw <- "{{ next_example }}"
}
Expand Down Expand Up @@ -150,15 +150,15 @@ roxy_tag_parse.roxy_tag_examplesShinyLive <- function(x) {
}

#' @noRd
#' @exportS3Method roxygen2::roxy_tag_rd roxy_tag_examplesShinyLive
#' @exportS3Method roxygen2::roxy_tag_rd roxy_tag_examplesShinylive
#' @importFrom roxygen2 rd_section
roxy_tag_rd.roxy_tag_examplesShinyLive <- function(x, base_path, env) {
roxygen2::rd_section("examplesShinyLive", x$val)
roxy_tag_rd.roxy_tag_examplesShinylive <- function(x, base_path, env) {
roxygen2::rd_section("examplesShinylive", x$val)
}

#' @noRd
#' @exportS3Method format rd_section_examplesShinyLive
format.rd_section_examplesShinyLive <- function(x, ...) {
#' @exportS3Method format rd_section_examplesShinylive
format.rd_section_examplesShinylive <- function(x, ...) {
paste0(
"\\section{Run examples in Shinylive}{\n",
"\\itemize{\n",
Expand Down
4 changes: 2 additions & 2 deletions R/parse_url.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#' Creates shinylive url for the app code.
#' Creates Shinylive url for the app code.
#'
#' @importFrom jsonlite unbox toJSON
#' @importFrom lzstring compressToEncodedURIComponent
#'
#' @param code (`character(1)`) A string with app code.
#' @return (`character(1)`) ShinyLive app url.
#' @return (`character(1)`) Shinylive app url.
create_shinylive_url <- function(code) {
# implementation based on "Create ShinyLive Link" feature of Shiny VSCode extension
# https://github.com/posit-dev/shiny-vscode/blob/80560bf36d516ff89dffe88bd9a28cee9edd4d43/src/shinylive.ts#L499
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This package provides a `roxygen2` extension that automatically takes the exampl
## Install

```r
devtools::install_github("insightsengineering/roxy.shinylive")
pak::pak("insightsengineering/roxy.shinylive")
```

## Usage
Expand All @@ -20,9 +20,9 @@ Roxygen: list(markdown = TRUE, packages = c("roxy.shinylive"))
Then in your package documentation:
```r
#' (docs)
#' @examplesShinyLive
#' @examplesShinylive
#' @examples
#' (example code with shiny App)
#' (example code with a Shiny app)
```

Which would produce a following output in your documentation:
Expand All @@ -37,4 +37,4 @@ Which would produce a following output in your documentation:
}
```

See the pacakge documentation for more details.
See the package documentation for more details.
6 changes: 6 additions & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Shinylive
WebR
installable
roxy
roxygen
shinylive
6 changes: 3 additions & 3 deletions man/create_shinylive_url.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 18 additions & 18 deletions man/tag-examplesShinyLive.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions tests/testthat/_snaps/examplesShinyLive.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# examplesShinyLive tag - errors - missing @examples
# examplesShinylive tag - errors - missing @examples

Code
block <- roxygen2::parse_text(text)[[1]]
Message
x <text>:8: @examplesShinyLive requires a value.
x <text>:8: @examplesShinylive requires a value.

# examplesShinyLive tag - keywords - error when parsing with glue
# examplesShinylive tag - keywords - error when parsing with glue

Code
block <- roxygen2::parse_text(text)[[1]]
Message
x <text>:8: @examplesShinyLive failed to interpolate the content.
x <text>:8: @examplesShinylive failed to interpolate the content.

Loading

0 comments on commit 7ec7bf2

Please sign in to comment.