Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upkeep 2024 10 #101

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
^docs$
^_pkgdown\.yml$
^pkgdown$
^README\.Rmd$
^codecov\.yml$
visual_test
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
issue_comment:
types: [created]

name: Commands
name: pr-commands.yaml

permissions: read-all

jobs:
document:
Expand All @@ -13,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -50,6 +54,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:
pull_request:
branches: [main, master]

name: test-coverage
name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
Expand All @@ -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: |
Expand Down
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
16 changes: 13 additions & 3 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ output: github_document

<!-- README.md is generated from README.Rmd. Please edit that file -->

```{r setup, include = FALSE}
```{r}
#| label: setup
#| include: false
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
Expand All @@ -20,7 +22,7 @@ options(width = 90)
<!-- badges: start -->
[![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)
<!-- badges: end -->

Expand All @@ -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)

Expand All @@ -60,13 +63,20 @@ 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)
```

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),
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<!-- badges: end -->
Expand Down Expand Up @@ -92,7 +92,7 @@ library(grid)
grid.draw(p_table) # alternative use plot(p_table)
```

<img src="man/figures/README-unnamed-chunk-2-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-3-1.png" 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" width="100%" />

While most people will interact with gtable through ggplot2, it is
possible to build a plot from the ground up.
Expand Down Expand Up @@ -126,4 +126,4 @@ plot <- gtable_add_grob(
grid.draw(plot)
```

<img src="man/figures/README-unnamed-chunk-3-1.png" width="100%" />
<img src="man/figures/README-unnamed-chunk-4-1.png" alt="A scatterplot of random numbers. The scatterplot is created by combining separate grobs created with grid using gtable." width="100%" />
Binary file modified man/figures/README-unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added man/figures/README-unnamed-chunk-4-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon-48x48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/favicon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions pkgdown/favicon/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions pkgdown/favicon/site.webmanifest
Original file line number Diff line number Diff line change
@@ -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"
}
Binary file added pkgdown/favicon/web-app-manifest-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added pkgdown/favicon/web-app-manifest-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 37 additions & 5 deletions tests/testthat/_snaps/gtable.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,43 @@
# as.gtable sensibly converts objects

Can't convert an integer vector to a <gtable>.
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 <gtable>.

---

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?

24 changes: 24 additions & 0 deletions tests/testthat/_snaps/layout.md
Original file line number Diff line number Diff line change
@@ -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`

32 changes: 32 additions & 0 deletions tests/testthat/_snaps/subsetting.md
Original file line number Diff line number Diff line change
@@ -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

File renamed without changes.
File renamed without changes.
15 changes: 5 additions & 10 deletions tests/testthat/test-gtable.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
6 changes: 3 additions & 3 deletions tests/testthat/test-layout.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
8 changes: 4 additions & 4 deletions tests/testthat/test-subsetting.R
Original file line number Diff line number Diff line change
Expand Up @@ -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])
})
Expand Down
Loading
Loading