Skip to content

Commit

Permalink
Merge pull request #252 from ThinkR-open/to-0.6.0
Browse files Browse the repository at this point in the history
To 0.6.0 - Version sent to CRAN
  • Loading branch information
statnmap authored May 13, 2024
2 parents 763c1c0 + 5d3c888 commit 9cffedf
Show file tree
Hide file tree
Showing 31 changed files with 214 additions and 159 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-20.04, r: '3.6'}
# - {os: ubuntu-20.04, r: '3.6'}
# - {os: ubuntu-20.04, r: '3.5'} # with usethis >2.2

env:
Expand Down
36 changes: 26 additions & 10 deletions .github/workflows/rhub.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# R-hub's genetic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/rhub2/blob/v1/inst/workflow/rhub.yaml
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
# You can update this file to a newer version using the rhub2 package:
#
# rhub2::rhub_setup()
# rhub::rhub_setup()
#
# It is unlikely that you need to modify this file manually.

name: R-hub
run-name: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }} (${{ github.event.inputs.id }})
run-name: "${{ github.event.inputs.id }}: ${{ github.event.inputs.name || format('Manually run by {0}', github.triggering_actor) }}"

on:
workflow_dispatch:
Expand All @@ -33,7 +33,7 @@ jobs:

steps:
# NO NEED TO CHECKOUT HERE
- uses: r-hub/rhub2/actions/rhub-setup@v1
- uses: r-hub/actions/setup@v1
with:
config: ${{ github.event.inputs.config }}
id: rhub-setup
Expand All @@ -51,8 +51,16 @@ jobs:
image: ${{ matrix.config.container }}

steps:
- uses: actions/checkout@v3
- uses: r-hub/rhub2/actions/rhub-check@v1
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/run-check@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
Expand All @@ -68,12 +76,20 @@ jobs:
config: ${{ fromJson(needs.setup.outputs.platforms) }}

steps:
- uses: actions/checkout@v3
- uses: r-hub/rhub2/actions/rhub-setup-r@v1
- uses: r-hub/actions/checkout@v1
- uses: r-hub/actions/setup-r@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/actions/platform-info@v1
with:
token: ${{ secrets.RHUB_TOKEN }}
job-config: ${{ matrix.config.job-config }}
- uses: r-hub/actions/setup-deps@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
- uses: r-hub/rhub2/actions/rhub-check@v1
- uses: r-hub/actions/run-check@v1
with:
job-config: ${{ matrix.config.job-config }}
token: ${{ secrets.RHUB_TOKEN }}
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Package: fusen
Title: Build a Package from Rmarkdown Files
Version: 0.6.0
Authors@R: c(
person("Sebastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
person("Sebastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-1565-9313")),
person("ThinkR", role = "cph")
)
Expand Down
2 changes: 1 addition & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export(add_minimal_package)
export(check_not_registered_files)
export(create_fusen)
export(deprecate_flat_file)
export(draw_the_tree)
export(draw_package_structure)
export(fill_description)
export(get_all_created_funs)
export(get_package_structure)
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## New features

- `draw_the_tree()` along with `get_package_structure()` allows to draw the package structure with
- `draw_package_structure()` along with `get_package_structure()` allows to draw the package structure with
all functions created in each R file, and whether they are exported (#189)
- `rename_flat_file()` allows to rename a flat file, and deals with config and inflated files
- `deprecate_flat_file()` helps properly deprecate a flat file, modifies the config file
Expand Down
8 changes: 4 additions & 4 deletions R/get_package_structure.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#' \dontrun{
#' # This only works inside a 'fusen' built package
#' pkg_structure <- get_package_structure()
#' draw_the_tree(pkg_structure)
#' draw_package_structure(pkg_structure)
#' }
#'
#' # Example with a dummy package
Expand All @@ -36,7 +36,7 @@
#'
#' # Works with classical package
#' pkg_structure <- get_package_structure()
#' draw_the_tree(pkg_structure)
#' draw_package_structure(pkg_structure)
#' })
#'
#' usethis::with_project(dummypackage, {
Expand All @@ -50,7 +50,7 @@
#' )
#'
#' pkg_structure <- get_package_structure()
#' draw_the_tree(pkg_structure)
#' draw_package_structure(pkg_structure)
#' })
get_package_structure <- function(
config_file,
Expand Down Expand Up @@ -164,7 +164,7 @@ get_package_structure <- function(
#' @export
#' @rdname get_package_structure
#'
draw_the_tree <- function(structure_list, silent = FALSE) {
draw_package_structure <- function(structure_list, silent = FALSE) {
if (missing(structure_list)) {
structure_list <- get_package_structure(silent = silent)
}
Expand Down
2 changes: 1 addition & 1 deletion R/inflate-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ knitr::opts_chunk$set(
)
```
```{r setup}
```{r}
library(.{pkgname}.)
```
',
Expand Down
4 changes: 3 additions & 1 deletion R/inflate.R
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,9 @@ inflate <- function(pkg = ".", flat_file,


# Restart RStudio
if (needs_restart) {
is_rstudio <- Sys.getenv("RSTUDIO") == "1"

if (needs_restart & is_rstudio) {
cli::cat_rule("RStudio restart needed")
getFromNamespace("restart_rstudio", "usethis")("A restart of RStudio is required to activate the Build pane")
}
Expand Down
40 changes: 20 additions & 20 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ knitr::include_graphics("man/figures/fusen_inflate_functions.png")

_Fill the flat Rmd (or qmd) template with everything in one place and {fusen} will inflate the identified parts in the correct package files and directories._

> The {fusen} Rmarkdown template encourages users to fill their documentation and tests at the same time of writing their functions code. Thanks to the R package structure used by {fusen}, you can built a robust workflow or R package. {fusen} simplifies and reduces the number of steps towards a full R package.
> The {fusen} Rmarkdown template encourages users to fill their documentation and tests at the same time of writing their functions code. Thanks to the R package structure used by {fusen}, you can build a robust workflow or R package. {fusen} simplifies and reduces the number of steps towards a full R package.
> After that, your {pkgdown} documentation website is one command away to be shared with all your users.
This {fusen} package is a real-world example of {fusen} use as it was itself created from the flat templates available in `"dev/"` folder in its GitHub repository.
This {fusen} package is a real-world example of {fusen} use as it is itself created from the flat templates available in `"dev/"` folder in its GitHub repository. You can have a look at its architecture in the [Readme of the "dev" directory](https://github.com/ThinkR-open/fusen/blob/main/dev/README.md).

## Installation

Expand All @@ -49,20 +49,15 @@ install.packages("fusen")
> *Full documentation for the CRAN version is here: https://thinkr-open.github.io/fusen/*

You can install the development version of {fusen} from GitHub:
You can install the development version of {fusen} from r-universe or GitHub:

```{r, eval=FALSE}
# From r-universe.dev (No need for GITHUB_PAT)
options(repos = c(
thinkropen = "https://thinkr-open.r-universe.dev",
CRAN = "https://cloud.r-project.org"
))
# Download and install {fusen} in R
install.packages("fusen")
install.packages("fusen", repos = c("https://thinkr-open.r-universe.dev", "https://cloud.r-project.org"))
# With {remotes} using GitHub API - Need for GITHUB_PAT
# install.packages("remotes")
remotes::install_github("ThinkR-open/fusen")
# Or with {pak} using GitHub API - Need for GITHUB_PAT
# install.packages("pak")
pak::pak("ThinkR-open/fusen")
```
> *Full documentation for the development version is here: https://thinkr-open.github.io/fusen/dev/*
Expand Down Expand Up @@ -144,19 +139,23 @@ _Note that the `"flat*.Rmd"` files created with templates `full` and `teaching`

There is a dedicated vignette to answer this: https://thinkr-open.github.io/fusen/articles/Maintain-packages-with-fusen.html

- **Option 1**: Modifications are only added to the "flat_template.Rmd" file, which then is inflated to update all packages files
- **Option 2**: Modifications are realized in the package files directly, and the "flat_template.Rmd" file must be protected from any use.
- **Option 1**: After a first inflate of your flat file, you can continue developing in the "flat_template.Rmd" file, and then inflate it using `fusen::inflate_all()`
- **Option 2**: After you're done with inflating, you can decide to deprecate your flat file with `fusen::deprecate_flat_file()` and develop in the package files directly, as for any other R package. 'fusen' has no impact on the structure of a classical package once inflated.

> Advice: Use git as soon as possible, this will avoid losing your work if you made some modifications in the wrong place
> Advice : Use git as soon as possible, this will avoid losing your work if you made some modifications in the wrong place
> Advice: Show the package structure with `fusen::draw_package_structure()` in a "dev/Readme.md" file to help developers
## Who is {fusen} for?

When you write a Rmarkdown file (or a vignette), you create a documentation for your analysis (or package). Inside, you write some functions, you test your functions with examples and you maybe write some unit tests to verify the outputs. This is even more true if you follow this guide : ['Rmd first': When development starts with documentation](https://rtask.thinkr.fr/when-development-starts-with-documentation/)
After that, you need to move your functions and scripts in the correct place. Let {fusen} do that for you!
If you mind about documentation for your users and tests for your maintainers, {fusen} is for you. Start writing documentation and tests while you conceive your functionalities, so that there are directly available for your users and maintainers.

Indeed, when you write a Rmarkdown file (or a vignette), you create a documentation for your analysis (or package). When you write some functions, you check your functions with examples and you maybe write some unit tests to verify the outputs. This is even more true if you follow this guide : ['Rmd first': When development starts with documentation](https://rtask.thinkr.fr/when-development-starts-with-documentation/)
Write them all in the same file while you explore the possibilities and let {fusen} store them in the right place for you!

*{fusen} is first addressed to people who never wrote a package before* but know how to write a Rmarkdown file. Understanding package infrastructure and correctly settling it can be frightening. This package may help them do the first step!
*{fusen} was first addressed to people who never wrote a package before* and know how to write a Rmarkdown file. Understanding package infrastructure and correctly settling it can be frightening. This package may help them do the first step!

*{fusen} is also addressed to more advanced developers who are fed up with switching* between R files, tests files, vignettes. In particular, when changing arguments of a function, we need to change examples, unit tests in multiple places. Here, you can do it in one place. No risk to forget one. Think also about code review: everything related to one function is at the same place.
*{fusen} is also addressed to more advanced developers who care about their users and the sustainability of their products, and are fed up with switching* between R files, tests files, vignettes while they prototype their functions. In particular, when changing arguments of a function, we need to change examples, unit tests in multiple places. Here, you can do it in one place. No risk to forget one. Think also about code review: everything related to one function is at the same place.

## Q&A : All tips and tricks of a {fusen} template

Expand All @@ -169,12 +168,13 @@ After that, you need to move your functions and scripts in the correct place. Le
- How to create a vignette with different title and Index Entry?
- How not to create a vignette ?
- How to get a pre-filled template for a specific function name ?
- How to Inflate multiple flat files ?
- How to inflate multiple flat files ?
- How to store multiple functions in a unique R file ?
- How to read dataset that I usually put in “tests/testthat/” for my unit tests?
- Can I load all functions of the current flat file during development without having to `inflate()`?
- Can I inflate a Quarto qmd file?
- Can I use {fusen} with {golem}?
- How can I know if R files were created from a flat or not ?

=> See vignette Tips and Tricks: https://thinkr-open.github.io/fusen/articles/tips-and-tricks.html

Expand Down
80 changes: 46 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@ and directories.*

> The {fusen} Rmarkdown template encourages users to fill their
> documentation and tests at the same time of writing their functions
> code. Thanks to the R package structure used by {fusen}, you can built
> code. Thanks to the R package structure used by {fusen}, you can build
> a robust workflow or R package. {fusen} simplifies and reduces the
> number of steps towards a full R package.
> After that, your {pkgdown} documentation website is one command away
> to be shared with all your users.
This {fusen} package is a real-world example of {fusen} use as it was
This {fusen} package is a real-world example of {fusen} use as it is
itself created from the flat templates available in `"dev/"` folder in
its GitHub repository.
its GitHub repository. You can have a look at its architecture in the
[Readme of the “dev”
directory](https://github.com/ThinkR-open/fusen/blob/main/dev/README.md).

## Installation

Expand All @@ -48,20 +50,16 @@ install.packages("fusen")
> *Full documentation for the CRAN version is here:
> <https://thinkr-open.github.io/fusen/>*
You can install the development version of {fusen} from GitHub:
You can install the development version of {fusen} from r-universe or
GitHub:

``` r
# From r-universe.dev (No need for GITHUB_PAT)
options(repos = c(
thinkropen = "https://thinkr-open.r-universe.dev",
CRAN = "https://cloud.r-project.org"
))
# Download and install {fusen} in R
install.packages("fusen")
install.packages("fusen", repos = c("https://thinkr-open.r-universe.dev", "https://cloud.r-project.org"))

# With {remotes} using GitHub API - Need for GITHUB_PAT
# install.packages("remotes")
remotes::install_github("ThinkR-open/fusen")
# Or with {pak} using GitHub API - Need for GITHUB_PAT
# install.packages("pak")
pak::pak("ThinkR-open/fusen")
```

> *Full documentation for the development version is here:
Expand Down Expand Up @@ -180,38 +178,51 @@ for your chunks.
There is a dedicated vignette to answer this:
<https://thinkr-open.github.io/fusen/articles/Maintain-packages-with-fusen.html>

- **Option 1**: Modifications are only added to the
“flat\_template.Rmd” file, which then is inflated to update all
packages files
- **Option 2**: Modifications are realized in the package files
directly, and the “flat\_template.Rmd” file must be protected from
any use.
- **Option 1**: After a first inflate of your flat file, you can
continue developing in the “flat\_template.Rmd” file, and then
inflate it using `fusen::inflate_all()`
- **Option 2**: After you’re done with inflating, you can decide to
deprecate your flat file with `fusen::deprecate_flat_file()` and
develop in the package files directly, as for any other R package.
‘fusen’ has no impact on the structure of a classical package once
inflated.

> Advice : Use git as soon as possible, this will avoid losing your work
> Advice: Use git as soon as possible, this will avoid losing your work
> if you made some modifications in the wrong place
> Advice: Show the package structure with
> `fusen::draw_package_structure()` in a “dev/Readme.md” file to help
> developers
## Who is {fusen} for?

When you write a Rmarkdown file (or a vignette), you create a
documentation for your analysis (or package). Inside, you write some
functions, you test your functions with examples and you maybe write
If you mind about documentation for your users and tests for your
maintainers, {fusen} is for you. Start writing documentation and tests
while you conceive your functionalities, so that there are directly
available for your users and maintainers.

Indeed, when you write a Rmarkdown file (or a vignette), you create a
documentation for your analysis (or package). When you write some
functions, you check your functions with examples and you maybe write
some unit tests to verify the outputs. This is even more true if you
follow this guide : [‘Rmd first’: When development starts with
documentation](https://rtask.thinkr.fr/when-development-starts-with-documentation/)
After that, you need to move your functions and scripts in the correct
place. Let {fusen} do that for you\!
Write them all in the same file while you explore the possibilities and
let {fusen} store them in the right place for you\!

*{fusen} is first addressed to people who never wrote a package before*
but know how to write a Rmarkdown file. Understanding package
*{fusen} was first addressed to people who never wrote a package before*
and know how to write a Rmarkdown file. Understanding package
infrastructure and correctly settling it can be frightening. This
package may help them do the first step\!

*{fusen} is also addressed to more advanced developers who are fed up
with switching* between R files, tests files, vignettes. In particular,
when changing arguments of a function, we need to change examples, unit
tests in multiple places. Here, you can do it in one place. No risk to
forget one. Think also about code review: everything related to one
function is at the same place.
*{fusen} is also addressed to more advanced developers who care about
their users and the sustainability of their products, and are fed up
with switching* between R files, tests files, vignettes while they
prototype their functions. In particular, when changing arguments of a
function, we need to change examples, unit tests in multiple places.
Here, you can do it in one place. No risk to forget one. Think also
about code review: everything related to one function is at the same
place.

## Q\&A : All tips and tricks of a {fusen} template

Expand All @@ -224,14 +235,15 @@ function is at the same place.
- How to create a vignette with different title and Index Entry?
- How not to create a vignette ?
- How to get a pre-filled template for a specific function name ?
- How to Inflate multiple flat files ?
- How to inflate multiple flat files ?
- How to store multiple functions in a unique R file ?
- How to read dataset that I usually put in “tests/testthat/” for my
unit tests?
- Can I load all functions of the current flat file during development
without having to `inflate()`?
- Can I inflate a Quarto qmd file?
- Can I use {fusen} with {golem}?
- How can I know if R files were created from a flat or not ?

\=\> See vignette Tips and Tricks:
<https://thinkr-open.github.io/fusen/articles/tips-and-tricks.html>
Expand Down
4 changes: 3 additions & 1 deletion dev/README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ output: github_document

# Here is a map of the architecture of the 'fusen' project

The _keep_ section is for independent files, which were not issued from a flat file.

```{r, message=FALSE, results='asis'}
pkgload::load_all()
usethis::with_project(here::here(), {
draw_the_tree(silent = TRUE)
fusen::draw_package_structure(silent = TRUE)
})
```
Loading

0 comments on commit 9cffedf

Please sign in to comment.