You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: vignettes/Maintain-packages-with-fusen.Rmd
+47-1Lines changed: 47 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ Your first `inflate()` may not directly work as expected. In this case, you can
57
57
58
58
59
59
60
-
##What about packages already built the old way ?
60
+
# What about packages already built the old way ?
61
61
62
62
The "dev_history.Rmd" template only modifies files related to functions presented inside the template.
63
63
This does not remove or modify previous functions, tests or vignettes, provided that names are different.
@@ -67,6 +67,52 @@ This does not remove or modify previous functions, tests or vignettes, provided
67
67
- If you want to add new functionnalities, correctly documented and tested, you can use {fusen}. This will not delete previous work.
68
68
- Use the "Option 2" above to continue after the development of your functionnality
69
69
70
+
## Let's try to convince package developers with an example
71
+
72
+
- Install {fusen} : `install.packages("fusen")`
73
+
- Open a project for **one of your already existing package**
74
+
+ Commit your previous state if you are afraid of {fusen}
75
+
+ If you are not sure enough to do it on an existing package, then follow the guide in ["How to use fusen"](https://thinkr-open.github.io/fusen/articles/How-to-use-fusen.html)
76
+
- Run in the Console : `fusen::add_dev_history(name = "additional")`
77
+
+ A Rmd file appears in "dev/dev_history.Rmd". Open it.
78
+
- Add a new function in the `function` chunk. For instance:
79
+
```{r, eval=FALSE}
80
+
#' My median
81
+
#'
82
+
#' @param x Vector of Numeric values
83
+
#' @inheritParams stats::median
84
+
#'
85
+
#' @return
86
+
#' Median of vector x
87
+
#' @export
88
+
#'
89
+
#' @examples
90
+
my_median <- function(x, na.rm = TRUE) {
91
+
if (!is.numeric(x)) {stop("x should be numeric")}
92
+
stats::median(x, na.rm = na.rm)
93
+
}
94
+
```
95
+
- Add a corresponding example in the `example` chunk. For instance:
96
+
```{r, eval=FALSE}
97
+
my_median(1:12)
98
+
```
99
+
- Add a corresponding unit test in the `test` chunk. For instance:
100
+
```{r, eval=FALSE}
101
+
test_that("my_median works properly and show error if needed", {
102
+
expect_true(my_median(1:12) == 6.5)
103
+
expect_error(my_median("text"))
104
+
})
105
+
```
106
+
- Run command of the last chunk: `fusen::inflate(rmd = "dev/dev_history.Rmd")`
107
+
+ This will run {attachment} behind the scene and may modify the list of dependencies in the DESCRIPTION file accordingly. Use `fusen::inflate(rmd = "dev/dev_history.Rmd", document = FALSE)` to avoid that.
108
+
+ This will also run `devtools::check()`. Use `fusen::inflate(rmd = "dev/dev_history.Rmd", check = FALSE)` to avoid that.
109
+
110
+
**That's it!**
111
+
You added a new function in your package, along with example, test and a new vignette:
0 commit comments