Skip to content

Commit 3096636

Browse files
authored
Merge pull request #188 from jrnold/switch-syler-to-air
Use air instead of styler for code formatting
2 parents a156f35 + 0c05793 commit 3096636

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+1130
-722
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@
2424
^scripts$
2525
^pkgdown$
2626
^CLAUDE\.md$
27+
^air\.toml$
28+
^\.claude$

.github/workflows/pr-commands.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ jobs:
6060
- uses: r-lib/actions/setup-r@v2
6161

6262
- name: Install dependencies
63-
run: install.packages("styler")
63+
run: install.packages("air")
6464
shell: Rscript {0}
6565

6666
- name: Style
67-
run: styler::style_pkg()
67+
run: air::air_style_pkg()
6868
shell: Rscript {0}
6969

7070
- name: commit

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ README.html
66
revdep
77
*.DS_Store
88
docs
9+
.RData

CLAUDE.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Rscript -e 'testthat::test_file("tests/testthat/test-economist.R")'
6969

7070
This project uses [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) for commit messages.
7171

72+
7273
### Format
7374
```
7475
<type>[optional scope]: <description>
@@ -96,6 +97,10 @@ test: add visual regression tests for tufte theme
9697
chore: update pkgdown configuration
9798
```
9899

100+
## NEWS.md
101+
102+
For user-facing changes update `NEWS.md` when commiting.
103+
99104
## Architecture
100105

101106
### Code Organization
@@ -153,9 +158,32 @@ Tests use:
153158

154159
### Code Style
155160

156-
- Uses tidyverse style enforced by styler (see `.lintr` for configuration)
157-
- Line length limit: 120 characters
158-
- Some example files are excluded from linting/styling (see `.lintr` and `scripts/style.R`)
161+
Code sytle is enforced by the the [air](https://tidyverse.org/blog/2025/02/air/) and [lintr](https://lintr.r-lib.org/) packages.
162+
163+
- Generally follows the [tidyverse style](https://style.tidyverse.org/).
164+
- Line length of 120
165+
- `air` package configuration: `air.toml`.
166+
- `lintr` package configuration: `.lintr`
167+
168+
### Spelling
169+
170+
Check spelling using the [spelling](https://docs.ropensci.org/spelling/) package.
171+
172+
```bash
173+
# Run spell check
174+
Rscript tests/spelling.R
175+
176+
# Update wordlist interactively (adds new words found in documentation)
177+
Rscript -e 'spelling::update_wordlist()'
178+
```
179+
180+
The custom wordlist is stored in `inst/WORDLIST` and contains project-specific terms like:
181+
- Package names (ggplot, vdiffr, pkgdown)
182+
- Theme names (fivethirtyeight, solarized, stata)
183+
- Author names and proper nouns
184+
- Technical terms specific to this project
185+
186+
When spell check finds new valid words, add them to `inst/WORDLIST` using `spelling::update_wordlist()`.
159187

160188
## Key Concepts
161189

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Description: Some extra themes, geoms, and scales for 'ggplot2'.
5454
License: GPL-2
5555
URL: https://jrnold.github.io/ggthemes/, https://github.com/jrnold/ggthemes, http://jrnold.github.io/ggthemes/
5656
BugReports: https://github.com/jrnold/ggthemes/issues
57-
RoxygenNote: 7.3.1
57+
RoxygenNote: 7.3.3
5858
LazyData: true
5959
Language: en-US
6060
Encoding: UTF-8

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ style:
2929
lint:
3030
$(RSCRIPT) -e 'devtools::lint()'
3131

32+
.PHONY: format
33+
format:
34+
./scripts/format
35+
3236
README.md: README.Rmd
3337
$(RSCRIPT) -e 'knitr::knit("$<", output = "$@", quiet = TRUE)'
3438

R/banking.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ calc_slopes <- function(x, y, cull = FALSE) {
9999
#' @seealso \code{\link[lattice]{banking}()}
100100
#' @export
101101
#' @example inst/examples/ex-bank_slopes.R
102-
bank_slopes <- function(x, y, cull = FALSE, weight = NULL,
103-
method = c("ms", "as"), ...) {
102+
bank_slopes <- function(x, y, cull = FALSE, weight = NULL, method = c("ms", "as"), ...) {
104103
method <- match.arg(method)
105104
fun <- bank_slopes_funs[[method]]
106105
# Heer produces functions with the target alpha = w/h = x/y

R/base.R

Lines changed: 56 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -427,14 +427,18 @@ theme_par <- function(base_size = par()$ps, base_family = par()$family) {
427427
colour = par()$col.axis,
428428
face = faces[par()$font.axis]
429429
),
430-
axis.text.x = element_text(margin = margin(
431-
t = 0.8 * half_line / 2,
432-
b = 0.8 * half_line / 2
433-
)),
434-
axis.text.y = element_text(margin = margin(
435-
r = 0.8 * half_line / 2,
436-
l = 0.8 * half_line / 2
437-
)),
430+
axis.text.x = element_text(
431+
margin = margin(
432+
t = 0.8 * half_line / 2,
433+
b = 0.8 * half_line / 2
434+
)
435+
),
436+
axis.text.y = element_text(
437+
margin = margin(
438+
r = 0.8 * half_line / 2,
439+
l = 0.8 * half_line / 2
440+
)
441+
),
438442
axis.ticks = element_line(colour = par()$fg),
439443
legend.title = element_text(colour = par()$fg),
440444
legend.text = element_text(colour = par()$fg),
@@ -458,42 +462,50 @@ theme_par <- function(base_size = par()$ps, base_family = par()$family) {
458462
face = faces[par()$font.sub],
459463
colour = par()$col.sub
460464
),
461-
strip.text.x = element_text(margin = margin(
462-
t = half_line,
463-
b = half_line
464-
)),
465-
strip.text.y = element_text(margin = margin(
466-
l = half_line,
467-
r = half_line
468-
)),
465+
strip.text.x = element_text(
466+
margin = margin(
467+
t = half_line,
468+
b = half_line
469+
)
470+
),
471+
strip.text.y = element_text(
472+
margin = margin(
473+
l = half_line,
474+
r = half_line
475+
)
476+
),
469477
strip.background = element_rect(colour = NA)
470478
)
471479

472480
las <- par()$las
473481
if (las == 0) {
474482
# parallel to axis
475-
thm <- thm + theme(
476-
axis.title.x = element_text(angle = 0),
477-
axis.title.y = element_text(angle = 90)
478-
)
483+
thm <- thm +
484+
theme(
485+
axis.title.x = element_text(angle = 0),
486+
axis.title.y = element_text(angle = 90)
487+
)
479488
} else if (las == 1) {
480489
# horizontal
481-
thm <- thm + theme(
482-
axis.title.x = element_text(angle = 0),
483-
axis.title.y = element_text(angle = 0)
484-
)
490+
thm <- thm +
491+
theme(
492+
axis.title.x = element_text(angle = 0),
493+
axis.title.y = element_text(angle = 0)
494+
)
485495
} else if (las == 2) {
486496
# perpendicular
487-
thm <- thm + theme(
488-
axis.title.x = element_text(angle = 90),
489-
axis.title.y = element_text(angle = 0)
490-
)
497+
thm <- thm +
498+
theme(
499+
axis.title.x = element_text(angle = 90),
500+
axis.title.y = element_text(angle = 0)
501+
)
491502
} else if (las == 3) {
492503
# vertical
493-
thm <- thm + theme(
494-
axis.title.x = element_text(angle = 90),
495-
axis.title.y = element_text(angle = 90)
496-
)
504+
thm <- thm +
505+
theme(
506+
axis.title.x = element_text(angle = 90),
507+
axis.title.y = element_text(angle = 90)
508+
)
497509
}
498510

499511
# ticks
@@ -504,18 +516,20 @@ theme_par <- function(base_size = par()$ps, base_family = par()$family) {
504516
}
505517
# plot x or y axis
506518
if (par()$xaxt == "n") {
507-
thm <- thm + theme(
508-
axis.line.x = element_blank(),
509-
axis.text.x = element_blank(),
510-
axis.ticks.x = element_blank()
511-
)
519+
thm <- thm +
520+
theme(
521+
axis.line.x = element_blank(),
522+
axis.text.x = element_blank(),
523+
axis.ticks.x = element_blank()
524+
)
512525
}
513526
if (par()$yaxt == "n") {
514-
thm <- thm + theme(
515-
axis.line.y = element_blank(),
516-
axis.text.y = element_blank(),
517-
axis.ticks.y = element_blank()
518-
)
527+
thm <- thm +
528+
theme(
529+
axis.line.y = element_blank(),
530+
axis.text.y = element_blank(),
531+
axis.ticks.y = element_blank()
532+
)
519533
}
520534

521535
thm

R/calc.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#' @family themes calc
88
#' @example inst/examples/ex-theme_calc.R
99
theme_calc <- function(base_size = 10, base_family = "sans") {
10-
(theme_foundation(base_family = base_family, base_size = base_size)
11-
+ theme(
10+
(theme_foundation(base_family = base_family, base_size = base_size) +
11+
theme(
1212
rect = element_rect(colour = "black", fill = "white"),
1313
text = element_text(colour = "black"),
1414
line = element_line(colour = "gray70"),

R/clean.R

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,12 @@
1212
#' @export
1313
#'
1414
#' @example inst/examples/ex-theme_clean.R
15-
theme_clean <- function(base_size = 12,
16-
base_family = "sans") {
17-
(
18-
theme_foundation(
19-
base_size = base_size,
20-
base_family = base_family
21-
) + theme(
15+
theme_clean <- function(base_size = 12, base_family = "sans") {
16+
(theme_foundation(
17+
base_size = base_size,
18+
base_family = base_family
19+
) +
20+
theme(
2221
axis.line.x = element_line(
2322
colour = "black",
2423
size = 0.5,
@@ -52,6 +51,5 @@ theme_clean <- function(base_size = 12,
5251
plot.background = element_rect(colour = "black"),
5352
plot.title = element_text(size = ceiling(base_size * 1.1), face = "bold"),
5453
plot.subtitle = element_text(size = ceiling(base_size * 1.05))
55-
)
56-
)
54+
))
5755
}

0 commit comments

Comments
 (0)