Skip to content

Commit d959bd4

Browse files
authored
Merge pull request #16 from A2-ai/config
Config logic for 0.3.1
2 parents 8788358 + 1ee3b30 commit d959bd4

36 files changed

+142
-117
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: reportifyr
22
Title: Reproducible Reporting Made Simple with R
3-
Version: 0.3.0
3+
Version: 0.3.1
44
Authors@R: c(
55
person("Jacob", "Dumbleton", , "[email protected]", role = c("aut", "cre")),
66
person("Matthew", "Smith", , "[email protected]", role = "aut"),

NEWS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# reportifyr 0.3.1
2+
## Minor Improvements
3+
4+
* If `config_yaml` is left `NULL` for the following functions, a default `config.yaml` file bundled with `reportifyr` is used instead:
5+
* `add_footnotes()`
6+
* `add_plots()`
7+
* `add_tables()`
8+
* `build_report()`
9+
* `finalize_document()`
10+
* `remove_tables_figures_footnotes()`
11+
12+
* `validate_input_args()` and `validate_alt_text_magic_strings()` no longer take a `config_yaml` argument.
13+
14+
* Function and argument descriptions introduced or expanded on in 0.3.0 have been updated for clarity and understanding.
15+
116
# reportifyr 0.3.0
217
## New Features
318

R/add_footnotes.R

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ add_footnotes <- function(
7878
browser()
7979
}
8080

81-
validate_input_args(docx_in, docx_out, config_yaml)
81+
validate_input_args(docx_in, docx_out)
8282
validate_docx(docx_in, config_yaml)
8383
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
8484

@@ -142,7 +142,7 @@ add_footnotes <- function(
142142

143143
if (!is.null(config_yaml)) {
144144
if (!validate_config(config_yaml)) {
145-
stop("Invalid confi yaml. Please fix")
145+
stop("Invalid config yaml. Please fix")
146146
}
147147
log4r::info(
148148
.le$logger,
@@ -158,11 +158,10 @@ add_footnotes <- function(
158158
paste0("Using default config file: ", config_yaml)
159159
)
160160
}
161-
if (!is.null(config_yaml)) {
162-
log4r::info(.le$logger, "Adding config.yaml to args")
163-
fig_args <- c(fig_args, "-c", config_yaml)
164-
tab_args <- c(tab_args, "-c", config_yaml)
165-
}
161+
log4r::info(.le$logger, "Adding config.yaml to args")
162+
fig_args <- c(fig_args, "-c", config_yaml)
163+
tab_args <- c(tab_args, "-c", config_yaml)
164+
166165
paths <- get_venv_uv_paths()
167166
log4r::debug(.le$logger, "Running figure footnotes script")
168167
tryCatch(

R/add_plots.R

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @param docx_in The file path to the input `.docx` file.
55
#' @param docx_out The file path to the output `.docx` file to save to.
66
#' @param figures_path The file path to the figures directory.
7-
#' @param config_yaml The path to config.yaml file that controls figure dimensions
7+
#' @param config_yaml The file path to the `config.yaml`. Default is `NULL`, a default `config.yaml` bundled with the `reportifyr` package is used.
88
#' @param fig_width A global controller. The figure width in inches. Default is `NULL`. If `NULL`, the width is determined by the figure's pixel dimensions.
99
#' @param fig_height A global controller. The figure height in inches. Default is `NULL`. If `NULL`, the height is determined by the figure's pixel dimensions.
1010
#' @param debug Debug.
@@ -59,7 +59,7 @@ add_plots <- function(
5959
browser()
6060
}
6161

62-
validate_input_args(docx_in, docx_out, config_yaml)
62+
validate_input_args(docx_in, docx_out)
6363
validate_docx(docx_in, config_yaml)
6464
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
6565

@@ -85,11 +85,14 @@ add_plots <- function(
8585
figures_path
8686
)
8787

88-
if (!is.null(config_yaml)) {
89-
args <- c(args, "-c", config_yaml)
90-
log4r::info(.le$logger, paste0("config yaml set: ", config_yaml))
88+
if (is.null(config_yaml)) {
89+
config_yaml <- system.file("extdata", "config.yaml", package = "reportifyr")
90+
log4r::info(.le$logger, paste0("using built-in config.yaml: ", config_yaml))
9191
}
9292

93+
args <- c(args, "-c", config_yaml)
94+
log4r::info(.le$logger, paste0("config yaml set: ", config_yaml))
95+
9396
if (!is.null(fig_width)) {
9497
args <- c(args, "-w", fig_width)
9598
log4r::info(.le$logger, paste0("Figure width set: ", fig_width))

R/add_plots_alt_text.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#' add_plots_alt_text()
1+
#' Inserts alt text for figures within a Microsoft Word file.
22
#'
3-
#' @param docx_in path to document
4-
#' @param docx_out path to output document with figures alt text
5-
#' @param debug boolean turns on browser
3+
#' @param docx_in The file path to the input `.docx` file.
4+
#' @param docx_out The file path to the output `.docx` file to save to.
5+
#' @param debug Debug.
66
#'
77
#' @export
88
#'
@@ -22,7 +22,7 @@ add_plots_alt_text <- function(
2222
browser()
2323
}
2424

25-
validate_input_args(docx_in, docx_out, NULL)
25+
validate_input_args(docx_in, docx_out)
2626

2727
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
2828

R/add_tables.R

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' @param docx_in The file path to the input `.docx` file.
55
#' @param docx_out The file path to the output `.docx` file to save to.
66
#' @param tables_path The file path to the tables and associated metadata directory.
7-
#' @param config_yaml The path to config.yaml file that controls figure dimensions
7+
#' @param config_yaml The file path to the `config.yaml`. Default is `NULL`, a default `config.yaml` bundled with the `reportifyr` package is used.
88
#' @param debug Debug.
99
#'
1010
#' @export
@@ -45,7 +45,12 @@ add_tables <- function(
4545
browser()
4646
}
4747

48-
validate_input_args(docx_in, docx_out, config_yaml)
48+
if (is.null(config_yaml)) {
49+
config_yaml <- system.file("extdata", "config.yaml", package = "reportifyr")
50+
log4r::info(.le$logger, paste0("using built-in config.yaml: ", config_yaml))
51+
}
52+
53+
validate_input_args(docx_in, docx_out)
4954
validate_docx(docx_in, config_yaml)
5055
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
5156

R/add_tables_alt_text.R

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#' add_tables_alt_text
1+
#' Inserts alt text for tables within a Microsoft Word file.
22
#'
3-
#' @param docx_in path to input document
4-
#' @param docx_out path to output document
5-
#' @param debug boolean for turning on debugging
3+
#' @param docx_in The file path to the input `.docx` file.
4+
#' @param docx_out The file path to the output `.docx` file to save to.
5+
#' @param debug Debug.
66
#'
77
#' @export
88
#'
@@ -22,7 +22,7 @@ add_tables_alt_text <- function(
2222
browser()
2323
}
2424

25-
validate_input_args(docx_in, docx_out, NULL)
25+
validate_input_args(docx_in, docx_out)
2626

2727
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
2828

R/build_report.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ build_report <- function(
5050
) {
5151
log4r::debug(.le$logger, "Starting build_report function")
5252

53-
validate_input_args(docx_in, docx_out, config_yaml)
53+
if (is.null(config_yaml)) {
54+
config_yaml <- system.file("extdata", "config.yaml", package = "reportifyr")
55+
log4r::info(.le$logger, paste0("using built-in config.yaml: ", config_yaml))
56+
}
57+
58+
validate_input_args(docx_in, docx_out)
5459
validate_docx(docx_in, config_yaml)
5560
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
5661

R/finalize_document.R

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @description Reads in a `.docx` file and returns a finalized version with magic strings and bookmarks removed.
44
#' @param docx_in The file path to the input `.docx` file.
55
#' @param docx_out The file path to the output `.docx` file to save to. Default is `NULL`. If `NULL`, `docx_out` is assigned `doc_dirs$doc_final` using `make_doc_dirs(docx_in = docx_in)`.
6-
#' @param config_yaml The file path to the `config.yaml`.
6+
#' @param config_yaml The file path to the `config.yaml`. Default is `NULL`, a default `config.yaml` bundled with the `reportifyr` package is used.
77
#'
88
#' @export
99
#'
@@ -45,7 +45,7 @@
4545
finalize_document <- function(
4646
docx_in,
4747
docx_out = NULL,
48-
config_yaml
48+
config_yaml = NULL
4949
) {
5050
tictoc::tic()
5151
log4r::debug(.le$logger, "Starting finalize_document function")
@@ -59,7 +59,11 @@ finalize_document <- function(
5959
)
6060
}
6161

62-
validate_input_args(docx_in, docx_out, config_yaml)
62+
if (is.null(config_yaml)) {
63+
config_yaml <- system.file("extdata", "config.yaml", package = "reportifyr")
64+
}
65+
66+
validate_input_args(docx_in, docx_out)
6367
validate_docx(docx_in, config_yaml)
6468
log4r::info(.le$logger, paste0("Output document path set: ", docx_out))
6569

R/initialize_report_project.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
#' @param project_dir The file path to the main project directory
44
#' where the directory structure will be created.
55
#' The directory must already exist; otherwise, an error will be thrown.
6-
#' @param report_dir_name The directory name for where reports will be saved,
7-
#' default NULL will use "report"
8-
#' @param outputs_dir_name The directory name for where artifacts will be saved,
9-
#' default NULL will use "OUTPUTS"
6+
#' @param report_dir_name The directory name for where reports will be saved.
7+
#' Default is `NULL`. If `NULL`, `report` will be used.
8+
#' @param outputs_dir_name The directory name for where artifacts will be saved.
9+
#' Default is `NULL`. If `NULL`, `OUTPUTS` will be used.
1010
#'
1111
#' @export
1212
#'

0 commit comments

Comments
 (0)