Skip to content

Commit 379f274

Browse files
committed
CRAN prerequisites
1 parent 198e90c commit 379f274

21 files changed

Lines changed: 242 additions & 7 deletions

.github/workflows/rhub.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# R-hub's generic GitHub Actions workflow file. It's canonical location is at
2+
# https://github.com/r-hub/actions/blob/v1/workflows/rhub.yaml
3+
# You can update this file to a newer version using the rhub2 package:
4+
#
5+
# rhub::rhub_setup()
6+
#
7+
# It is unlikely that you need to modify this file manually.
8+
9+
name: R-hub
10+
run-name: >-
11+
${{ github.event.inputs.id || format('Manual run by @{0}', github.triggering_actor) }}:
12+
${{ github.event.inputs.name || github.event.inputs.config }}
13+
14+
on:
15+
workflow_dispatch:
16+
inputs:
17+
config:
18+
description: >-
19+
Comma-separated list of R-hub platforms to use.
20+
Full list: https://r-hub.github.io/containers/
21+
type: string
22+
default: 'linux,windows,macos'
23+
name:
24+
description: 'Run name. You can leave this empty.'
25+
type: string
26+
id:
27+
description: 'Unique ID. You can leave this empty.'
28+
type: string
29+
30+
jobs:
31+
32+
setup:
33+
runs-on: ubuntu-latest
34+
outputs:
35+
containers: ${{ steps.rhub-setup.outputs.containers }}
36+
platforms: ${{ steps.rhub-setup.outputs.platforms }}
37+
38+
steps:
39+
# NO NEED TO CHECKOUT HERE
40+
- uses: r-hub/actions/setup@v1
41+
with:
42+
config: ${{ github.event.inputs.config }}
43+
id: rhub-setup
44+
45+
linux-containers:
46+
needs: setup
47+
if: ${{ needs.setup.outputs.containers != '[]' }}
48+
runs-on: ubuntu-latest
49+
name: ${{ matrix.config.label }}
50+
strategy:
51+
fail-fast: false
52+
matrix:
53+
config: ${{ fromJson(needs.setup.outputs.containers) }}
54+
container:
55+
image: ${{ matrix.config.container }}
56+
57+
steps:
58+
- uses: r-hub/actions/checkout@v1
59+
- uses: r-hub/actions/platform-info@v1
60+
with:
61+
token: ${{ secrets.RHUB_TOKEN }}
62+
job-config: ${{ matrix.config.job-config }}
63+
- uses: r-hub/actions/setup-deps@v1
64+
with:
65+
token: ${{ secrets.RHUB_TOKEN }}
66+
job-config: ${{ matrix.config.job-config }}
67+
- uses: r-hub/actions/run-check@v1
68+
with:
69+
token: ${{ secrets.RHUB_TOKEN }}
70+
job-config: ${{ matrix.config.job-config }}
71+
72+
other-platforms:
73+
needs: setup
74+
if: ${{ needs.setup.outputs.platforms != '[]' }}
75+
runs-on: ${{ matrix.config.os }}
76+
name: ${{ matrix.config.label }}
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
config: ${{ fromJson(needs.setup.outputs.platforms) }}
81+
82+
steps:
83+
- uses: r-hub/actions/checkout@v1
84+
- uses: r-hub/actions/setup-r@v1
85+
with:
86+
job-config: ${{ matrix.config.job-config }}
87+
token: ${{ secrets.RHUB_TOKEN }}
88+
- uses: r-hub/actions/platform-info@v1
89+
with:
90+
token: ${{ secrets.RHUB_TOKEN }}
91+
job-config: ${{ matrix.config.job-config }}
92+
- uses: r-hub/actions/setup-deps@v1
93+
with:
94+
job-config: ${{ matrix.config.job-config }}
95+
token: ${{ secrets.RHUB_TOKEN }}
96+
- uses: r-hub/actions/run-check@v1
97+
with:
98+
job-config: ${{ matrix.config.job-config }}
99+
token: ${{ secrets.RHUB_TOKEN }}

DESCRIPTION

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
Package: rpkgkit
2-
Title: A Set of Tools to Help You Create and Maintain an R Package
2+
Title: Create and Maintain 'R' Packages
33
Version: 0.0.7
44
Authors@R:
55
person("Yuxi", "Yang", , "15364051195@163.com", role = c("aut", "cre"))
6-
Description: A set of tools to help you create and maintain an R package.
6+
Description: Create and maintain R packages with utilities for NEWS.md
7+
management, standalone file creation, and code formatting. Supports popular
8+
development workflows and integrates with 'usethis' and 'RStudio'. Includes
9+
helper functions for renaming functions and detecting common coding errors.
710
License: MIT + file LICENSE
811
URL: https://github.com/WangLabCSU/rpkgkit
912
BugReports: https://github.com/WangLabCSU/rpkgkit/issues
@@ -32,5 +35,4 @@ Imports:
3235
cli,
3336
rlang,
3437
rstudioapi
35-
Remotes:
36-
github::wurli/pedant
38+

R/10_air_format.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
#'
1515
#' @return The exit status of the `air format` command (invisibly).
1616
#'
17+
#' @examples
18+
#' \dontrun{
19+
#' air_format(system.file("", package = "rpkgkit"))
20+
#' }
1721
#' @export
1822
air_format <- function(path = NULL, ...) {
1923
check_air_installed()

R/11_flir_fix.R

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
#'
1717
#' @return Invisibly returns the result from the called flir function.
1818
#'
19+
#' @examplesIf rlang::is_installed("flir")
20+
#' tmp <- tempfile(fileext = ".R")
21+
#' writeLines("a<-1+1", tmp)
22+
#' flir_fix(tmp)
23+
#' cat(readLines(tmp, warn = FALSE), sep = "\n")
1924
#' @export
2025
flir_fix <- function(path = NULL, ...) {
2126
rlang::check_installed("flir")

R/12_render_rmd.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@
77
#'
88
#' @return The output file path from rmarkdown::render.
99
#'
10+
#' @examples
11+
#' \dontrun{
12+
#' rlang::is_installed("rmarkdown")
13+
#' tmp <- tempfile(fileext = ".Rmd")
14+
#' writeLines(c("---", "title: Test", "---", "", "Hello, world!"), tmp)
15+
#' render_rmd(tmp)
16+
#' }
1017
#' @export
1118
render_rmd <- function(path = NULL, output_format = "md_document", ...) {
1219
rlang::check_installed("rmarkdown")

R/13_make_func_call_explicit.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ make_func_call_explicit <- function(
4242
...
4343
) {
4444
rlang::check_dots_empty0()
45-
rlang::check_installed("pedant")
45+
if (!rlang::is_installed("pedant")) {
46+
choice <- utils::askYesNo(cli::cli_fmt(cli::cli_alert_info(
47+
"{.pkg pedant} is not installed. Would you like to install it?"
48+
)))
49+
if (!isTRUE(choice)) {
50+
stop("Installation of pedant package is required")
51+
}
52+
pak::pkg_install("wurli/pedant")
53+
}
4654
path <- if (is.null(path) && rlang::is_installed("rstudioapi")) {
4755
rstudioapi::getActiveDocumentContext()$path
4856
} else {

R/20_inquire_standalone.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#'
1616
#' @details This function queries the GitHub API to list files in the R/ directory, filters for files starting with "standalone-", parses each file's YAML metadata (delimited by "# ---") and roxygen tags to extract descriptions, and generates usage code for importing each standalone file.
1717
#'
18+
#' @examples
19+
#' \dontrun{
20+
#' inquire_standalone("r-lib", "rlang")
21+
#' }
1822
#' @export
1923
inquire_standalone <- function(owner, repo, ...) {
2024
rlang::check_dots_empty0()

R/21_create_standalone.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
#'
2525
#' @return Invisibly returns the path to the created file.
2626
#'
27+
#' @examples
28+
#' \dontrun{
29+
#' create_standalone("my_utils", path = tempdir())
30+
#' }
2731
#' @export
2832
create_standalone <- function(
2933
standalone_name = NULL,

R/22_update_time_in_standalone.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#'
1111
#' @return Invisibly returns a character vector of updated file paths.
1212
#'
13+
#' @examples
14+
#' \dontrun{
15+
#' update_time_in_standalone(tempdir())
16+
#' }
1317
#' @export
1418
update_time_in_standalone <- function(path = NULL) {
1519
if (is.null(path) && rlang::is_installed("rstudioapi")) {

R/23_add_changelog_in_standalone.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
#'
1616
#' @return Invisibly returns the path to the updated file.
1717
#'
18+
#' @examples
19+
#' \dontrun{
20+
#' add_changelog_in_standalone(tempdir(), "Added new feature")
21+
#' }
1822
#' @export
1923
add_changelog_in_standalone <- function(
2024
path = NULL,

0 commit comments

Comments
 (0)