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

Added pkgdown website #7

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
^paintbrush\.Rproj$
^\.Rproj\.user$
^_pkgdown\.yml$
^docs$
^pkgdown$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
48 changes: 48 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
release:
types: [published]
workflow_dispatch:

name: pkgdown

jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website

- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.httr-oauth
.DS_Store
.quarto
docs
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Imports:
utils
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
URL: https://github.com/klbarnes20/paintbrush
URL: https://github.com/klbarnes20/paintbrush, https://klbarnes20.github.io/paintbrush/
BugReports: https://github.com/klbarnes20/paintbrush/issues
Suggests:
testthat (>= 3.0.0)
Expand Down
14 changes: 7 additions & 7 deletions R/colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ carpentries_pal <- function(discrete = TRUE) {
#'
#' print(p_fill_discrete)
#'
#' p_fill_continuous <- ggplot(data, aes(x, y, fill = category)) +
#' p_fill_continuous <- ggplot(data, aes(x, y, fill = y)) +
#' geom_bar(stat = 'identity') +
#' scale_fill_carpentries(discrete = FALSE) +
#' theme_carpentries()
Expand All @@ -88,19 +88,19 @@ scale_fill_carpentries <-
...) {
palette <- match.arg(palette)
if (discrete) {
discrete_scale("fill",
"carpentries",
carpentries_pal(discrete = TRUE),
discrete_scale(aesthetics = "fill",
scale_name = "carpentries",
palette = carpentries_pal(discrete = TRUE),
...)
} else {
scale_color_gradientn(
scale_fill_gradientn(
...,
colors = carpentries_pal(discrete = FALSE),
colors = carpentries_colors,
values = NULL,
space = "Lab",
na.value = "grey50",
guide = "colourbar",
aesthetics = "color"
aesthetics = "fill"
)
}
}
Expand Down
15 changes: 3 additions & 12 deletions R/theme.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,16 @@
#'
#' p1 <- ggplot(mtcars2) +
#' geom_point(aes(x = wt, y = mpg, colour = gear)) +
#' labs(
#' title = "Fuel economy declines as weight increases",
#' subtitle = "(1973-74)",
#' caption = "Data from the 1974 Motor Trend US magazine.",
#' tag = "Figure 1",
#' x = "Weight (1000 lbs)",
#' y = "Fuel economy (mpg)",
#' colour = "Gears"
#' )
#' theme_carpentries()
#'
theme_carpentries <- function() {
theme_bw(base_size = 12) %+replace%
theme(
plot.title =
element_text(size = 14, face = "bold", hjust = 0.5,
margin = margin(0, 0, 15, 0)),
axis.text = element_text(size = 9),
axis.text.x = element_text(angle = 0, vjust = 0.5),
axis.text.y = element_text(size = 9),
axis.text.x = element_blank(),
axis.ticks = element_blank(),
axis.title = element_text(face = "bold", vjust = 0.5),
strip.text = element_text(face = "bold"),
strip.background = element_blank(),
Expand Down
4 changes: 4 additions & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
url: https://klbarnes20.github.io/paintbrush/
template:
bootstrap: 5

8 changes: 5 additions & 3 deletions tests/testthat/test-colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ test_that("discrete color palettes return expected colors", {
# I expect the dp to return a vector of the first three
# colors of carpentries_colors
expect_equal(dp(3), unname(carpentries_colors[1:3]))
expect_equal(dp(14), unname(carpentries_colors[1:14]))
expect_warning(dp(15))
expect_warning(dp(100))
expect_equal(dp(14), unname(carpentries_colors))
expect_warning(x15 <- dp(15), "have supplied 15")
expect_equal(x15, unname(c(carpentries_colors, NA)))
expect_warning(x100 <- dp(100), "have supplied 100")
expect_equal(x100, unname(c(carpentries_colors, rep(NA, 86))))
})

test_that("continuous color palettes return expected colors", {
Expand Down