Skip to content

Commit

Permalink
2023 upkeep (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasp85 authored Mar 7, 2023
1 parent d772034 commit 6c1d359
Show file tree
Hide file tree
Showing 25 changed files with 154 additions and 119 deletions.
50 changes: 24 additions & 26 deletions CODE_OF_CONDUCT.md → .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
Expand All @@ -21,25 +21,25 @@ community include:
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the overall
community
community

Examples of unacceptable behavior include:

* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* The use of sexualized language or imagery, and sexual attention or advances of
any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Publishing others' private information, such as a physical or email address,
without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
professional setting

## Enforcement Responsibilities

Community leaders are responsible for clarifying and enforcing our standards
of acceptable behavior and will take appropriate and fair corrective action in
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.

Expand All @@ -50,17 +50,17 @@ decisions when appropriate.

## Scope

This Code of Conduct applies within all community spaces, and also applies
when an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail
address, posting via an official social media account, or acting as an appointed
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.

## Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at [INSERT CONTACT
METHOD]. All complaints will be reviewed and investigated promptly and fairly.
reported to the community leaders responsible for enforcement at [email protected].
All complaints will be reviewed and investigated promptly and fairly.

All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
Expand Down Expand Up @@ -114,15 +114,13 @@ community.
## Attribution

This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0,
available at https://www.contributor-covenant.org/version/2/0/
code_of_conduct.html.
version 2.1, available at
<https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.

Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).

[homepage]: https://www.contributor-covenant.org
Community Impact Guidelines were inspired by
[Mozilla's code of conduct enforcement ladder][https://github.com/mozilla/inclusion].

For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at https://
www.contributor-covenant.org/translations.
<https://www.contributor-covenant.org/faq>. Translations are available at <https://www.contributor-covenant.org/translations>.

[homepage]: https://www.contributor-covenant.org
19 changes: 10 additions & 9 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,27 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {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'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-18.04, r: 'oldrel-2'}
- {os: ubuntu-18.04, r: 'oldrel-3'}
- {os: ubuntu-18.04, 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 }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

Expand All @@ -39,7 +39,7 @@ jobs:

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected].4
uses: JamesIves/github-pages-deploy-action@v4.4.1
with:
clean: false
branch: gh-pages
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v2
with:
Expand Down
23 changes: 21 additions & 2 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -27,5 +27,24 @@ jobs:
needs: coverage

- name: Test coverage
run: covr::codecov(quiet = FALSE)
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ Authors@R: c(
comment = "Improved styles; polypath implementation"),
person("Håkon", "Malmedal", role = "ctb",
comment = "Opacity code"),
person("RStudio", role = c("cph", "fnd"))
person("Posit, PBC", role = c("cph", "fnd"))
)
Description: A graphics device for R that produces 'Scalable Vector
Graphics'. 'svglite' is a fork of the older 'RSvgDevice' package.
License: GPL (>= 2)
URL: https://svglite.r-lib.org, https://github.com/r-lib/svglite
BugReports: https://github.com/r-lib/svglite/issues
Depends:
R (>= 3.0.0)
R (>= 3.5.0)
Imports:
systemfonts (>= 1.0.0)
Suggests:
Expand All @@ -34,7 +34,7 @@ Suggests:
htmltools,
knitr,
rmarkdown,
testthat,
testthat (>= 3.0.0),
xml2 (>= 1.0.0)
LinkingTo:
cpp11,
Expand All @@ -46,3 +46,4 @@ Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.1
SystemRequirements: C++11, libpng
Config/testthat/edition: 3
22 changes: 14 additions & 8 deletions R/SVG.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
#' @examples
#' # Save to file
#' svglite(tempfile("Rplots.svg"))
#' plot(1:11, (-5:5)^2, type = 'b', main = "Simple Example")
#' plot(1:11, (-5:5)^2, type = "b", main = "Simple Example")
#' dev.off()
#'
#' @keywords device
Expand All @@ -83,8 +83,9 @@ svglite <- function(filename = "Rplot%03d.svg", width = 10, height = 8,
if (!missing(file)) {
filename <- file
}
if (invalid_filename(filename))
if (invalid_filename(filename)) {
stop("invalid 'file': ", filename)
}
aliases <- validate_aliases(system_fonts, user_fonts)
web_fonts <- validate_web_fonts(web_fonts)
if (is.null(id)) {
Expand All @@ -105,10 +106,13 @@ svglite <- function(filename = "Rplot%03d.svg", width = 10, height = 8,
#' @return A function with no arguments: call the function to get the
#' current value of the string.
#' @examples
#' s <- svgstring(); s()
#' s <- svgstring()
#' s()
#'
#' plot.new(); s();
#' text(0.5, 0.5, "Hi!"); s()
#' plot.new()
#' s()
#' text(0.5, 0.5, "Hi!")
#' s()
#' dev.off()
#'
#' s <- svgstring()
Expand All @@ -130,13 +134,15 @@ svgstring <- function(width = 10, height = 8, bg = "white",
id <- as.character(id)

env <- new.env(parent = emptyenv())
string_src <- svgstring_(env, width = width, height = height, bg = bg,
string_src <- svgstring_(env,
width = width, height = height, bg = bg,
pointsize = pointsize, standalone = standalone, aliases = aliases,
webfonts = web_fonts, id = id, fix_text_size, scaling)
webfonts = web_fonts, id = id, fix_text_size, scaling
)

function() {
svgstr <- env$svg_string
if(!env$is_closed) {
if (!env$is_closed) {
svgstr <- c(svgstr, get_svg_content(string_src))
}
structure(svgstr, class = "svg")
Expand Down
19 changes: 13 additions & 6 deletions R/fonts.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ validate_system_alias <- function(alias) {

matched <- match_family(alias)
if (alias != matched) {
warning(call. = FALSE,
warning(
call. = FALSE,
"System font `", alias, "` not found. ",
"Closest match: `", matched, "`")
"Closest match: `", matched, "`"
)
}
matched
}
Expand All @@ -68,15 +70,17 @@ is_user_alias <- function(x) {
validate_user_alias <- function(default_name, family) {
if (!all(names(family) %in% r_font_faces)) {
stop("Faces must contain only: `plain`, `bold`, `italic`, `bolditalic`, `symbol`",
call. = FALSE)
call. = FALSE
)
}

is_alias_object <- vapply_lgl(family, is_user_alias)
is_alias_plain <- vapply_lgl(family, is_scalar_character)

is_valid_alias <- is_alias_object | is_alias_plain
if (any(!is_valid_alias)) {
stop(call. = FALSE,
stop(
call. = FALSE,
"The following faces are invalid for `", default_name, "`: ",
paste0(names(family)[!is_valid_alias], collapse = ", ")
)
Expand All @@ -93,7 +97,8 @@ validate_user_alias <- function(default_name, family) {
file_exists <- vapply_lgl(files, file.exists)
if (any(!file_exists)) {
missing <- unlist(files)[!file_exists]
stop(call. = FALSE,
stop(
call. = FALSE,
"Could not find font file: ",
paste0(missing, collapse = ", ")
)
Expand Down Expand Up @@ -186,7 +191,9 @@ print.font_face <- function(x, ...) {
is_font_face <- function(x) inherits(x, "font_face")

validate_web_fonts <- function(x) {
if (length(x) == 0) return("")
if (length(x) == 0) {
return("")
}
paste0(paste(
ifelse(vapply(x, is_font_face, logical(1)), x, paste0(' @import url("', x, '");')),
collapse = "\n"
Expand Down
6 changes: 6 additions & 0 deletions R/svglite-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
8 changes: 4 additions & 4 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@ open_manual_tests <- function() {
}

invalid_filename <- function(filename) {

if (!is.character(filename) || length(filename) != 1)
if (!is.character(filename) || length(filename) != 1) {
return(TRUE)
}

# strip double occurences of %
stripped_file <- gsub("%{2}", "", filename)
# filename is fine if there are no % left
if (!grepl("%", stripped_file))
if (!grepl("%", stripped_file)) {
return(FALSE)
}
# remove first allowed pattern, % followed by digits followed by [diouxX]
stripped_file <- sub("%[#0 ,+-]*[0-9.]*[diouxX]", "", stripped_file)
# matching leftover % indicates multiple patterns or a single incorrect pattern (e.g., %s)
return(grepl("%", stripped_file))

}
#' Convert an svg file to svgz, overwriting the old file
#' @param file the path to the file to convert
Expand Down
Loading

0 comments on commit 6c1d359

Please sign in to comment.