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

Fix 1068 remove old usethis funcs #1125

Merged
merged 3 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions inst/shinyexample/dev/02_dev.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,6 @@ usethis::use_github_action_check_full()
# Add action for PR
usethis::use_github_action_pr_commands()

# Travis CI
usethis::use_travis()
usethis::use_travis_badge()

# AppVeyor
usethis::use_appveyor()
usethis::use_appveyor_badge()

# Circle CI
usethis::use_circleci()
usethis::use_circleci_badge()
Expand Down
22 changes: 10 additions & 12 deletions vignettes/b_dev.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ knitr::opts_chunk$set(

Now that you're all set with your project init, time to move to development!

App development should happen through the `dev/02_dev.R` file, which contains common commands for developing.
App development should happen through the `dev/02_dev.R` file, which contains common commands for developing.

## Launching the app

Expand All @@ -39,7 +39,7 @@ To run the app, go to the `dev/run_dev.R` file, and run the all thing.

You can use `attachment::att_amend_desc()` to parse the code in your `.R` files, detect `@import` `@importFrom` and `::`, and fill your `DESCRIPTION` accordingly.

Note that the `{attachment}` package should be installed on your machine.
Note that the `{attachment}` package should be installed on your machine.

```{r}
attachment::att_amend_desc()
Expand Down Expand Up @@ -77,7 +77,7 @@ mod_my_first_module_server <- function(input, output, session) {

At the end of the file, you will find a piece of code that has to be copied and pasted inside your UI and server functions.

## Add function files
## Add function files

```{r}
golem::add_fct("helpers")
Expand All @@ -97,7 +97,7 @@ golem::add_css_file("custom")
golem::add_sass_file("custom")
```

Note: While the general philosophy of `{golem}` is being based on the idea that you're building a package, these functions can be used outside of a `{golem}` project.
Note: While the general philosophy of `{golem}` is being based on the idea that you're building a package, these functions can be used outside of a `{golem}` project.

Note that you can also download external CSS and JavaScript files with:

Expand All @@ -106,14 +106,14 @@ golem::use_external_css_file(url = "url", name = "your_provided_name")
golem::use_external_js_file(url = "url", name = "your_provided_name")
```

The above has the effect of downloading the file at the specified url and giving it a provided name. If the intent is to use a CDN hosted CSS/JS file then manually add the tag - `tags$script(src = "source_of_ur_css/js")` in the function `golem_add_external_resources` in file `app-ui.R`.
The above has the effect of downloading the file at the specified url and giving it a provided name. If the intent is to use a CDN hosted CSS/JS file then manually add the tag - `tags$script(src = "source_of_ur_css/js")` in the function `golem_add_external_resources` in file `app-ui.R`.
The tag can be added inside the `tags$head(...)` if the intent is to load the js/css file in the `<head>` of the document or outside it if it is intended in the `<body>`.

### Adding these external resources to your app

You can add any external resource into `inst/app/www`.
You can add any external resource into `inst/app/www`.

JavaScript and CSS are automatically linked in the `golem_add_external_resources()` function. If you add other resources (example images), you can link them in the app with the `www` prefix:
JavaScript and CSS are automatically linked in the `golem_add_external_resources()` function. If you add other resources (example images), you can link them in the app with the `www` prefix:

```{r}
tags$img(src = "www/my.png")
Expand All @@ -123,7 +123,7 @@ You can also list here the use of other packages, for example `useShinyalert()`

### Add a data-raw folder

If you have data in your package:
If you have data in your package:

```{r}
usethis::use_data_raw()
Expand Down Expand Up @@ -155,14 +155,12 @@ About [package Vignette](https://r-pkgs.org/vignettes.html).
### Code coverage

```{r}
usethis::use_travis()
usethis::use_appveyor()
usethis::use_coverage()
```

## Using `{golem}` dev functions

There's a series of tools to make your app behave differently whether it's in dev or prod mode. Notably, the `app_prod()` and `app_dev()` function tests for `options( "golem.app.prod")` (or return TRUE if this option doesn't exist).
There's a series of tools to make your app behave differently whether it's in dev or prod mode. Notably, the `app_prod()` and `app_dev()` function tests for `options( "golem.app.prod")` (or return TRUE if this option doesn't exist).

Setting this options at the beginning of your dev process allows to make your app behave in a specific way when you are in dev mode. For example, printing message to the console with `cat_dev()`.

Expand All @@ -173,7 +171,7 @@ options("golem.app.prod" = FALSE)
golem::cat_dev("hey\n")
```

You can then make any function being "dev-dependent" with the `make_dev()` function:
You can then make any function being "dev-dependent" with the `make_dev()` function:

```{r eval = TRUE}
log_dev <- golem::make_dev(log)
Expand Down