Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples to use bslib #3963

Merged
merged 20 commits into from
Mar 20, 2024
Merged

Conversation

skaltman
Copy link
Contributor

@skaltman skaltman commented Jan 3, 2024

This PR updates runExample() to use {bslib}-powered examples. These new examples are located under inst/shiny instead of inst/examples.

To run the old (legacy) examples, set options(shiny.legacy.examples = TRUE)

@CLAassistant
Copy link

CLAassistant commented Jan 3, 2024

CLA assistant check
All committers have signed the CLA.

…date runExamples() to use that directory by default
inst/shiny/04_mpg/app.R Outdated Show resolved Hide resolved
inst/shiny/11_timer/app.R Outdated Show resolved Hide resolved
@cpsievert
Copy link
Collaborator

Looking good to so far! I just changed file locations around a bit for better backwards-compatibility reasons.

I also suggested a couple small tweaks, and left them unresolved in case you need to make updates elsewhere

@cpsievert cpsievert requested a review from gadenbuie February 2, 2024 22:51
@cpsievert cpsievert added this to the 1.9 milestone Mar 13, 2024
NEWS.md Show resolved Hide resolved
@cpsievert cpsievert marked this pull request as ready for review March 19, 2024 23:03
Copy link
Member

@gadenbuie gadenbuie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great thanks everyone!

I'd love to see us use consistent and modern code style throughout. I certainly have opinions and am happy to restyle the new examples in a follow up.

In particular, I'd like to follow these rules:

  1. All arguments to a function are either on the same line or each argument is on a new line.
  2. Closing braces and parens have the same level of indentation as line containing the opening function call.
# Before
      textInput(inputId = "caption",
                label = "Caption:",
                value = "Data Summary"),

      # Input: Selector for choosing dataset ----
      selectInput(inputId = "dataset",
                  label = "Choose a dataset:",
                  choices = c("rock", "pressure", "cars")),

# After
      textInput(
        inputId = "caption",
        label = "Caption:",
        value = "Data Summary"
      ),

      # Input: Selector for choosing dataset ----
      selectInput(
        inputId = "dataset",
        label = "Choose a dataset:",
        choices = c("rock", "pressure", "cars")
      ),

Importantly, this code style matches Python's black formatting rules so it's easier for us to be consistent across languages and projects if we follow it.

Comment on lines +470 to +472
legacy <- getOption('shiny.legacy.examples', FALSE)
examplesDir <- if (isTRUE(legacy)) 'examples' else 'shiny'
examplesDir <- system_file(examplesDir, package='shiny')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karangattu started working on extending runExample() to other packages in #3917.

That said, while we're here, I think we should do a very light-weight version of that work and add package = "shiny" to runExample()'s parameters.

I'll take that in a follow-up PR.

@cpsievert cpsievert merged commit 47fb562 into rstudio:main Mar 20, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants