Skip to content

Commit 290b439

Browse files
committed
reforked
Merge branch 'main' of https://github.com/iaugusty/formatters # Conflicts: # DESCRIPTION # NEWS.md
2 parents cb8b4b5 + 06f8a1f commit 290b439

21 files changed

+264
-33
lines changed

.Rbuildignore

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
^renv$
2+
^renv\.lock$
13
(^|/)[#][^/]*#$
24
(^|/)\.[#][^/]*$
35
^.*\.Rproj$

.github/workflows/check.yaml

+21
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,27 @@ jobs:
4040
checking top-level files .* NOTE
4141
unit-test-report-brand: >-
4242
https://raw.githubusercontent.com/insightsengineering/hex-stickers/main/thumbs/formatters.png
43+
r-cmd-non-cran:
44+
name: R CMD Check (non-CRAN) 🧬
45+
uses: insightsengineering/r.pkg.template/.github/workflows/build-check-install.yaml@main
46+
secrets:
47+
REPO_GITHUB_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}
48+
with:
49+
enforce-note-blocklist: true
50+
publish-unit-test-report-gh-pages: false
51+
junit-xml-comparison: false
52+
concurrency-group: non-cran
53+
disable-unit-test-reports: true
54+
skip-r-cmd-install: true
55+
note-blocklist: |
56+
checking dependencies in R code .* NOTE
57+
checking R code for possible problems .* NOTE
58+
checking examples .* NOTE
59+
checking Rd line widths .* NOTE
60+
checking S3 generic/method consistency .* NOTE
61+
checking Rd .usage sections .* NOTE
62+
checking for unstated dependencies in vignettes .* NOTE
63+
checking top-level files .* NOTE
4364
coverage:
4465
name: Coverage 📔
4566
uses: insightsengineering/r.pkg.template/.github/workflows/test-coverage.yaml@main

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ repos:
1313
- checkmate
1414
- grid
1515
- htmltools
16+
- lifecycle
1617
# codemeta must be above use-tidy-description when both are used
1718
# - id: codemeta-description-updated
1819
- id: use-tidy-description

DESCRIPTION

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: formatters
22
Title: ASCII Formatting for Values and Tables
3-
Version: 0.5.6.9003
4-
Date: 2024-04-29
3+
Version: 0.5.6.9006
4+
Date: 2024-05-27
55
Authors@R: c(
66
person("Gabriel", "Becker", , "[email protected]", role = "aut",
77
comment = "original creator of the package"),
@@ -25,23 +25,23 @@ Depends:
2525
Imports:
2626
checkmate (>= 2.1.0),
2727
grid,
28-
htmltools (>= 0.5.3)
28+
htmltools (>= 0.5.3),
29+
lifecycle (>= 0.2.0)
2930
Suggests:
3031
dplyr (>= 1.0.9),
31-
gt (>= 0.7.0),
32+
gt (>= 0.10.0),
3233
huxtable (>= 2.0.0),
3334
knitr (>= 1.42),
34-
lifecycle (>= 0.2.0),
3535
r2rtf (>= 0.3.2),
36-
rmarkdown (>= 2.19),
36+
rmarkdown (>= 2.23),
3737
stringi (>= 1.6),
3838
testthat (>= 3.0.4),
3939
withr (>= 2.0.0)
4040
VignetteBuilder:
4141
knitr
4242
Config/Needs/verdepcheck: mllg/checkmate, rstudio/htmltools,
43-
tidyverse/dplyr, rstudio/gt, hughjonesd/huxtable, yihui/knitr,
44-
r-lib/lifecycle, Merck/r2rtf, rstudio/rmarkdown, gagolews/stringi,
43+
r-lib/lifecycle, tidyverse/dplyr, rstudio/gt, hughjonesd/huxtable,
44+
yihui/knitr, Merck/r2rtf, rstudio/rmarkdown, gagolews/stringi,
4545
r-lib/testthat, r-lib/withr
4646
Config/Needs/website: insightsengineering/nesttemplate
4747
Encoding: UTF-8

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ importFrom(grid,textGrob)
158158
importFrom(grid,unit)
159159
importFrom(htmltools,tagList)
160160
importFrom(htmltools,tags)
161+
importFrom(lifecycle,deprecated)
161162
importFrom(stats,na.omit)
162163
importFrom(tools,file_ext)
163164
importFrom(utils,capture.output)

NEWS.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
## formatters 0.5.6.9003
1+
## formatters 0.5.6.9006
2+
3+
* Deprecate `width`, `height` and `fontsize` arguments of `export_as_pdf()` using `lifecycle` package.
4+
* Add `lifecycle` badge files for documentation.
5+
* Fixed bug causing recursive appending of page number text during pagination.
26

37
## formatters 0.5.6
48
* Added "N=xx" format and unit test for it.
@@ -50,7 +54,7 @@
5054
* Reduced the amount of spelling issues.
5155
* New generic `getter` and `setter` for `align` (`obj_align` and `obj_align<-`).
5256
* New `fmt_config` class to bundle together `format`, `na_str`, and `align` instructions.
53-
* Reverting default for alignment (from `NULL` to `center`) and `na_str`
57+
* Reverting default for alignment (from `NULL` to `center`) and `na_str`
5458
from `NULL` to `"NA"`. This affects only `rlistings`, where the new default takes effect.
5559

5660
## formatters 0.5.0
@@ -66,7 +70,7 @@
6670
* `MatrixPrintForm` objects now pay closer attention to referential footnote information than they did in the past.
6771
* `MatrixPrintForm` objects infer detailed referential footnote information from their `strings` element for backward compatibility.
6872
* Fix to test that failed on old Windows CRAN machine due to imperfect UTF support there.
69-
* If `lpp` and `cpp` in pagination or exporter functions are assigned to `NULL`, no pagination in the vertical or horizontal direction happens, respectively.
73+
* If `lpp` and `cpp` in pagination or exporter functions are assigned to `NULL`, no pagination in the vertical or horizontal direction happens, respectively.
7074
* The new default of `NA_integer_` for `lpp` and `cpp` now means those values should be inferred from page size.
7175
* Added `hexSticker` logo.
7276

@@ -111,10 +115,10 @@
111115
* adding wrapping of titles, subtitles, and footers.
112116
* `page_lcpp` function now provided to map page size and font combinations to lines
113117
and characters per page.
114-
* `getters` and `setters` for the components of `MatrixPrintForm` objects are now exported
118+
* `getters` and `setters` for the components of `MatrixPrintForm` objects are now exported
115119
(i.e., `mf_spans` and friends).
116120
* `na_str` can now be length >1, and is matched in position to NAs in that case.
117-
* `format_value` now returns solely the `na_str` value when all-NA values are formatted with certain formats
121+
* `format_value` now returns solely the `na_str` value when all-NA values are formatted with certain formats
118122
(currently`"(N=xx)"`, `">999.9"`, `">999.99"`, `"x.xxxx | (<0.0001)"`)
119123

120124
## formatters 0.3.3
@@ -147,7 +151,7 @@
147151
## formatters 0.3.0
148152
* add exported `default_hsep` function for use her and in reverse-dependencies (incl `rtables`)
149153
* format_value now respects `na_str` even when format is `xx` (previously it returned `"NA"` always)
150-
* rename `linesep` argument to `hsep` in `toString` generic signature
154+
* rename `linesep` argument to `hsep` in `toString` generic signature
151155
* add `indent_size` argument to `matrix_form` generic signature
152156
* add a number of `"__ (__)"` (no pct) formats in response to #23
153157
* Switch to `testthat` as testing framework

R/mpf_exporters.R

+14-12
Original file line numberDiff line numberDiff line change
@@ -504,13 +504,13 @@ export_as_pdf <- function(x,
504504
landscape = FALSE,
505505
pg_width = page_dim(page_type)[if (landscape) 2 else 1],
506506
pg_height = page_dim(page_type)[if (landscape) 1 else 2],
507-
width = NULL,
508-
height = NULL, # passed to pdf()
507+
width = lifecycle::deprecated(),
508+
height = lifecycle::deprecated(),
509509
margins = c(4, 4, 4, 4),
510510
min_siblings = 2,
511511
font_family = "Courier",
512512
font_size = 8,
513-
fontsize = font_size,
513+
fontsize = lifecycle::deprecated(),
514514
paginate = TRUE,
515515
page_num = default_page_number(),
516516
lpp = NULL,
@@ -534,19 +534,21 @@ export_as_pdf <- function(x,
534534
paginate <- TRUE
535535
}
536536

537-
gp_plot <- grid::gpar(fontsize = font_size, fontfamily = font_family)
538-
539-
if (!is.null(height)) {
540-
pg_height <- height
541-
}
542-
543-
if (!is.null(width)) {
537+
if (lifecycle::is_present(width)) {
538+
lifecycle::deprecate_warn("0.5.5", "export_as_pdf(width)", "export_as_pdf(pg_width)")
544539
pg_width <- width
545540
}
546-
547-
if (missing(font_size) && !missing(fontsize)) {
541+
if (lifecycle::is_present(height)) {
542+
lifecycle::deprecate_warn("0.5.5", "export_as_pdf(height)", "export_as_pdf(pg_height)")
543+
pg_height <- height
544+
}
545+
if (lifecycle::is_present(fontsize)) {
546+
lifecycle::deprecate_warn("0.5.5", "export_as_pdf(fontsize)", "export_as_pdf(font_size)")
548547
font_size <- fontsize
549548
}
549+
550+
gp_plot <- grid::gpar(fontsize = font_size, fontfamily = font_family)
551+
550552
pdf(file = file, width = pg_width, height = pg_height)
551553
on.exit(dev.off())
552554
grid::grid.newpage()

R/package.R

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
#'
33
#' Package to format tables and listings in a flexible way.
44
#'
5+
#' @keywords internal
56
"_PACKAGE"
67

8+
#' @importFrom htmltools tags tagList
9+
#' @importFrom lifecycle deprecated
710
#' @importFrom stats na.omit
811
#' @importFrom utils head tail localeToCharset
9-
#' @importFrom htmltools tags tagList
1012
#' @import checkmate
1113
NULL

R/pagination.R

+3-2
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ paginate_to_mpfs <- function(obj,
10921092
return(mpfs)
10931093
}
10941094

1095-
if (!is.null(page_num)) {
1095+
if (!is.null(page_num) && (length(prov_footer(obj)) == 0 || !grepl(page_num, prov_footer(obj), perl = TRUE))) {
10961096
# Only adding a line for pagination -> lpp - 1 would have worked too
10971097
prov_footer(obj) <- c(prov_footer(obj), page_num)
10981098
}
@@ -1167,7 +1167,8 @@ paginate_to_mpfs <- function(obj,
11671167
colwidths = colwidths,
11681168
min_siblings = min_siblings,
11691169
nosplitin = nosplitin,
1170-
verbose = verbose
1170+
verbose = verbose,
1171+
page_num = page_num
11711172
)
11721173
return(unlist(deep_pag, recursive = FALSE))
11731174
} else if (has_page_title(fpags[[1]])) {

inst/WORDLIST

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ decrementing
1515
formatter
1616
funder
1717
getters
18-
glyphs
1918
mandatorily
2019
paginations
2120
pathing

man/export_as_pdf.Rd

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/figures/lifecycle-archived.svg

+21
Loading

man/figures/lifecycle-defunct.svg

+21
Loading

man/figures/lifecycle-deprecated.svg

+21
Loading
+21
Loading

man/figures/lifecycle-maturing.svg

+21
Loading

man/figures/lifecycle-questioning.svg

+21
Loading
+21
Loading

0 commit comments

Comments
 (0)