How to use fusen

library(fusen)

All steps to create a package with {fusen} from one Rmd file

Create multiple "flat_xxx.Rmd" files with fusen::add_flat_template(template = "add") if needed

Fill your package Description

Fonction fill_description() requires the description of your package: What does it do? Who are the developers?
This will fill the DESCRIPTION file in the proper way.

fill_description(
  pkg = dummypackage,
  fields = list(
    Title = "Build A Package From Rmarkdown file",
    Description = paste("Use Rmarkdown First method to build your package.", 
                        "Start your package with documentation.", 
                        "Everything can be set from a Rmarkdown file in your project."),
    `Authors@R` = c(
      person("Sebastien", "Rochette", email = "sebastien@thinkr.fr", 
             role = c("aut", "cre"), comment = c(ORCID = "0000-0002-1565-9313")),
      person(given = "ThinkR", role = "cph")
    )
  )
)

Inflate your package from the flat Rmd template

You’re one inflate from flat paper to box. Build your package from the flat Rmd template using the inflate() command below.

After that, you can:

fusen::inflate(
  flat_file = "dev/flat_teaching.Rmd", 
  vignette_name = "Exploration of my Data",
  open_vignette = TRUE,
  document = TRUE,
  check = TRUE
)

Create a new package from command line directly, using a pre-defined template

# Create a new project
dummypackage <- tempfile(pattern = "dummy")

# {fusen} steps
dev_file <- create_fusen(dummypackage, template = "teaching", open = FALSE)
# Description
fusen::fill_description(pkg = dummypackage, fields = list(Title = "Dummy Package"))

# From inside the package
usethis::with_project(dummypackage, {
  # Define License with use_*_license()
  usethis::use_mit_license("Sébastien Rochette")
  
  # You may need to execute inflate() in the console directly
  fusen::inflate(pkg = dummypackage, 
                 flat_file = dev_file,
                 vignette_name = "Get started")
})

# Explore directory of the package
browseURL(dummypackage)

# Delete dummy package
unlink(dummypackage, recursive = TRUE)

Add a new “flat_template.Rmd” template in “dev/” directory

# Add an additional dev template
add_flat_template(template = "add", pkg = dummypackage)

There can be development actions

These are only included in the flat template file, their content will not be part of the package anywhere else.

Name the following chunk with {r development-something, eval=FALSE}

```{r development-inflate, eval=FALSE}
# Run but keep eval=FALSE to avoid infinite loop

usethis::use_mit_license("Sébastien Rochette")

# Execute in the console directly

fusen::inflate(flat_file = "dev/dev_history.Rmd")
```

Limitations