diff --git a/.Rbuildignore b/.Rbuildignore
index ea9634d..c747efc 100644
--- a/.Rbuildignore
+++ b/.Rbuildignore
@@ -1,5 +1,6 @@
^docs$
^_pkgdown\.yml$
+^pkgdown$
^README\.Rmd$
^codecov\.yml$
visual_test
diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml
index d8aeb54..064677b 100644
--- a/.github/workflows/R-CMD-check.yaml
+++ b/.github/workflows/R-CMD-check.yaml
@@ -10,7 +10,9 @@ on:
pull_request:
branches: [main, master]
-name: R-CMD-check
+name: R-CMD-check.yaml
+
+permissions: read-all
jobs:
R-CMD-check:
@@ -25,17 +27,15 @@ jobs:
- {os: macos-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
- # Use 3.6 to trigger usage of RTools35
- - {os: windows-latest, r: '3.6'}
- # use 4.1 to check with rtools40's older compiler
- - {os: windows-latest, r: '4.1'}
-
- - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- - {os: ubuntu-latest, r: 'release'}
- - {os: ubuntu-latest, r: 'oldrel-1'}
- - {os: ubuntu-latest, r: 'oldrel-2'}
- - {os: ubuntu-latest, r: 'oldrel-3'}
- - {os: ubuntu-latest, r: 'oldrel-4'}
+ # use 4.0 or 4.1 to check with rtools40's older compiler
+ - {os: windows-latest, r: 'oldrel-4'}
+
+ - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
+ - {os: ubuntu-latest, r: 'release'}
+ - {os: ubuntu-latest, r: 'oldrel-1'}
+ - {os: ubuntu-latest, r: 'oldrel-2'}
+ - {os: ubuntu-latest, r: 'oldrel-3'}
+ - {os: ubuntu-latest, r: 'oldrel-4'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml
index a7276e8..4bbce75 100644
--- a/.github/workflows/pkgdown.yaml
+++ b/.github/workflows/pkgdown.yaml
@@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:
-name: pkgdown
+name: pkgdown.yaml
+
+permissions: read-all
jobs:
pkgdown:
diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml
index eea58c5..2edd93f 100644
--- a/.github/workflows/pr-commands.yaml
+++ b/.github/workflows/pr-commands.yaml
@@ -4,7 +4,9 @@ on:
issue_comment:
types: [created]
-name: Commands
+name: pr-commands.yaml
+
+permissions: read-all
jobs:
document:
@@ -13,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
+ permissions:
+ contents: write
steps:
- uses: actions/checkout@v4
@@ -50,6 +54,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
+ permissions:
+ contents: write
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml
index 21b8a93..9882260 100644
--- a/.github/workflows/test-coverage.yaml
+++ b/.github/workflows/test-coverage.yaml
@@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]
-name: test-coverage
+name: test-coverage.yaml
+
+permissions: read-all
jobs:
test-coverage:
@@ -23,18 +25,27 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
- extra-packages: any::covr
+ extra-packages: any::covr, any::xml2
needs: coverage
- name: Test coverage
run: |
- covr::codecov(
+ cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
+ covr::to_cobertura(cov)
shell: Rscript {0}
+ - uses: codecov/codecov-action@v4
+ with:
+ fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
+ file: ./cobertura.xml
+ plugin: noop
+ disable_search: true
+ token: ${{ secrets.CODECOV_TOKEN }}
+
- name: Show testthat output
if: always()
run: |
diff --git a/DESCRIPTION b/DESCRIPTION
index 103726a..c13f782 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -15,7 +15,7 @@ License: MIT + file LICENSE
URL: https://gtable.r-lib.org, https://github.com/r-lib/gtable
BugReports: https://github.com/r-lib/gtable/issues
Depends:
- R (>= 3.5)
+ R (>= 4.0)
Imports:
cli,
glue,
@@ -33,6 +33,7 @@ VignetteBuilder:
knitr
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
+Config/usethis/last-upkeep: 2024-10-25
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
-RoxygenNote: 7.3.1
+RoxygenNote: 7.3.2
diff --git a/README.Rmd b/README.Rmd
index 77610aa..7f676b1 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -4,7 +4,9 @@ output: github_document
-```{r setup, include = FALSE}
+```{r}
+#| label: setup
+#| include: false
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
@@ -20,7 +22,7 @@ options(width = 90)
[![R-CMD-check](https://github.com/r-lib/gtable/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/gtable/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/gtable)](https://CRAN.R-project.org/package=gtable)
-[![Codecov test coverage](https://codecov.io/gh/r-lib/gtable/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/gtable?branch=main)
+[![Codecov test coverage](https://codecov.io/gh/r-lib/gtable/graph/badge.svg)](https://app.codecov.io/gh/r-lib/gtable)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
@@ -44,7 +46,8 @@ pak::pak("r-lib/gtable")
## Example
ggplot2 uses gtable for laying out plots, and it is possible to access the gtable representation of a plot for inspection and modification:
-```{r, message=FALSE}
+```{r}
+#| message: false
library(gtable)
library(ggplot2)
@@ -60,6 +63,10 @@ A gtable object is a collection of graphic elements along with their placement i
A gtable object is itself a grob, and can thus be drawn using standard functions from the grid package:
```{r}
+#| fig-alt: >
+#| A scatterplot of miles per gallon against displacement based on the mtcars
+#| dataset. The plot is rendered by first converting the ggplot object to a
+#| gtable and then plotting the gtable
library(grid)
grid.draw(p_table) # alternative use plot(p_table)
```
@@ -67,6 +74,9 @@ grid.draw(p_table) # alternative use plot(p_table)
While most people will interact with gtable through ggplot2, it is possible to build a plot from the ground up.
```{r}
+#| fig-alt: >
+#| A scatterplot of random numbers. The scatterplot is created by combining
+#| separate grobs created with grid using gtable.
# Construct some graphical elements using grid
points <- pointsGrob(
x = runif(10),
diff --git a/README.md b/README.md
index 8968468..9d13dba 100644
--- a/README.md
+++ b/README.md
@@ -9,7 +9,7 @@
[![CRAN
status](https://www.r-pkg.org/badges/version/gtable)](https://CRAN.R-project.org/package=gtable)
[![Codecov test
-coverage](https://codecov.io/gh/r-lib/gtable/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/gtable?branch=main)
+coverage](https://codecov.io/gh/r-lib/gtable/graph/badge.svg)](https://app.codecov.io/gh/r-lib/gtable)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
@@ -92,7 +92,7 @@ library(grid)
grid.draw(p_table) # alternative use plot(p_table)
```
-
+
While most people will interact with gtable through ggplot2, it is
possible to build a plot from the ground up.
@@ -126,4 +126,4 @@ plot <- gtable_add_grob(
grid.draw(plot)
```
-
+
diff --git a/man/figures/README-unnamed-chunk-3-1.png b/man/figures/README-unnamed-chunk-3-1.png
index c91c483..f41204e 100644
Binary files a/man/figures/README-unnamed-chunk-3-1.png and b/man/figures/README-unnamed-chunk-3-1.png differ
diff --git a/man/figures/README-unnamed-chunk-4-1.png b/man/figures/README-unnamed-chunk-4-1.png
new file mode 100644
index 0000000..c91c483
Binary files /dev/null and b/man/figures/README-unnamed-chunk-4-1.png differ
diff --git a/man/figures/logo.png b/man/figures/logo.png
index 02546a4..0e851d3 100644
Binary files a/man/figures/logo.png and b/man/figures/logo.png differ
diff --git a/pkgdown/favicon/apple-touch-icon.png b/pkgdown/favicon/apple-touch-icon.png
new file mode 100644
index 0000000..45b5681
Binary files /dev/null and b/pkgdown/favicon/apple-touch-icon.png differ
diff --git a/pkgdown/favicon/favicon-48x48.png b/pkgdown/favicon/favicon-48x48.png
new file mode 100644
index 0000000..aaffb63
Binary files /dev/null and b/pkgdown/favicon/favicon-48x48.png differ
diff --git a/pkgdown/favicon/favicon.ico b/pkgdown/favicon/favicon.ico
new file mode 100644
index 0000000..46c10b3
Binary files /dev/null and b/pkgdown/favicon/favicon.ico differ
diff --git a/pkgdown/favicon/favicon.svg b/pkgdown/favicon/favicon.svg
new file mode 100644
index 0000000..413a211
--- /dev/null
+++ b/pkgdown/favicon/favicon.svg
@@ -0,0 +1,3 @@
+
\ No newline at end of file
diff --git a/pkgdown/favicon/site.webmanifest b/pkgdown/favicon/site.webmanifest
new file mode 100644
index 0000000..4ebda26
--- /dev/null
+++ b/pkgdown/favicon/site.webmanifest
@@ -0,0 +1,21 @@
+{
+ "name": "",
+ "short_name": "",
+ "icons": [
+ {
+ "src": "/web-app-manifest-192x192.png",
+ "sizes": "192x192",
+ "type": "image/png",
+ "purpose": "maskable"
+ },
+ {
+ "src": "/web-app-manifest-512x512.png",
+ "sizes": "512x512",
+ "type": "image/png",
+ "purpose": "maskable"
+ }
+ ],
+ "theme_color": "#ffffff",
+ "background_color": "#ffffff",
+ "display": "standalone"
+}
\ No newline at end of file
diff --git a/pkgdown/favicon/web-app-manifest-192x192.png b/pkgdown/favicon/web-app-manifest-192x192.png
new file mode 100644
index 0000000..95a6b39
Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-192x192.png differ
diff --git a/pkgdown/favicon/web-app-manifest-512x512.png b/pkgdown/favicon/web-app-manifest-512x512.png
new file mode 100644
index 0000000..5987ec8
Binary files /dev/null and b/pkgdown/favicon/web-app-manifest-512x512.png differ
diff --git a/tests/testthat/_snaps/gtable.md b/tests/testthat/_snaps/gtable.md
index f4a1920..668704c 100644
--- a/tests/testthat/_snaps/gtable.md
+++ b/tests/testthat/_snaps/gtable.md
@@ -1,11 +1,43 @@
# as.gtable sensibly converts objects
- Can't convert an integer vector to a .
+ Code
+ as.gtable(g2, widths = unit(c(1, 1), "cm"))
+ Condition
+ Warning:
+ `widths` truncated to length 1.
+ Output
+ TableGrob (1 x 1) "layout": 1 grobs
+ z cells name grob
+ 1 1 (1-1,1-1) layout circle[GRID.circle.9]
---
- Arguments in `...` must be used.
- x Problematic argument:
- * foo = "bar"
- i Did you misspell an argument name?
+ Code
+ as.gtable(g2, heights = unit(c(1, 1), "cm"))
+ Condition
+ Warning:
+ `heights` truncated to length 1.
+ Output
+ TableGrob (1 x 1) "layout": 1 grobs
+ z cells name grob
+ 1 1 (1-1,1-1) layout circle[GRID.circle.9]
+
+---
+
+ Code
+ as.gtable(1:5)
+ Condition
+ Error in `as.gtable()`:
+ ! Can't convert an integer vector to a .
+
+---
+
+ Code
+ as.gtable(g1, foo = "bar")
+ Condition
+ Error in `as.gtable()`:
+ ! Arguments in `...` must be used.
+ x Problematic argument:
+ * foo = "bar"
+ i Did you misspell an argument name?
diff --git a/tests/testthat/_snaps/layout.md b/tests/testthat/_snaps/layout.md
new file mode 100644
index 0000000..268bff9
--- /dev/null
+++ b/tests/testthat/_snaps/layout.md
@@ -0,0 +1,24 @@
+# Adding multiple grobs
+
+ Code
+ gtable_add_grob(layout, grobs, c(1:3), 1, 3, 3)
+ Condition
+ Error in `gtable_add_grob()`:
+ ! Not all inputs have either length 1 or same length same as `grobs`
+
+---
+
+ Code
+ gtable_add_grob(layout, grobs, tval, 1:2, 3, 3)
+ Condition
+ Error in `gtable_add_grob()`:
+ ! Not all inputs have either length 1 or same length same as `grobs`
+
+---
+
+ Code
+ gtable_add_grob(layout, grobs, tval, 1, 3, 3, z = 1:4)
+ Condition
+ Error in `gtable_add_grob()`:
+ ! Not all inputs have either length 1 or same length same as `grobs`
+
diff --git a/tests/testthat/_snaps/subsetting.md b/tests/testthat/_snaps/subsetting.md
new file mode 100644
index 0000000..3f853b5
--- /dev/null
+++ b/tests/testthat/_snaps/subsetting.md
@@ -0,0 +1,32 @@
+# indexing errors are caught
+
+ Code
+ base[2:1, ]
+ Condition
+ Error in `base[2:1, ]`:
+ ! `i` and `j` must be increasing sequences of numbers
+
+---
+
+ Code
+ base[c(2, 2), ]
+ Condition
+ Error in `base[c(2, 2), ]`:
+ ! `i` and `j` must be increasing sequences of numbers
+
+---
+
+ Code
+ base[, 2:1]
+ Condition
+ Error in `base[, 2:1]`:
+ ! `i` and `j` must be increasing sequences of numbers
+
+---
+
+ Code
+ base[, c(1, 1)]
+ Condition
+ Error in `base[, c(1, 1)]`:
+ ! `i` and `j` must be increasing sequences of numbers
+
diff --git a/tests/testthat/helper-grobs.r b/tests/testthat/helper-grobs.R
similarity index 100%
rename from tests/testthat/helper-grobs.r
rename to tests/testthat/helper-grobs.R
diff --git a/tests/testthat/helper-units.r b/tests/testthat/helper-units.R
similarity index 100%
rename from tests/testthat/helper-units.r
rename to tests/testthat/helper-units.R
diff --git a/tests/testthat/test-gtable.R b/tests/testthat/test-gtable.R
index 5b13c1f..46162d6 100644
--- a/tests/testthat/test-gtable.R
+++ b/tests/testthat/test-gtable.R
@@ -11,14 +11,9 @@ test_that("as.gtable sensibly converts objects", {
expect_equal(as.numeric(convertUnit(gtable_width(test), "cm")), 2)
expect_equal(as.numeric(convertUnit(gtable_height(test), "cm")), 2)
- expect_warning(
- as.gtable(g2, widths = unit(c(1, 1), "cm")),
- "truncated to length 1"
- )
- expect_warning(
- as.gtable(g2, heights = unit(c(1, 1), "cm")),
- "truncated to length 1"
- )
- expect_snapshot_error(as.gtable(1:5))
- expect_snapshot_error(as.gtable(g1, foo = "bar"))
+ expect_snapshot(as.gtable(g2, widths = unit(c(1, 1), "cm")))
+ expect_snapshot(as.gtable(g2, heights = unit(c(1, 1), "cm")))
+
+ expect_snapshot(as.gtable(1:5), error = TRUE)
+ expect_snapshot(as.gtable(g1, foo = "bar"), error = TRUE)
})
diff --git a/tests/testthat/test-layout.R b/tests/testthat/test-layout.R
index 4466270..99087ca 100644
--- a/tests/testthat/test-layout.R
+++ b/tests/testthat/test-layout.R
@@ -150,7 +150,7 @@ test_that("Adding multiple grobs", {
# Error if inputs are not length 1 or same length as grobs
layout <- gtable_add_cols(gtable_add_rows(gtable(), rep(cm, 3)), rep(cm, 3))
- expect_error(gtable_add_grob(layout, grobs, c(1:3), 1, 3, 3))
- expect_error(gtable_add_grob(layout, grobs, tval, 1:2, 3, 3))
- expect_error(gtable_add_grob(layout, grobs, tval, 1, 3, 3, z = 1:4))
+ expect_snapshot(gtable_add_grob(layout, grobs, c(1:3), 1, 3, 3), error = TRUE)
+ expect_snapshot(gtable_add_grob(layout, grobs, tval, 1:2, 3, 3), error = TRUE)
+ expect_snapshot(gtable_add_grob(layout, grobs, tval, 1, 3, 3, z = 1:4), error = TRUE)
})
diff --git a/tests/testthat/test-subsetting.R b/tests/testthat/test-subsetting.R
index da3f640..68a69c5 100644
--- a/tests/testthat/test-subsetting.R
+++ b/tests/testthat/test-subsetting.R
@@ -43,10 +43,10 @@ test_that("spanning grobs kept if ends kept", {
})
test_that("indexing errors are caught", {
- expect_error(base[2:1,])
- expect_error(base[c(2,2), ])
- expect_error(base[, 2:1])
- expect_error(base[, c(1,1)])
+ expect_snapshot(base[2:1,], error = TRUE)
+ expect_snapshot(base[c(2,2), ], error = TRUE)
+ expect_snapshot(base[, 2:1], error = TRUE)
+ expect_snapshot(base[, c(1,1)], error = TRUE)
expect_silent(base[1:2, 1:2])
})
diff --git a/vignettes/profiling.Rmd b/vignettes/profiling.Rmd
index 85b0e2e..70ac553 100644
--- a/vignettes/profiling.Rmd
+++ b/vignettes/profiling.Rmd
@@ -8,7 +8,9 @@ vignette: >
%\VignetteEncoding{UTF-8}
---
-```{r setup, include = FALSE}
+```{r}
+#| label: setup
+#| include: false
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
@@ -34,7 +36,9 @@ profile <- profvis(for (i in seq_len(100)) ggplot_gtable(p_build))
profile
```
-```{r, eval=FALSE, include=FALSE}
+```{r}
+#| eval: false
+#| include: false
saveRDS(profile, file.path('profilings', paste0(packageVersion('gtable'), '.rds')))
```