Skip to content

Commit

Permalink
Merge pull request #272 from ThinkR-open/main-268
Browse files Browse the repository at this point in the history
Fix linting errors in generated R files and bump version to 0.6.0.9005
  • Loading branch information
VincentGuyader authored Jan 30, 2025
2 parents 1048139 + 56129e4 commit 062ca6a
Show file tree
Hide file tree
Showing 47 changed files with 116 additions and 93 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/R-CMD-check-devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ jobs:
remotes::install_github("ThinkR-open/lightparser", upgrade = "always")
shell: Rscript {0}

- name: Check
env:
_R_CHECK_CRAN_INCOMING_REMOTE_: false
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: ${{ github.event_name == 'workflow_dispatch' && inputs.debug_enabled }} # Works on 'main' only
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master, production-cran]
branches: [main, master, production-cran, main-268-test_x86]
pull_request:
branches: [main, master, production-cran]

Expand All @@ -23,6 +23,7 @@ jobs:
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: macos-13, r: 'release'} #x86_64
# - {os: ubuntu-20.04, r: '3.6'}
# - {os: ubuntu-20.04, r: '3.5'} # with usethis >2.2

Expand Down
12 changes: 7 additions & 5 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
Package: fusen
Title: Build a Package from Rmarkdown Files
Version: 0.6.0.9004
Version: 0.7.1
Authors@R: c(
person("Sebastien", "Rochette", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-1565-9313")),
person("Yohann", "Mansiaux", , "[email protected]", role = "aut"),
person("Sebastien", "Rochette", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0002-1565-9313", "creator")),
person("Vincent", "Guyader", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-0671-9270")),
person("Yohann", "Mansiaux", , "[email protected]", role = "aut"),
person("ThinkR", role = "cph")
)
Description: Use Rmarkdown First method to build your package. Start your
Expand Down Expand Up @@ -50,7 +52,7 @@ Suggests:
withr
VignetteBuilder:
knitr
Config/fusen/version: 0.6.0.9004
Config/fusen/version: 0.7.0
Config/testthat/edition: 3
Config/testthat/parallel: false
Encoding: UTF-8
Expand Down
17 changes: 10 additions & 7 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
# fusen (development version 0.6.0.9003)
# fusen 0.7.1

## New features
## Bug fix

- `inflate` and `inflate_all()` proposes to compute the package code coverage using `covr::package_coverage()` using the `codecov` parameter (default is FALSE)
- Skip some tests on MacOS on CRAN to avoid errors

# fusen (development version 0.6.0.9002)
# fusen 0.7.0

## New features

- Adding `sepuku()`, allowing to remove all traces of a fusen-related files and tags in the package (#257 #258 #259) @ymansiaux
- `inflate` and `inflate_all()` proposes to compute the package code coverage using `covr::package_coverage()` using the `codecov` parameter (default is FALSE)
- RStudio Addin "Fusen : Add fusen chunks" as well as `fusen::add_fusen_chunks()` add a development chunk in complement to the "function", "example" and "test" chunks already provided (#255) @ymansiaux

## Minor changes

# fusen (development version 0.6.0.9001)
- Add `# nolint: line_length_linter` in created files to avoid line length linter warnings (#278) @LBeaulaton

## New features
## Bug fixes

- Adding `sepuku()`, allowing to remove all traces of a fusen-related files and tags in the package (#257 #258 #259) @ymansiaux
- Fix `grep()` calls in unit tests (#271) @statnmap

# fusen 0.6.0

Expand Down
2 changes: 1 addition & 1 deletion R/add_flat_template.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_create_flat.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_create_flat.Rmd: do not edit by hand # nolint: line_length_linter.

#' @rdname add_flat_template
#' @export
Expand Down
2 changes: 1 addition & 1 deletion R/build_fusen_chunks.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_addins.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_addins.Rmd: do not edit by hand # nolint: line_length_linter.

#' Add 'fusen' chunks
#'
Expand Down
2 changes: 1 addition & 1 deletion R/deprecate_flat_file.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_deal_with_flat_files.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_deal_with_flat_files.Rmd: do not edit by hand # nolint: line_length_linter.

#' Deprecate a flat file
#'
Expand Down
2 changes: 1 addition & 1 deletion R/get_all_created_funs.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_get_package_structure.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_get_package_structure.Rmd: do not edit by hand # nolint: line_length_linter.

#' Get all functions created in a R file
#'
Expand Down
2 changes: 1 addition & 1 deletion R/get_package_structure.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_get_package_structure.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_get_package_structure.Rmd: do not edit by hand # nolint: line_length_linter.

#' Get structure and information of a 'fusen' built package for developers
#'
Expand Down
2 changes: 1 addition & 1 deletion R/inflate-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ parse_test <- function(x, pkg, relative_flat_file) { # x <- rmd_test[1,]
}

lines <- c(
sprintf("# WARNING - Generated by {fusen} from %s: do not edit by hand\n", relative_flat_file),
sprintf("# WARNING - Generated by {fusen} from %s: do not edit by hand # nolint: line_length_linter.\n", relative_flat_file),
x[["code"]][[1]]
)
write_utf8(path = test_file, lines = lines)
Expand Down
2 changes: 1 addition & 1 deletion R/inflate.R
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ create_r_files <- function(fun_code, pkg, relative_flat_file) {
cli::cli_alert_warning(paste(basename(r_file), "has been overwritten"))
}
lines <- c(
sprintf("# WARNING - Generated by {fusen} from %s: do not edit by hand\n", relative_flat_file),
sprintf("# WARNING - Generated by {fusen} from %s: do not edit by hand # nolint: line_length_linter.\n", relative_flat_file),
unlist(fun_code[x, ][["code_example"]])
)
write_utf8(path = r_file, lines = lines)
Expand Down
2 changes: 1 addition & 1 deletion R/inflate_all.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_inflate_all.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_inflate_all.Rmd: do not edit by hand # nolint: line_length_linter.

#' Inflate all your flat files
#'
Expand Down
2 changes: 1 addition & 1 deletion R/inflate_all_utils.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_inflate_all_utils.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_inflate_all_utils.Rmd: do not edit by hand # nolint: line_length_linter.

#' This function evaluates whether flat files can or can not be inflated with `inflate_all()`
#'
Expand Down
2 changes: 1 addition & 1 deletion R/init_share_on_github.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_init_share_on_github.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_init_share_on_github.Rmd: do not edit by hand # nolint: line_length_linter.

#' Initiate GitHub to share your package on a website
#'
Expand Down
2 changes: 1 addition & 1 deletion R/pre_inflate_all_diagnosis_eval.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_inflate_all_utils.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_inflate_all_utils.Rmd: do not edit by hand # nolint: line_length_linter.

#' Eval message, warning and error from the diagnostic table
#'
Expand Down
2 changes: 1 addition & 1 deletion R/register_config_file.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_register_config_file.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_register_config_file.Rmd: do not edit by hand # nolint: line_length_linter.

#' Show in a table files that are not already registered in the yaml config file
#'
Expand Down
2 changes: 1 addition & 1 deletion R/rename_flat_file.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_deal_with_flat_files.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_deal_with_flat_files.Rmd: do not edit by hand # nolint: line_length_linter.

#' Rename a flat file
#'
Expand Down
8 changes: 4 additions & 4 deletions R/sepuku.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# WARNING - Generated by {fusen} from dev/flat_sepuku.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_sepuku.Rmd: do not edit by hand # nolint: line_length_linter.

#' Clean a package from fusen-related files and tags
#'
#' This function will delete all the flat files (i.e files listed in the fusen configuration file, as well as rmd or qmd files starting with "flat" in the "dev/" and "dev/flat_history" folders). It will also remove the fusen-related tags added by calls to `fusen::inflate()` in files located in the "R/", "tests/" and "vignettes/" folders. Finally, it will also remove the fusen configuration file if it exists.
#' This function will delete all the flat files (i.e files listed in the fusen configuration file, as well as Rmd or qmd files starting with "flat" in the "dev/" and "dev/flat_history" folders). It will also remove the fusen-related tags added by calls to `fusen::inflate()` in files located in the "R/", "tests/" and "vignettes/" folders. Finally, it will also remove the fusen configuration file if it exists.
#'
#' @param pkg Character. Path of the current package
#' @param force logical. whether to force the cleaning or not, without asking if the user is sure about making this operation (default: FALSE)
Expand Down Expand Up @@ -127,9 +127,9 @@ sepuku <- function(
config_file <- getOption("fusen.config_file", default = "dev/config_fusen.yaml")

if (!file.exists(config_file)) {
cli_alert_info("No fusen configuration file found. The flat files to be deleted will be identified as rmd or qmd files starting with 'flat' in the dev/ and dev/flat_history folders.")
cli_alert_info("No fusen configuration file found. The flat files to be deleted will be identified as Rmd or qmd files starting with 'flat' in the dev/ and dev/flat_history folders.")
} else {
cli_alert_info("A fusen configuration file was found. The flat files to be deleted will be identified as files listed in this configuration file as well as rmd or qmd files starting with 'flat' in the dev/ and dev/flat_history folders. The configuration file will also be deleted.")
cli_alert_info("A fusen configuration file was found. The flat files to be deleted will be identified as files listed in this configuration file as well as Rmd or qmd files starting with 'flat' in the dev/ and dev/flat_history folders. The configuration file will also be deleted.")
}

flat_files <- list_flat_files(pkg = pkg)
Expand Down
4 changes: 2 additions & 2 deletions R/sepuku_utils.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# WARNING - Generated by {fusen} from dev/flat_sepuku-utils.Rmd: do not edit by hand
# WARNING - Generated by {fusen} from dev/flat_sepuku-utils.Rmd: do not edit by hand # nolint: line_length_linter.

#' @importFrom yaml read_yaml
#' @noRd
Expand Down Expand Up @@ -49,7 +49,7 @@ list_flat_files_in_dev_folder <- function(

#' List all flat files present in the package
#'
#' Search for flat files listed in fusen config file, and for rmd and qmd files starting with "flat_" in dev/ folder, and dev/flat_history folder
#' Search for flat files listed in fusen config file, and for Rmd and qmd files starting with "flat_" in dev/ folder, and dev/flat_history folder
#'
#' @param pkg Path to package
#' @return a vector of flat files paths
Expand Down
3 changes: 2 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ _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**: 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.
- **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. You can even use `sepuku()` to remove all traces of 'fusen'.

> Advice: Use git as soon as possible, this will avoid losing your work if you made some modifications in the wrong place
Expand Down Expand Up @@ -175,6 +175,7 @@ Write them all in the same file while you explore the possibilities and let {fus
- 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 ?
- How can I get rid of everything related to 'fusen' in my package ?

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

Expand Down
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

<!-- badges: start -->

[![fusen status
Expand Down Expand Up @@ -174,7 +173,7 @@ There is a dedicated vignette to answer this:
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.
inflated. You can even use `sepuku()` to remove all traces of ‘fusen’.

> Advice: Use git as soon as possible, this will avoid losing your work
> if you made some modifications in the wrong place
Expand Down Expand Up @@ -233,6 +232,7 @@ place.
- 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 ?
- How can I get rid of everything related to ‘fusen’ in my package ?

=\> See vignette Tips and Tricks:
<https://thinkr-open.github.io/fusen/articles/tips-and-tricks.html>
Expand All @@ -250,12 +250,9 @@ in a specific way so that at the end, you can magically `inflate()` it
to let a nice package appear.

<details>

<summary>

Click here to fold your {fusen}…
</summary>

<img src="man/figures/fusen-fold-origami.gif" />
</details>

Expand Down
25 changes: 24 additions & 1 deletion dev/cran-comments-history.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# v0.7.1
## R CMD check results

A new error appeared on CRAN for x86-64 MacOS architecture after the release of v0.7.0
The present release fixes the problem

0 errors | 0 warnings | 0 note

* OK on GitHub Actions, rhub, winbuilder and macbuilder
* Fixes error on CRAN checks: "DESCRIPTION file does not exist"

# v0.7.0
## R CMD check results

0 errors | 0 warnings | 1 note

* Maintainer was changed for Vincent Guyader, instead Sébastien Rochette.
* OK on GitHub Actions, rhub, winbuilder and macbuilder
* Fixes error on CRAN checks: "invalid regular expression"




# v0.6.0
## R CMD check results

0 errors | 0 warnings | 1 note

* Maintainer email was changed for my personal address, instead of my professional one.
* OK on GitHub Actions, rhub, winbuilder and macbuilder

* Fixes notes on CRAN checks: "Lost braces; missing escapes or markup?"

# v0.5.2
## R CMD check results
Expand Down
4 changes: 3 additions & 1 deletion dev/flat_create_flat.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ output: html_document
editor_options:
chunk_output_type: console
inflate:
state: deprecated?
state: active
---

```{r development, include=FALSE}
Expand Down Expand Up @@ -632,6 +632,7 @@ for (template in all_templates) {
expect_true(sum(grepl(paste0("fusen::inflate\\(flat_file = \"dev/flat_", main_flat_file_name, ".Rmd\""), flat_lines)) == 1)
withr::with_dir(dummypackage4, {
skip_on_os(os = "mac", arch = "x86_64")
inflate_command <- paste0("fusen::inflate(flat_file = \"dev/flat_", main_flat_file_name, ".Rmd\", open_vignette = FALSE, check = FALSE)")
expect_error(suppressMessages(eval(parse(text = inflate_command))), regexp = NA)
})
Expand All @@ -640,6 +641,7 @@ for (template in all_templates) {
# Now try to inflates a second time
test_that("flat file inflates a second time", {
withr::with_dir(dummypackage4, {
skip_on_os(os = "mac", arch = "x86_64")
inflate_command_second <- paste0("fusen::inflate(flat_file = \"dev/flat_", main_flat_file_name, ".Rmd\", open_vignette = FALSE, check = FALSE, overwrite = TRUE)")
expect_error(suppressMessages(eval(parse(text = inflate_command_second))), regexp = NA)
})
Expand Down
2 changes: 1 addition & 1 deletion dev/flat_deal_with_flat_files.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ usethis::with_project(dummypackage, {

## Fully deprecate a flat file after inflate

'fusen' serves as a framework to ensure that developers prioritize end-users during the function development process. By employing 'fusen' within Rmd/Qmd files, developers can conceptualize their product and articulate their ideas in plain text before initiating any code. This approach encourages consideration of the package's users: their intended actions, and the potential impact on their experiences. Consequently, developers can draft function documentation prior to its implementation, thinking about explaining what's behind the black box, as well as reminding that this may end into the vignette.
'fusen' serves as a framework to ensure that developers prioritize end-users during the function development process. By employing 'fusen' within Rmd/qmd files, developers can conceptualize their product and articulate their ideas in plain text before initiating any code. This approach encourages consideration of the package's users: their intended actions, and the potential impact on their experiences. Consequently, developers can draft function documentation prior to its implementation, thinking about explaining what's behind the black box, as well as reminding that this may end into the vignette.

Additionally, 'fusen' offers a minimal template comprising 'function', 'doc', and 'test' components. We advocate for Test Driven Development (TDD), where writing tests precedes function implementation. This practice aids in function design and enables anticipation of future behavior.

Expand Down
6 changes: 3 additions & 3 deletions dev/flat_sepuku-utils.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ usethis::with_project(dummypackage, {
# Add licence
usethis::use_mit_license("John Doe")
test_that("list_flat_files_in_dev_folder works for rmd and qmd files in dev folder starting with flat", {
test_that("list_flat_files_in_dev_folder works for Rmd and qmd files in dev folder starting with flat", {
flat_file_with_bad_name <- "xxx_flat2.Rmd"
file.create(file.path(dummypackage, "dev", flat_file_with_bad_name))
Expand All @@ -191,7 +191,7 @@ usethis::with_project(dummypackage, {
)
})
test_that("list_flat_files_in_dev_folder works for rmd and qmd files in flat_history folder starting with flat", {
test_that("list_flat_files_in_dev_folder works for Rmd and qmd files in flat_history folder starting with flat", {
inflate(
pkg = dummypackage,
flat_file = flat_file1,
Expand Down Expand Up @@ -240,7 +240,7 @@ unlink(dummypackage, recursive = TRUE)
```{r function-list_flat_files}
#' List all flat files present in the package
#'
#' Search for flat files listed in fusen config file, and for rmd and qmd files starting with "flat_" in dev/ folder, and dev/flat_history folder
#' Search for flat files listed in fusen config file, and for Rmd and qmd files starting with "flat_" in dev/ folder, and dev/flat_history folder
#'
#' @param pkg Path to package
#' @return a vector of flat files paths
Expand Down
Loading

0 comments on commit 062ca6a

Please sign in to comment.