Skip to content

Commit 5319bea

Browse files
munoztd0Copilot
andauthored
export: mf_col_widths (#374)
`junco` uses `mf_col_widths`. To use a public, stable API and avoid relying on unexported internal symbols, can we consider exporting `mf_col_widths` in the next release? I have added a test for it. See -> johnsonandjohnson/junco#317 --------- Co-authored-by: Copilot <copilot@github.com>
1 parent b6d095d commit 5319bea

5 files changed

Lines changed: 26 additions & 0 deletions

File tree

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export("main_footer<-")
55
export("main_title<-")
66
export("mf_aligns<-")
77
export("mf_cinfo<-")
8+
export("mf_col_widths<-")
89
export("mf_colgap<-")
910
export("mf_display<-")
1011
export("mf_fontspec<-")
@@ -59,6 +60,7 @@ export(make_row_df)
5960
export(matrix_form)
6061
export(mf_aligns)
6162
export(mf_cinfo)
63+
export(mf_col_widths)
6264
export(mf_colgap)
6365
export(mf_display)
6466
export(mf_fontspec)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## formatters 0.5.12.9002
22

3+
* Export `mf_col_widths` accessor (`getter` and `setter`).
4+
35
## formatters 0.5.12
46
* Added `"default"` format label which behaves like `"xx"` in `format_value` but indicates formatting behavior can be inherited from parent structures in upstream code.
57
* `round_type = "sas"` no longer displays a negative sign when negative values are rounded to zero.

R/matrix_form.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,10 +625,14 @@ mf_col_paths <- function(mf) {
625625
}
626626
}
627627

628+
#' @export
629+
#' @rdname mpf_accessors
628630
mf_col_widths <- function(mf) {
629631
mf$col_widths
630632
}
631633

634+
#' @export
635+
#' @rdname mpf_accessors
632636
`mf_col_widths<-` <- function(mf, value) {
633637
if (!is.null(value) && length(value) != NCOL(mf_strings(mf))) {
634638
stop(

man/mpf_accessors.Rd

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
test_that("mf_col_widths getter and setter are available and work", {
2+
mf <- basic_matrix_form(mtcars)
3+
4+
# getter returns numeric vector
5+
cw <- mf_col_widths(mf)
6+
expect_true(is.numeric(cw))
7+
8+
# setter updates widths
9+
new <- rep(10L, NCOL(mf_strings(mf)))
10+
mf_col_widths(mf) <- new
11+
expect_equal(mf_col_widths(mf), new)
12+
})

0 commit comments

Comments
 (0)