Skip to content

Commit 19ec8f6

Browse files
authored
Merge pull request #108 from ThinkR-open/extend
Extend
2 parents f2b0a2d + 323939e commit 19ec8f6

File tree

9 files changed

+383
-19
lines changed

9 files changed

+383
-19
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: fusen
22
Title: Build a Package from Rmarkdown File
3-
Version: 0.2.4.9000
3+
Version: 0.3.0
44
Authors@R: c(
55
person("Sebastien", "Rochette", , "sebastien@thinkr.fr", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0002-1565-9313")),

NEWS.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# fusen 0.2.4.9000
1+
# fusen 0.3.0
22

33
## Breaking changes
44

@@ -9,9 +9,11 @@
99

1010
## Major changes
1111

12+
* Check included now uses `devtools::check()` instead of `rcmdcheck()`
1213
* Avoid creating vignette with `inflate(vignette_name = NA)`
1314
* Decide whether or not to open vignette when inflate with `inflate(open_vignette = FALSE)`
1415
* Improve documentation included in flat templates to reflect changes in using dev_history file
16+
* Add Rstudio Addin to insert a new flat template
1517
* Add Rstudio Addin to insert chunks for new function (@ColinFay)
1618
* Deal with `\dontrun{}` in example chunks
1719
* Allow short names for chunks: dev, fun, ex, test

R/addins.R

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#' Addin to add a new template
2+
#' @noRd
3+
addin_add_template <- function() {
4+
if (
5+
requireNamespace("rstudioapi") &&
6+
rstudioapi::isAvailable()
7+
) {
8+
# This will allow to interactively have the function name
9+
if (rstudioapi::hasFun("showPrompt")) {
10+
template <- rstudioapi::showPrompt(
11+
title = "Enter the flat template type",
12+
message = "e.g. add = additional; min = minimal;",
13+
default = "additional")
14+
} else {
15+
template <- readline("Enter the flat template type: ")
16+
}
17+
if (rstudioapi::hasFun("showPrompt")) {
18+
flat_name <- rstudioapi::showPrompt(
19+
title = "Choose the function name",
20+
message = "Name is used to pre-fill the template",
21+
default = "my_fun")
22+
} else {
23+
flat_name <- readline("Enter the function name: ")
24+
}
25+
26+
add_flat_template(template = template, flat_name = flat_name)
27+
}
28+
}

R/inflate.R

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ inflate <- function(pkg = ".", flat_file = file.path("dev", "flat_full.Rmd"),
6161
overwrite = "ask", ...) {
6262

6363
if (!is.null(list(...)[["name"]])) {
64-
warning(paste0("The `name` argument to `inflate()` is deprecated since {fusen} version 0.2.5,",
64+
warning(paste0("The `name` argument to `inflate()` is deprecated since {fusen} version 0.3.0,",
6565
" and will be removed in a future version.",
6666
"\nPlease use `vignette_name = '", list(...)[["name"]],"'` instead.\n"))
6767
vignette_name <- list(...)[["name"]]
6868
}
6969
if (!is.null(list(...)[["rmd"]])) {
70-
warning(paste0("The `rmd` argument to `inflate()` is deprecated since {fusen} version 0.2.5,",
70+
warning(paste0("The `rmd` argument to `inflate()` is deprecated since {fusen} version 0.3.0,",
7171
" and will be removed in a future version.",
7272
"\nPlease use `flat_file = '", list(...)[["rmd"]],"'` instead.\n"))
7373
flat_file <- list(...)[["rmd"]]

dev/dev_history.R

+6-3
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,13 @@ urlchecker::url_update()
203203
# check on other distributions
204204
# _rhub
205205
devtools::check_rhub()
206+
rhub::platforms()
206207
rhub::check_on_windows(check_args = "--force-multiarch")
207-
rhub::check_on_solaris()
208-
rhub::check(platform = "debian-clang-devel")
209-
rhub::check(platform = "fedora-clang-devel")
208+
rhub::check_on_solaris(show_status = FALSE)
209+
rhub::check(platform = "debian-clang-devel", show_status = FALSE)
210+
rhub::check(platform = "debian-gcc-devel", show_status = FALSE)
211+
rhub::check(platform = "fedora-clang-devel", show_status = FALSE)
212+
rhub::check(platform = "macos-m1-bigsur-release", show_status = FALSE)
210213
rhub::check_for_cran(show_status = FALSE)
211214

212215
# Run locally in Docker

inst/rstudio/addins.dcf

+4
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,7 @@ Description: Create {fusen} chunks inside your Rmd
33
Binding: add_fusen_chunks
44
Interactive: false
55

6+
Name: Add {fusen} flat template
7+
Description: Create a new flat template file in your project
8+
Binding: addin_add_template
9+
Interactive: true

inst/tests-templates/dev-template-two-fun-same-title.Rmd

+2-11
Original file line numberDiff line numberDiff line change
@@ -163,21 +163,12 @@ test_that("my_fun_rdname1 works properly and show error if needed", {
163163
## fun_rdname2
164164

165165
```{r function-fun_rdname2}
166-
#' My fun_rdname2
167-
#'
168-
#' @param x Vector of Numeric values
169-
#' @inheritParams stats::median
170-
#'
171166
#' @rdname same_rdname
172-
#' @return
173-
#' Median of vector x
167+
#' @importFrom stats median
174168
#' @export
175-
#'
176-
#' @examples
177-
#' my_fun_rdname2(2:20)
178169
my_fun_rdname2 <- function(x, na.rm = TRUE) {
179170
if (!is.numeric(x)) {stop("x should be numeric")}
180-
stats::median(x, na.rm = na.rm)
171+
median(x, na.rm = na.rm)
181172
}
182173
```
183174

tests/testthat/test-inflate.R

+34-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ usethis::with_project(dummypackage, {
495495
),
496496
regexp = NA)
497497
# Check error
498-
skip_on_os(os = c("windows", "solaris"))
498+
# skip_on_os(os = c("windows", "solaris"))
499+
skip_on_cran()
499500

500501
# Could not find function "my_norox2"
501502
expect_error(rcmdcheck::rcmdcheck(dummypackage, quiet = TRUE,
@@ -555,6 +556,7 @@ for (pkgname in c("full", "teaching", "minimal")) {
555556
# Do not check inside check if on CRAN
556557
skip_on_os(os = c("windows", "solaris"))
557558

559+
558560
# If this check is run inside a not "--as-cran" check, then it wont work as expected
559561
check_out <- rcmdcheck::rcmdcheck(path_foosen, quiet = TRUE,
560562
args = c("--no-manual"))
@@ -568,6 +570,7 @@ for (pkgname in c("full", "teaching", "minimal")) {
568570
# ‘MASS’
569571
# print(" -- warnings --")
570572
# print(check_out[["warnings"]])
573+
skip_on_cran()
571574
expect_true(length(check_out[["notes"]]) == 0)
572575
} else {
573576
print(" ==== Interactive ====")
@@ -699,6 +702,7 @@ usethis::with_project(dummypackage, {
699702
# ‘MASS’
700703
# print(" -- warnings --")
701704
# print(check_out[["warnings"]])
705+
skip_on_cran()
702706
expect_true(length(check_out[["notes"]]) == 0)
703707
} else {
704708
expect_error(
@@ -936,6 +940,12 @@ usethis::with_project(dummypackage, {
936940
r_lines <- readLines(my_rdname1_file)
937941
expect_true(any(grepl("my_fun_rdname1 <- function", r_lines)))
938942
expect_true(any(grepl("my_fun_rdname2 <- function", r_lines)))
943+
expect_equal(r_lines[13:15],
944+
c("#' @examples" , "#' my_fun_rdname1(2:20)", "#' my_fun_rdname1(1:12)"))
945+
expect_equal(r_lines[21:25],
946+
c("#' @rdname same_rdname" ,
947+
"#' @importFrom stats median", "#' @export",
948+
"#' @examples", "#' my_fun_rdname2(1:12)" ))
939949
# Same chunk name
940950
r_lines <- readLines(my_chunk1_file)
941951
expect_true(any(grepl("my_fun_chunk1 <- function", r_lines)))
@@ -947,6 +957,29 @@ usethis::with_project(dummypackage, {
947957
# @filename cleaned in R file
948958
expect_false(any(grepl("@filename", r_lines)))
949959

960+
# -- doc files --
961+
my_median_file <- file.path(dummypackage, "man", "my_median.Rd")
962+
expect_true(file.exists(my_median_file))
963+
my_median2_file <- file.path(dummypackage, "man", "my_median2.Rd")
964+
expect_true(file.exists(my_median2_file))
965+
# chunk name
966+
my_median_file <- file.path(dummypackage, "man", "my_fun_chunk1.Rd")
967+
expect_true(file.exists(my_median_file))
968+
my_median2_file <- file.path(dummypackage, "man", "my_fun_chunk2.Rd")
969+
expect_true(file.exists(my_median2_file))
970+
# rdname
971+
my_median_file <- file.path(dummypackage, "man", "my_fun_rdname1.Rd")
972+
expect_false(file.exists(my_median_file))
973+
my_median2_file <- file.path(dummypackage, "man", "my_fun_rdname2.Rd")
974+
expect_false(file.exists(my_median2_file))
975+
my_median3_file <- file.path(dummypackage, "man", "same_rdname.Rd")
976+
expect_true(file.exists(my_median3_file))
977+
# filename
978+
my_median_file <- file.path(dummypackage, "man", "my_fun_filename1.Rd")
979+
expect_true(file.exists(my_median_file))
980+
my_median2_file <- file.path(dummypackage, "man", "my_fun_filename2.Rd")
981+
expect_true(file.exists(my_median2_file))
982+
950983
# -- test files --
951984
my_median_file <- file.path(dummypackage, "tests", "testthat", "test-my_median.R")
952985
expect_true(file.exists(my_median_file))

0 commit comments

Comments
 (0)