Skip to content

Commit 94eb946

Browse files
more s4 mthd dmtn fixes
1 parent 947c864 commit 94eb946

4 files changed

Lines changed: 53 additions & 22 deletions

File tree

R/fn_write.R

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ write_abbr_lup <- function (seed_lup = NULL, short_name_chr = NA_character_, lon
5757
return(pkg_dss_tb)
5858
}
5959
#' Write all function documentation
60-
#' @description write_all_fn_dmt() is a Write function that writes a file to a specified local directory. Specifically, this function implements an algorithm to write all function documentation. The function is called for its side effects and does not return a value. WARNING: This function writes R scripts to your local environment. Make sure to only use if you want this behaviour
60+
#' @description write_all_fn_dmt() is a Write function that writes a file to a specified local directory. Specifically, this function implements an algorithm to write all function documentation. The function returns a S4 methods (a list).
6161
#' @param pkg_setup_ls Package setup (a list)
6262
#' @param fns_env_ls Functions (a list of environments)
6363
#' @param document_unexp_lgl Document unexported (a logical vector), Default: F
6464
#' @param fns_dmt_tb Functions documentation (a tibble), Default: deprecated()
65-
#' @return NULL
65+
#' @return a S4 methods (a list)
6666
#' @rdname write_all_fn_dmt
6767
#' @export
6868
#' @importFrom lifecycle is_present deprecate_warn
@@ -104,6 +104,10 @@ write_all_fn_dmt <- function (pkg_setup_ls, fns_env_ls, document_unexp_lgl = F,
104104
devtools::document()
105105
devtools::load_all()
106106
}
107+
else {
108+
s4_mthds_ls <- NULL
109+
}
110+
return(s4_mthds_ls)
107111
}
108112
#' Write all tibbles in tibbles ready4 S4 to comma separated variables files
109113
#' @description write_all_tbs_in_tbs_r4_to_csvs() is a Write function that writes a file to a specified local directory. Specifically, this function implements an algorithm to write all tibbles in tibbles ready4 s4 to comma separated variables files. The function is called for its side effects and does not return a value. WARNING: This function writes R scripts to your local environment. Make sure to only use if you want this behaviour
@@ -207,7 +211,7 @@ write_and_doc_ds <- function (db_df, overwrite_1L_lgl = T, db_1L_chr, title_1L_c
207211
#' @export
208212
#' @importFrom lifecycle is_present deprecate_warn
209213
#' @importFrom ready4 write_new_dirs
210-
#' @importFrom purrr walk2 map flatten_chr discard map2
214+
#' @importFrom purrr map2 map flatten_chr discard
211215
#' @importFrom devtools load_all build_manual
212216
#' @importFrom utils data
213217
#' @importFrom dplyr filter pull
@@ -257,15 +261,16 @@ write_and_doc_fn_fls <- function (pkg_setup_ls, make_pdfs_1L_lgl = T, update_pkg
257261
"/User")))
258262
fns_env_ls <- read_fns(make_undmtd_fns_dir_chr(paste0(pkg_setup_ls$initial_ls$path_to_pkg_rt_1L_chr,
259263
"/data-raw"), drop_empty_1L_lgl = T))
260-
purrr::walk2(list(paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,
264+
s4_mthds_ls_ls <- purrr::map2(list(paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,
261265
"/Developer"), paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,
262266
"/User")), c(T, F), ~{
263-
write_all_fn_dmt(pkg_setup_ls, fns_env_ls = fns_env_ls,
267+
s4_mthds_ls <- write_all_fn_dmt(pkg_setup_ls, fns_env_ls = fns_env_ls,
264268
document_unexp_lgl = .y)
265269
write_ns_imps_to_desc(dev_pkgs_chr = dev_pkgs_chr, incr_ver_1L_lgl = .y)
266270
devtools::load_all()
267271
if (make_pdfs_1L_lgl)
268272
devtools::build_manual(path = .x)
273+
s4_mthds_ls
269274
})
270275
if (update_pkgdown_1L_lgl) {
271276
datasets_chr <- utils::data(package = get_dev_pkg_nm(pkg_setup_ls$initial_ls$path_to_pkg_rt_1L_chr),
@@ -302,6 +307,15 @@ write_and_doc_fn_fls <- function (pkg_setup_ls, make_pdfs_1L_lgl = T, update_pkg
302307
fns_chr <- dplyr::filter(pkg_setup_ls$subsequent_ls$fns_dmt_tb,
303308
inc_for_main_user_lgl & file_pfx_chr == .x) %>%
304309
dplyr::pull(fns_chr)
310+
if (.x == "mthd_" & !is.null(s4_mthds_ls_ls)) {
311+
fns_chr <- c(fns_chr, s4_mthds_ls_ls[[2]]$mthds_ls %>%
312+
purrr::map2(names(s4_mthds_ls_ls[[2]]$mthds_ls),
313+
~{
314+
mthd_nm_1L_chr <- .y
315+
s4_cls_nms_chr <- names(.x)
316+
paste0(mthd_nm_1L_chr, "-", s4_cls_nms_chr)
317+
}) %>% purrr::flatten_chr()) %>% sort()
318+
}
305319
if (length(fns_chr) > 0) {
306320
txt_chr <- c(paste0("- title: \"", .y, "\""),
307321
"- contents:", paste0(" - ", fns_chr))

_pkgdown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
home:
22
links:
33
- text: Manual - User (PDF)
4-
href: https://dataverse.harvard.edu/api/access/datafile/5342646
4+
href: https://dataverse.harvard.edu/api/access/datafile/5342665
55
- text: Manual - Developer (PDF)
6-
href: https://dataverse.harvard.edu/api/access/datafile/5342645
6+
href: https://dataverse.harvard.edu/api/access/datafile/5342664
77
- text: Project website
88
href: https://www.ready4-dev.com/
99
development:

data-raw/fns/write.R

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,13 @@ write_all_fn_dmt <- function(pkg_setup_ls,
8989
devtools::load_all()
9090
if(length(pkg_setup_ls$subsequent_ls$s4_fns_ls)>0){
9191
s4_mthds_ls <- rlang::exec(pkg_setup_ls$subsequent_ls$s4_fns_ls$fn,
92-
!!!pkg_setup_ls$subsequent_ls$s4_fns_ls$args_ls)
92+
!!!pkg_setup_ls$subsequent_ls$s4_fns_ls$args_ls)
9393
devtools::document()
9494
devtools::load_all()
95+
}else{
96+
s4_mthds_ls <- NULL
9597
}
98+
return(s4_mthds_ls)
9699
}
97100
write_all_tbs_in_tbs_r4_to_csvs <- function(tbs_r4,
98101
r4_name_1L_chr,
@@ -225,19 +228,20 @@ write_and_doc_fn_fls <- function(pkg_setup_ls,
225228
fns_env_ls <- read_fns(make_undmtd_fns_dir_chr(paste0(pkg_setup_ls$initial_ls$path_to_pkg_rt_1L_chr,
226229
"/data-raw"),
227230
drop_empty_1L_lgl = T))
228-
purrr::walk2(list(paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,"/Developer"),
229-
paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,"/User")),
230-
c(T,F),
231-
~ {
232-
write_all_fn_dmt(pkg_setup_ls,
233-
fns_env_ls = fns_env_ls,
234-
document_unexp_lgl = .y)
235-
write_ns_imps_to_desc(dev_pkgs_chr = dev_pkgs_chr,
236-
incr_ver_1L_lgl = .y)
237-
devtools::load_all()
238-
if(make_pdfs_1L_lgl)
239-
devtools::build_manual(path = .x)
240-
})
231+
s4_mthds_ls_ls <- purrr::map2(list(paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,"/Developer"),
232+
paste0(pkg_setup_ls$subsequent_ls$path_to_dmt_dir_1L_chr,"/User")),
233+
c(T,F),
234+
~ {
235+
s4_mthds_ls <- write_all_fn_dmt(pkg_setup_ls,
236+
fns_env_ls = fns_env_ls,
237+
document_unexp_lgl = .y)
238+
write_ns_imps_to_desc(dev_pkgs_chr = dev_pkgs_chr,
239+
incr_ver_1L_lgl = .y)
240+
devtools::load_all()
241+
if(make_pdfs_1L_lgl)
242+
devtools::build_manual(path = .x)
243+
s4_mthds_ls
244+
})
241245
if(update_pkgdown_1L_lgl){
242246
datasets_chr <- utils::data(package = get_dev_pkg_nm(pkg_setup_ls$initial_ls$path_to_pkg_rt_1L_chr),
243247
envir = environment())$results[,3]
@@ -285,6 +289,16 @@ write_and_doc_fn_fls <- function(pkg_setup_ls,
285289
~{
286290
fns_chr <- dplyr::filter(pkg_setup_ls$subsequent_ls$fns_dmt_tb, inc_for_main_user_lgl & file_pfx_chr == .x) %>%
287291
dplyr::pull(fns_chr)
292+
if(.x=="mthd_" & !is.null(s4_mthds_ls_ls)){
293+
fns_chr <- c(fns_chr,
294+
s4_mthds_ls_ls[[2]]$mthds_ls %>%
295+
purrr::map2(names(s4_mthds_ls_ls[[2]]$mthds_ls),
296+
~{
297+
mthd_nm_1L_chr <- .y
298+
s4_cls_nms_chr <- names(.x)
299+
paste0(mthd_nm_1L_chr,"-",s4_cls_nms_chr)
300+
}) %>% purrr::flatten_chr()) %>% sort()
301+
}
288302
if(length(fns_chr)>0){
289303
txt_chr <- c( paste0("- title: \"",.y,"\""),
290304
"- contents:",

man/write_all_fn_dmt.Rd

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)