22
33# ' @rdname add_flat_template
44# ' @export
5- add_additional <- function (pkg = " ." ,
6- dev_dir = " dev" ,
7- flat_name = " additional" ,
8- overwrite = FALSE ,
9- open = TRUE ) {
5+ add_additional <- function (
6+ pkg = " ." ,
7+ dev_dir = " dev" ,
8+ flat_name = " additional" ,
9+ overwrite = FALSE ,
10+ open = TRUE
11+ ) {
1012 add_flat_template(
1113 template = " additional" ,
1214 pkg = pkg ,
@@ -19,11 +21,13 @@ add_additional <- function(pkg = ".",
1921
2022# ' @rdname add_flat_template
2123# ' @export
22- add_minimal_flat <- function (pkg = " ." ,
23- dev_dir = " dev" ,
24- flat_name = " minimal" ,
25- overwrite = FALSE ,
26- open = TRUE ) {
24+ add_minimal_flat <- function (
25+ pkg = " ." ,
26+ dev_dir = " dev" ,
27+ flat_name = " minimal" ,
28+ overwrite = FALSE ,
29+ open = TRUE
30+ ) {
2731 add_flat_template(
2832 template = " minimal_flat" ,
2933 pkg = pkg ,
@@ -36,11 +40,13 @@ add_minimal_flat <- function(pkg = ".",
3640
3741# ' @rdname add_flat_template
3842# ' @export
39- add_minimal_package <- function (pkg = " ." ,
40- dev_dir = " dev" ,
41- flat_name = " minimal" ,
42- overwrite = FALSE ,
43- open = TRUE ) {
43+ add_minimal_package <- function (
44+ pkg = " ." ,
45+ dev_dir = " dev" ,
46+ flat_name = " minimal" ,
47+ overwrite = FALSE ,
48+ open = TRUE
49+ ) {
4450 add_flat_template(
4551 template = " minimal_package" ,
4652 pkg = pkg ,
@@ -53,11 +59,13 @@ add_minimal_package <- function(pkg = ".",
5359
5460# ' @rdname add_flat_template
5561# ' @export
56- add_full <- function (pkg = " ." ,
57- dev_dir = " dev" ,
58- flat_name = " full" ,
59- overwrite = FALSE ,
60- open = TRUE ) {
62+ add_full <- function (
63+ pkg = " ." ,
64+ dev_dir = " dev" ,
65+ flat_name = " full" ,
66+ overwrite = FALSE ,
67+ open = TRUE
68+ ) {
6169 add_flat_template(
6270 template = " full" ,
6371 pkg = pkg ,
@@ -70,10 +78,12 @@ add_full <- function(pkg = ".",
7078
7179# ' @rdname add_flat_template
7280# ' @export
73- add_dev_history <- function (pkg = " ." ,
74- dev_dir = " dev" ,
75- overwrite = FALSE ,
76- open = TRUE ) {
81+ add_dev_history <- function (
82+ pkg = " ." ,
83+ dev_dir = " dev" ,
84+ overwrite = FALSE ,
85+ open = TRUE
86+ ) {
7787 add_flat_template(
7888 template = " dev_history" ,
7989 pkg = pkg ,
@@ -86,10 +96,16 @@ add_dev_history <- function(pkg = ".",
8696
8797flat_template_choices <- c(
8898 " full" ,
89- " minimal_package" , " minpkg" ,
90- " minimal_flat" , " minflat" , " add" , " additional" ,
91- " teach" , " teaching" ,
92- " dev_history" , " dev"
99+ " minimal_package" ,
100+ " minpkg" ,
101+ " minimal_flat" ,
102+ " minflat" ,
103+ " add" ,
104+ " additional" ,
105+ " teach" ,
106+ " teaching" ,
107+ " dev_history" ,
108+ " dev"
93109)
94110
95111create_fusen_choices <- c(" full" , " minimal" , " teaching" , " dev_history" )
@@ -156,17 +172,20 @@ create_fusen_choices <- c("full", "minimal", "teaching", "dev_history")
156172# ' # add new flat template for teaching (a reduced full template)
157173# ' add_flat_template("teaching")
158174# ' }
159- add_flat_template <- function (template = c(" full" , " minimal_package" , " minimal_flat" , " additional" , " teaching" , " dev_history" ),
160- pkg = " ." ,
161- dev_dir = " dev" ,
162- flat_name = NULL ,
163- overwrite = FALSE ,
164- open = TRUE ) {
175+ add_flat_template <- function (
176+ template = c(" full" , " minimal_package" , " minimal_flat" , " additional" , " teaching" , " dev_history" ),
177+ pkg = " ." ,
178+ dev_dir = " dev" ,
179+ flat_name = NULL ,
180+ overwrite = FALSE ,
181+ open = TRUE
182+ ) {
165183 project_name <- get_pkg_name(pkg = pkg )
166184
167185 if (project_name != asciify_name(project_name , to_pkg = TRUE )) {
168186 stop(
169- " Please rename your project/directory with: `" , asciify_name(project_name , to_pkg = TRUE ),
187+ " Please rename your project/directory with: `" ,
188+ asciify_name(project_name , to_pkg = TRUE ),
170189 " ` as a package name should only contain letters, numbers and dots."
171190 )
172191 }
@@ -207,7 +226,8 @@ add_flat_template <- function(template = c("full", "minimal_package", "minimal_f
207226 }
208227 flat_name <- paste0(
209228 " flat_" ,
210- asciify_name(gsub(" [.]Rmd$" , " " , flat_name [1 ])), " .Rmd"
229+ asciify_name(gsub(" [.]Rmd$" , " " , flat_name [1 ])),
230+ " .Rmd"
211231 )
212232
213233 pkg <- normalizePath(pkg )
@@ -227,8 +247,10 @@ add_flat_template <- function(template = c("full", "minimal_package", "minimal_f
227247 n <- length(list.files(full_dev_dir , pattern = " ^flat_.*[.]Rmd" ))
228248 dev_file_path <- file.path(full_dev_dir , paste0(file_path_sans_ext(flat_name ), " _" , n + 1 , " .Rmd" ))
229249 message(
230- flat_name , " already exists. New flat file is renamed '" ,
231- basename(dev_file_path ), " '. Use overwrite = TRUE, if you want to " ,
250+ flat_name ,
251+ " already exists. New flat file is renamed '" ,
252+ basename(dev_file_path ),
253+ " '. Use overwrite = TRUE, if you want to " ,
232254 " overwrite the existing file or rename it."
233255 )
234256 }
@@ -239,29 +261,33 @@ add_flat_template <- function(template = c("full", "minimal_package", "minimal_f
239261
240262 lines_template [grepl(" <my_package_name>" , lines_template )] <-
241263 gsub(
242- " <my_package_name>" , project_name ,
264+ " <my_package_name>" ,
265+ project_name ,
243266 lines_template [grepl(" <my_package_name>" , lines_template )]
244267 )
245268
246269 # Change flat_template file name
247270 # _inflate
248271 lines_template [grepl(" dev/flat_template.Rmd" , lines_template )] <-
249272 gsub(
250- " dev/flat_template.Rmd" , file.path(dev_dir , dev_name ),
273+ " dev/flat_template.Rmd" ,
274+ file.path(dev_dir , dev_name ),
251275 lines_template [grepl(" dev/flat_template.Rmd" , lines_template )]
252276 )
253277 # _title
254278 lines_template [grepl(" flat_template.Rmd" , lines_template )] <-
255279 gsub(
256- " flat_template.Rmd" , dev_name ,
280+ " flat_template.Rmd" ,
281+ dev_name ,
257282 lines_template [grepl(" flat_template.Rmd" , lines_template )]
258283 )
259284
260285 # Change my_fun to fun_name
261286 if (! is.na(fun_name )) {
262287 lines_template [grepl(" my_fun" , lines_template )] <-
263288 gsub(
264- " my_fun" , fun_name ,
289+ " my_fun" ,
290+ fun_name ,
265291 lines_template [grepl(" my_fun" , lines_template )]
266292 )
267293 }
0 commit comments