Skip to content

Commit

Permalink
Merge pull request #1830 from olivroy/re-export
Browse files Browse the repository at this point in the history
Re export `where()`, `any_of()`, `all_of()` + error early for absent footnote.
  • Loading branch information
rich-iannone authored Aug 16, 2024
2 parents 9736533 + ca5e5b5 commit 6b63c32
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 77 deletions.
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ S3method(to_output_location,default)
S3method(to_output_location,output_relative)
export("%>%")
export(adjust_luminance)
export(all_of)
export(any_of)
export(as_gtable)
export(as_latex)
export(as_raw_html)
Expand Down Expand Up @@ -244,18 +246,22 @@ export(vec_fmt_scientific)
export(vec_fmt_spelled_num)
export(vec_fmt_time)
export(web_image)
export(where)
import(rlang)
importFrom(dplyr,vars)
importFrom(htmltools,as.tags)
importFrom(htmltools,css)
importFrom(magrittr,"%>%")
importFrom(tidyselect,all_of)
importFrom(tidyselect,any_of)
importFrom(tidyselect,contains)
importFrom(tidyselect,ends_with)
importFrom(tidyselect,everything)
importFrom(tidyselect,matches)
importFrom(tidyselect,num_range)
importFrom(tidyselect,one_of)
importFrom(tidyselect,starts_with)
importFrom(tidyselect,where)
importFrom(xml2,`xml_attr<-`)
importFrom(xml2,`xml_text<-`)
importFrom(xml2,as_xml_document)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@

* Fixed an issue where `tab_spanner_delim()` would fail to resolve a duplicate id (@olivroy, #1821).

* `tidyselect::where()`, `tidyselect::all_of()`, `tidyselect::any_of()` are now re-exported by gt.

# gt 0.11.0

## New features
Expand Down
7 changes: 4 additions & 3 deletions R/dt_has_built.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ dt_has_built <- function(data) {

#nocov start

dt_has_built_assert <- function(data) {
dt_has_built_assert <- function(data, call = rlang::caller_env()) {

if (!dt_has_built(data = data)) {
if (!dt_has_built(data)) {
cli::cli_abort(c(
"The build hasn't yet occurred.",
"*" = "Call `build_data()` before retrieving."
))
),
call = caller_env())
}
}

Expand Down
4 changes: 2 additions & 2 deletions R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ extract_summary <- function(data) {

cli::cli_abort(c(
"There is no summary list to extract.",
"*" = "Use the `{.help [summary_rows](gt::summary_rows)}()` /
"*" = "Use the `{.help [summary_rows](gt::summary_rows)}()` /
`{.help [grand_summary_rows](gt::grand_summary_rows)}()` functions to
generate summaries."
))
Expand Down Expand Up @@ -409,7 +409,7 @@ extract_cells <- function(
data = data
)

if (!dt_has_built_get(data)) {
if (!dt_has_built(data)) {
#
# Partially build the gt table using the resolved `output` as the
# rendering context; this formats the body cells and applies merging
Expand Down
34 changes: 25 additions & 9 deletions R/reexports.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@
#
#------------------------------------------------------------------------------#


#' @importFrom dplyr vars
#' @export
dplyr::vars

#' @importFrom tidyselect starts_with
#' @export
tidyselect::starts_with
Expand All @@ -42,10 +37,6 @@ tidyselect::contains
#' @export
tidyselect::matches

#' @importFrom tidyselect one_of
#' @export
tidyselect::one_of

#' @importFrom tidyselect everything
#' @export
tidyselect::everything
Expand All @@ -54,6 +45,31 @@ tidyselect::everything
#' @export
tidyselect::num_range

#' @importFrom tidyselect all_of
#' @export
tidyselect::all_of

#' @importFrom tidyselect any_of
#' @export
tidyselect::any_of

#' @importFrom tidyselect where
#' @export
tidyselect::where

#' @importFrom htmltools css
#' @export
htmltools::css

#' @importFrom magrittr %>%
#' @export
magrittr::`%>%`

# TODO Avoid reexporting those helpers eventually -----
#' @importFrom dplyr vars
#' @export
dplyr::vars

#' @importFrom tidyselect one_of
#' @export
tidyselect::one_of
9 changes: 5 additions & 4 deletions R/tab_footnote.R
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,12 @@ tab_footnote <- function(
placement = c("auto", "right", "left")
) {

placement <- rlang::arg_match(placement)

# Perform input object validation
stop_if_not_gt_tbl(data = data)

placement <- rlang::arg_match(placement)
rlang::check_required(footnote)

if (is.null(locations)) {

# We need to invoke `dt_footnotes_add()` here (and not use
Expand Down Expand Up @@ -497,7 +498,7 @@ set_footnote.cells_column_labels <- function(
placement
) {

resolved <-
resolved <-
resolve_cells_column_labels(
data = data,
object = loc,
Expand Down Expand Up @@ -598,7 +599,7 @@ set_footnote.cells_body <- function(
placement
) {

resolved <-
resolved <-
resolve_cells_body(
data = data,
object = loc,
Expand Down
35 changes: 0 additions & 35 deletions R/utils_pipe.R

This file was deleted.

8 changes: 1 addition & 7 deletions R/utils_render_common.R
Original file line number Diff line number Diff line change
Expand Up @@ -744,13 +744,7 @@ get_number_of_visible_data_columns <- function(data) {
get_effective_number_of_columns <- function(data) {

# Check if the table has been built, return an error if that's not the case
if (!dt_has_built(data = data)) {

cli::cli_abort(
"The `get_effective_number_of_columns()` function can only be used on
gt objects that have tables 'built'."
)
}
dt_has_built_assert(data = data)

# Obtain the number of visible columns in the built table
n_data_cols <- get_number_of_visible_data_columns(data = data)
Expand Down
2 changes: 1 addition & 1 deletion R/utils_render_html.R
Original file line number Diff line number Diff line change
Expand Up @@ -1192,7 +1192,7 @@ create_body_component_h <- function(data) {
)

summary[[1]] <-
htmltools::HTML(gsub("^<tr>", paste0("<tr>", group_col_td), as.character(summary[[1]])))
htmltools::HTML(sub("^<tr>", paste0("<tr>", group_col_td), as.character(summary[[1]])))
}

summary
Expand Down
12 changes: 0 additions & 12 deletions man/pipe.Rd

This file was deleted.

8 changes: 7 additions & 1 deletion man/reexports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/performance-monitoring/dplyr-known-good.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "dplyr <-> data.table"
subtitle: "Notes I took while learning to use data.table"
author:
- name: "Marc-Aurèle Rivière"
url: https://ma-riviere.me
url: https://ma-riviere.com
orcid: 0000-0002-5108-3382
date: "2022-05-19"
editor: source
Expand Down
2 changes: 1 addition & 1 deletion tests/performance-monitoring/dplyr.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "dplyr <-> data.table"
subtitle: "Notes I took while learning to use data.table"
author:
- name: "Marc-Aurèle Rivière"
url: https://ma-riviere.me
url: https://ma-riviere.com
orcid: 0000-0002-5108-3382
date: "2022-05-19"
editor: source
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/_snaps/utils_render_grid.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# create_columns_component_g creates columns and spanners
# create_columns_component_g() creates columns and spanners

Code
test
Expand Down

0 comments on commit 6b63c32

Please sign in to comment.