From ab2078976c9ab57116c7c9175632e7d19d45273f Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Mon, 28 Feb 2022 14:24:54 -0600 Subject: [PATCH] Workflow updates (#358) * use_tidy_description() and dd RStudio as funder * use_tidy_github_actions() * Update to latest pkgdown template * Mark S4 class registration as internal, and minimize Rd --- .github/workflows/R-CMD-check.yaml | 51 +++++++------- .github/workflows/pkgdown.yaml | 58 +++++++-------- .github/workflows/pr-commands.yaml | 67 ++++++++++++------ .github/workflows/test-coverage.yaml | 42 ++++------- .travis.yml | 29 -------- DESCRIPTION | 34 ++++----- R/S4.R | 26 ++----- README.md | 1 + _pkgdown.yml | 26 ++++--- man/oldclass.Rd | 19 ++--- vignettes/releases/xml2-1.1.1.Rmd | 101 --------------------------- 11 files changed, 162 insertions(+), 292 deletions(-) delete mode 100644 .travis.yml delete mode 100644 vignettes/releases/xml2-1.1.1.Rmd diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index b8ec9bc1..4efedd96 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,6 +1,14 @@ +# 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 +# +# NOTE: This workflow is overkill for most R packages and +# check-standard.yaml is likely a better choice. +# usethis::use_github_action("check-standard") will install it. on: push: + branches: [main, master] pull_request: + branches: [main, master] name: R-CMD-check @@ -14,15 +22,19 @@ jobs: fail-fast: false matrix: config: + - {os: macOS-latest, r: 'release'} + - {os: windows-latest, r: 'release'} - - {os: windows-2022, r: 'devel'} - - {os: windows-2022, r: 'devel-ucrt'} - - {os: macOS-latest, r: 'release'} - - {os: ubuntu-18.04, r: '3.4'} - - {os: ubuntu-18.04, r: '3.5'} - - {os: ubuntu-18.04, r: '3.6'} - - {os: ubuntu-18.04, r: '4.0'} - - {os: ubuntu-18.04, r: '4.1'} + # Use 3.6 to trigger usage of RTools35 + - {os: windows-latest, r: '3.6'} + + # 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'} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} @@ -31,28 +43,19 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: rcmdcheck - - - uses: r-lib/actions/check-r-package@HEAD - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash + extra-packages: any::rcmdcheck + needs: check - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main + - uses: r-lib/actions/check-r-package@v2 with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check + upload-snapshots: true diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index c4ebc41c..0b260216 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,44 +1,46 @@ +# 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: master + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: name: pkgdown jobs: pkgdown: - runs-on: macOS-latest + 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 }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@master + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-pandoc@master - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2) - shell: Rscript {0} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Cache R packages - uses: actions/cache@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: macOS-r-4.0-2-${{ hashFiles('depends.Rds') }} - restore-keys: macOS-r-4.0-2- + extra-packages: any::pkgdown, local::. + needs: website - - name: Install dependencies - run: | - install.packages("remotes") - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("pkgdown") + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - - name: Install package - run: R CMD INSTALL . - - - name: Deploy package - run: | - install.packages('xslt') - pkgdown::deploy_to_branch(new_process = FALSE) - shell: Rscript {0} + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/pr-commands.yaml b/.github/workflows/pr-commands.yaml index f5711b9f..97271eb2 100644 --- a/.github/workflows/pr-commands.yaml +++ b/.github/workflows/pr-commands.yaml @@ -1,52 +1,79 @@ +# 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: issue_comment: types: [created] + name: Commands + jobs: document: - if: startsWith(github.event.comment.body, '/document') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }} name: document - runs-on: macOS-latest + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@master + + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@master - - name: Install dependencies - run: Rscript -e 'install.packages(c("remotes", "roxygen2"))' -e 'remotes::install_deps(dependencies = TRUE)' + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::roxygen2 + needs: pr-document + - name: Document - run: Rscript -e 'roxygen2::roxygenise()' + run: roxygen2::roxygenise() + shell: Rscript {0} + - name: commit run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add man/\* NAMESPACE git commit -m 'Document' - - uses: r-lib/actions/pr-push@master + + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} + style: - if: startsWith(github.event.comment.body, '/style') + if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }} name: style - runs-on: macOS-latest + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/pr-fetch@master + + - uses: r-lib/actions/pr-fetch@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - - uses: r-lib/actions/setup-r@master + + - uses: r-lib/actions/setup-r@v2 + - name: Install dependencies - run: Rscript -e 'install.packages("styler")' + run: install.packages("styler") + shell: Rscript {0} + - name: Style - run: Rscript -e 'styler::style_pkg()' + run: styler::style_pkg() + shell: Rscript {0} + - name: commit run: | + git config --local user.name "$GITHUB_ACTOR" + git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" git add \*.R git commit -m 'Style' - - uses: r-lib/actions/pr-push@master + + - uses: r-lib/actions/pr-push@v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - # A mock job just to ensure we have a successful build status - finish: - runs-on: ubuntu-latest - steps: - - run: true diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index bdbf20c2..4b654182 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,43 +1,31 @@ +# 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: - - master + branches: [main, master] pull_request: - branches: - - master + branches: [main, master] name: test-coverage jobs: test-coverage: - runs-on: macOS-latest + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@master - - - uses: r-lib/actions/setup-pandoc@master - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), "depends.Rds", version = 2) - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v1 + - uses: r-lib/actions/setup-r@v2 with: - path: ${{ env.R_LIBS_USER }} - key: macOS-r-4.0-2-${{ hashFiles('depends.Rds') }} - restore-keys: macOS-r-4.0-2- + use-public-rspm: true - - name: Install dependencies - run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("covr") - shell: Rscript {0} + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage - name: Test coverage - run: covr::codecov() + run: covr::codecov(quiet = FALSE) shell: Rscript {0} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index dbba345c..00000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: r -cache: packages - -matrix: - include: - - os: linux - r: 3.2 - - os: linux - r: 3.3 - - os: linux - r: 3.4 - - os: linux - r: 3.5 - - os: linux - r: release - - os: linux - r: devel - - os: osx - osx_image: xcode8.3 - - os: osx - osx_image: xcode8.3 - before_install: - - brew install libxml2 - - brew link --force libxml2 - -addons: - apt: - packages: - - libxml2-dev diff --git a/DESCRIPTION b/DESCRIPTION index 45c9520c..e21d0dea 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,24 +1,16 @@ Package: xml2 Title: Parse XML Version: 1.3.3.9000 -Authors@R: - c(person(given = "Hadley", - family = "Wickham", - role = c("aut", "cre"), - email = "hadley@rstudio.com"), - person(given = "Jim", - family = "Hester", - role = "aut"), - person(given = "Jeroen", - family = "Ooms", - role = "aut"), - person(given = "RStudio", - role = "cph"), - person(given = "R Foundation", - role = "ctb", - comment = "Copy of R-project homepage cached as example")) -Description: Work with XML files using a simple, consistent - interface. Built on top of the 'libxml2' C library. +Authors@R: c( + person("Hadley", "Wickham", , "hadley@rstudio.com", role = c("aut", "cre")), + person("Jim", "Hester", role = "aut"), + person("Jeroen", "Ooms", role = "aut"), + person("RStudio", role = c("cph", "fnd")), + person("R Foundation", role = "ctb", + comment = "Copy of R-project homepage cached as example") + ) +Description: Work with XML files using a simple, consistent interface. + Built on top of the 'libxml2' C library. License: MIT + file LICENSE URL: https://xml2.r-lib.org/, https://github.com/r-lib/xml2 BugReports: https://github.com/r-lib/xml2/issues @@ -37,11 +29,11 @@ Suggests: testthat (>= 2.1.0) VignetteBuilder: knitr +Config/Needs/website: tidyverse/tidytemplate Encoding: UTF-8 Roxygen: list(markdown = TRUE) -RoxygenNote: 7.1.1 -SystemRequirements: libxml2: libxml2-dev (deb), libxml2-devel - (rpm) +RoxygenNote: 7.1.2 +SystemRequirements: libxml2: libxml2-dev (deb), libxml2-devel (rpm) Collate: 'S4.R' 'as_list.R' diff --git a/R/S4.R b/R/S4.R index 0b643966..9d94ffdc 100644 --- a/R/S4.R +++ b/R/S4.R @@ -3,41 +3,29 @@ #' @description #' Classes are exported so they can be re-used within S4 classes, see [methods::setOldClass()]. #' -#' `xml_document`: a complete document. +#' * `xml_document`: a complete document. +#' * `xml_nodeset`: a _set_ of nodes within a document. +#' * `xml_missing`: a missing object, e.g. for an empty result set. +#' * `xml_node`: a single node in a document. #' -#' @name xml_document-class -#' @family xml_document #' @importFrom methods setOldClass -#' @exportClass xml_document +#' @keywords internal #' @rdname oldclass +#' @name xml_document-class +#' @exportClass xml_document setOldClass("xml_document") -#' xml_missing class -#' -#' `xml_missing`: a missing object, e.g. for an empty result set. -#' #' @name xml_missing-class -#' @family xml_missing #' @exportClass xml_missing #' @rdname oldclass setOldClass("xml_missing") -#' xml_node Class -#' -#' `xml_node`: a single node in a document. -#' #' @name xml_node-class -#' @family xml_node #' @exportClass xml_node #' @rdname oldclass setOldClass("xml_node") -#' xml_nodeset Class -#' -#' `xml_nodeset`: a _set_ of nodes within a document. -#' #' @name xml_nodeset-class -#' @family xml_nodeset #' @exportClass xml_nodeset #' @rdname oldclass setOldClass("xml_nodeset") diff --git a/README.md b/README.md index a0bba8c2..58145dfb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # xml2 +[![R-CMD-check](https://github.com/r-lib/xml2/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/xml2/actions/workflows/R-CMD-check.yaml) [![R build status](https://github.com/r-lib/xml2/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/xml2/actions) [![Coverage Status](https://img.shields.io/codecov/c/github/r-lib/xml2/master.svg)](https://codecov.io/github/r-lib/xml2?branch=master) diff --git a/_pkgdown.yml b/_pkgdown.yml index 6e6936c1..01e37265 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,18 +1,15 @@ url: http://xml2.r-lib.org -development: - mode: auto +template: + bootstrap: 5 + package: tidytemplate -authors: - "Jim Hester": - href: http://jimhester.com + includes: + in_header: | + -template: - params: - docsearch: - api_key: fbd8d79ed49f21fc9ca7b2cf601a3f5b - index_name: xml2 - ganalytics: UA-115082821-1 +development: + mode: auto reference: - title: Read and write documents @@ -60,3 +57,10 @@ reference: contents: - ends_with("serialize") - xml2_example + +news: + releases: + - text: Version 1.0.0 + href: https://www.rstudio.com/blog/xml2-1-0-0/ + - text: Version 1.1.1 + href: https://www.rstudio.com/blog/xml-1-1-1/ diff --git a/man/oldclass.Rd b/man/oldclass.Rd index 2b177569..524dddd3 100644 --- a/man/oldclass.Rd +++ b/man/oldclass.Rd @@ -8,16 +8,11 @@ \title{Register S4 classes} \description{ Classes are exported so they can be re-used within S4 classes, see \code{\link[methods:setOldClass]{methods::setOldClass()}}. - -\code{xml_document}: a complete document. - -\code{xml_missing}: a missing object, e.g. for an empty result set. - -\code{xml_node}: a single node in a document. - -\code{xml_nodeset}: a \emph{set} of nodes within a document. +\itemize{ +\item \code{xml_document}: a complete document. +\item \code{xml_nodeset}: a \emph{set} of nodes within a document. +\item \code{xml_missing}: a missing object, e.g. for an empty result set. +\item \code{xml_node}: a single node in a document. } -\concept{xml_document} -\concept{xml_missing} -\concept{xml_node} -\concept{xml_nodeset} +} +\keyword{internal} diff --git a/vignettes/releases/xml2-1.1.1.Rmd b/vignettes/releases/xml2-1.1.1.Rmd deleted file mode 100644 index 9bcb9840..00000000 --- a/vignettes/releases/xml2-1.1.1.Rmd +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: xml2 1.1.1 -output: - html_fragment ---- - -```{r setup, include=FALSE} -library(xml2) -library(xslt) -library(magrittr) - -knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>" -) -``` - - -Today we are pleased to release version 1.1.1 of xml2. xml2 makes it easy to read, create, and modify XML with R. You can install it with: - -```{r, eval = FALSE} -install.packages("xml2") -``` - -As well as fixing many bugs, this release: - -* Makes it easier to create an modify XML -* Improves roundtrip support between XML and lists -* Adds support for XML validation and XSLT transformations. - -You can see a full list of changes in the [release notes](https://github.com/r-lib/xml2/releases/tag/v1.1.1). This is the first release maintained by [Jim Hester](https://github.com/jimhester). - -## Creating and modifying XML - -xml2 has been overhauled with a set of methods to make generating and modfying XML easier: - -* `xml_new_root()` can be used to create a new document and root node - simultaneously. - - ```{r} - xml_new_root("x") %>% - xml_add_child("y") %>% - xml_root() - ``` - -* New `xml_set_text()`, `xml_set_name()`, `xml_set_attr()`, and - `xml_set_attrs()` make it easy to modify nodes within a pipeline. - - ```{r} - x <- read_xml(" - - - ") - x - - x %>% - xml_find_all(".//b") %>% - xml_set_name("banana") %>% - xml_set_attr("oldname", "b") - x - ``` - -* New `xml_add_parent()` makes it easy to insert a node as the parent of - an existing node. - -* You can create more esoteric node types with `xml_comment()` (comments), - `xml_cdata()` (CDATA nodes), and `xml_dtd()` (DTDs). - -## Coercion to and from R Lists - -xml2 1.1.1 improves support for converting to and from R lists, thanks in part -to work by [Peter Foley](https://github.com/peterfoley) and [Jenny -Bryan](https://github.com/jennybc). In particular xml2 now supports preserving the root -node name as well as saving all xml2 attributes as R attributes. These changes -allows you to convert most XML documents to and from R lists with `as_list()` -and `as_xml_document()` without loss of data. - -```{r} -x <- read_xml("") -x -as_list(x) -as_xml_document(as_list(x)) -``` - -## XML validation and xslt - -xml2 1.1.1 also adds support for XML validation, thanks to [Jeroen -Ooms](https://github.com/jeroenooms). -Simply read the document and schema files and call `xml_validate()`. - -```{r} -doc <- read_xml(system.file("extdata/order-doc.xml", package = "xml2")) -schema <- read_xml(system.file("extdata/order-schema.xml", package = "xml2")) -xml_validate(doc, schema) -``` - -Jeroen also released the first xml2 extension package in conjunction with xml2 -1.1.1, [xslt](https://cran.r-project.org/package=xslt). xslt allows one to -apply [XSLT (Extensible Stylesheet Language -Transformations)](https://en.wikipedia.org/wiki/XSLT) to XML documents, which -are great for transforming XML data into other formats such as HTML.