Skip to content

Commit 5a92c4b

Browse files
authored
Merge pull request #82 from jmbarbone/docs-and-tests
docs, tests, formats
2 parents 7fe5bc0 + 9a03495 commit 5a92c4b

24 files changed

Lines changed: 197 additions & 156 deletions

.github/workflows/R-CMD-check.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ on:
44
push:
55
branches: [main, master]
66
pull_request:
7-
branches: [main, master]
87

9-
name: R-CMD-check
8+
name: R-CMD-check.yaml
9+
10+
permissions: read-all
1011

1112
jobs:
1213
R-CMD-check:
@@ -29,7 +30,7 @@ jobs:
2930
R_KEEP_PKG_SOURCE: yes
3031

3132
steps:
32-
- uses: actions/checkout@v3
33+
- uses: actions/checkout@v4
3334

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

@@ -47,3 +48,4 @@ jobs:
4748
- uses: r-lib/actions/check-r-package@v2
4849
with:
4950
upload-snapshots: true
51+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

.github/workflows/lint.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@ on:
44
push:
55
branches: [main, master]
66
pull_request:
7-
branches: [main, master]
87

9-
name: lint
8+
name: lint.yaml
9+
10+
permissions: read-all
1011

1112
jobs:
1213
lint:
1314
runs-on: ubuntu-latest
1415
env:
1516
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1617
steps:
17-
- uses: actions/checkout@v3
18+
- uses: actions/checkout@v4
1819

1920
- uses: r-lib/actions/setup-r@v2
2021
with:

.github/workflows/pkgdown.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ on:
44
push:
55
branches: [main, master]
66
pull_request:
7-
branches: [main, master]
87
release:
98
types: [published]
109
workflow_dispatch:
1110

12-
name: pkgdown
11+
name: pkgdown.yaml
12+
13+
permissions: read-all
1314

1415
jobs:
1516
pkgdown:
@@ -19,8 +20,10 @@ jobs:
1920
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
2021
env:
2122
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
23+
permissions:
24+
contents: write
2225
steps:
23-
- uses: actions/checkout@v3
26+
- uses: actions/checkout@v4
2427

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

@@ -39,7 +42,7 @@ jobs:
3942

4043
- name: Deploy to GitHub pages 🚀
4144
if: github.event_name != 'pull_request'
42-
uses: JamesIves/github-pages-deploy-action@v4.4.1
45+
uses: JamesIves/github-pages-deploy-action@v4.5.0
4346
with:
4447
clean: false
4548
branch: gh-pages

.github/workflows/test-coverage.yaml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ on:
44
push:
55
branches: [main, master]
66
pull_request:
7-
branches: [main, master]
87

9-
name: test-coverage
8+
name: test-coverage.yaml
9+
10+
permissions: read-all
1011

1112
jobs:
1213
test-coverage:
@@ -15,36 +16,47 @@ jobs:
1516
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1617

1718
steps:
18-
- uses: actions/checkout@v3
19+
- uses: actions/checkout@v4
1920

2021
- uses: r-lib/actions/setup-r@v2
2122
with:
2223
use-public-rspm: true
2324

2425
- uses: r-lib/actions/setup-r-dependencies@v2
2526
with:
26-
extra-packages: any::covr
27+
extra-packages: any::covr, any::xml2
2728
needs: coverage
2829

2930
- name: Test coverage
3031
run: |
31-
covr::codecov(
32+
cov <- covr::package_coverage(
3233
quiet = FALSE,
3334
clean = FALSE,
34-
install_path = file.path(Sys.getenv("RUNNER_TEMP"), "package")
35+
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
3536
)
37+
print(cov)
38+
covr::to_cobertura(cov)
3639
shell: Rscript {0}
3740

41+
- uses: codecov/codecov-action@v5
42+
with:
43+
# Fail if error if not on PR, or if on PR and token is given
44+
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
45+
files: ./cobertura.xml
46+
plugins: noop
47+
disable_search: true
48+
token: ${{ secrets.CODECOV_TOKEN }}
49+
3850
- name: Show testthat output
3951
if: always()
4052
run: |
4153
## --------------------------------------------------------------------
42-
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
54+
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
4355
shell: bash
4456

4557
- name: Upload test results
4658
if: failure()
47-
uses: actions/upload-artifact@v3
59+
uses: actions/upload-artifact@v4
4860
with:
4961
name: coverage-test-failures
5062
path: ${{ runner.temp }}/package

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: scribe
22
Title: Command Argument Parsing
3-
Version: 0.3.0.9002
3+
Version: 0.3.0.9004
44
Authors@R:
55
person(
66
given = "Jordan Mark",
@@ -16,7 +16,6 @@ License: MIT + file LICENSE
1616
Encoding: UTF-8
1717
Language: en-US
1818
Roxygen: list(markdown = TRUE)
19-
RoxygenNote: 7.3.1
2019
Depends:
2120
R (>= 3.6)
2221
Imports:
@@ -34,3 +33,4 @@ VignetteBuilder: knitr
3433
URL: https://jmbarbone.github.io/scribe/, https://github.com/jmbarbone/scribe
3534
BugReports: https://github.com/jmbarbone/scribe/issues
3635
Config/testthat/parallel: true
36+
Config/roxygen2/version: 8.0.0

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ These are not meant to be user accessible.
1717
- `arg$show()` now prints values of class `"scribe_empty_value"` as `<empty>`
1818
- `arg$add_argument()` correctly passes all method arguments [#78](https://github.com/jmbarbone/scribe/issues/78)
1919
- `ca$parse()` correctly deals with new arguments that nave the same _name_ as ones in `included` [#80](https://github.com/jmbarbone/scribe/issues/80)
20+
- internal documentation updates
2021

2122
# scribe 0.3.0
2223

R/arg.R

Lines changed: 30 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#' New command argument
32
#'
43
#' Make a new [scribeArg] object
@@ -13,25 +12,25 @@
1312
#' @family scribe
1413
#' @export
1514
new_arg <- function(
16-
aliases = "",
17-
action = arg_actions(),
18-
default = NULL,
19-
convert = scribe_convert(),
20-
n = NA_integer_,
21-
info = NULL,
22-
options = list(),
23-
stop = c("none", "hard", "soft"),
24-
execute = invisible
15+
aliases = "",
16+
action = arg_actions(),
17+
default = NULL,
18+
convert = scribe_convert(),
19+
n = NA_integer_,
20+
info = NULL,
21+
options = list(),
22+
stop = c("none", "hard", "soft"),
23+
execute = invisible
2524
) {
2625
scribeArg$new(
2726
aliases = aliases,
28-
action = action,
27+
action = action,
2928
default = default,
3029
convert = convert,
31-
n = n,
32-
info = info,
30+
n = n,
31+
info = info,
3332
options = options,
34-
stop = stop,
33+
stop = stop,
3534
execute = execute
3635
)
3736
}
@@ -48,7 +47,7 @@ scribe_help_arg <- function() {
4847
execute = function(self, ca) {
4948
if (isTRUE(self$get_value())) {
5049
ca$help()
51-
return(exit())
50+
exit()
5251
}
5352
}
5453
)
@@ -68,29 +67,28 @@ scribe_version_arg <- function() {
6867
if (isTRUE(self$get_value())) {
6968
.Deprecated("For {scribe} package version, use ---version instead")
7069
ca$version()
71-
return(exit())
70+
exit()
7271
}
7372
}
7473
)
7574
}
7675

7776
# wrappers ----------------------------------------------------------------
7877

79-
# nolint next: cyclocomp_linter.
8078
arg_initialize <- function(
81-
self,
82-
aliases = "",
83-
action = arg_actions(),
84-
default = NULL,
85-
convert = scribe_convert(),
86-
n = NA_integer_,
87-
info = NA_character_,
88-
options = list(),
89-
stop = c("none", "hard", "soft"),
90-
execute = invisible
79+
self,
80+
aliases = "",
81+
action = arg_actions(),
82+
default = NULL,
83+
convert = scribe_convert(),
84+
n = NA_integer_,
85+
info = NA_character_,
86+
options = list(),
87+
stop = c("none", "hard", "soft"),
88+
execute = invisible
9189
) {
92-
action <- match.arg(action, arg_actions())
93-
info <- info %||% NA_character_
90+
action <- match.arg(action, arg_actions())
91+
info <- info %||% NA_character_
9492
options <- options %||% list()
9593

9694
if (action == "default") {
@@ -314,7 +312,7 @@ arg_get_help <- function(self) {
314312
list = {
315313
left <- paste(
316314
to_string(self$get_aliases(), sep = ", "),
317-
sprintf("[%s]", if (self$n == 1) "ARG" else sprintf("..%i", self$n))
315+
sprintf("[%s]", if (self$n == 1) "ARG" else sprintf("..%i", self$n))
318316
)
319317

320318
right <- self$info
@@ -374,7 +372,7 @@ arg_get_name <- function(self, clean = TRUE) {
374372
nm
375373
}
376374

377-
arg_get_action <- function(self) {
375+
arg_get_action <- function(self) {
378376
self$action %||% character()
379377
}
380378

@@ -400,7 +398,6 @@ arg_is_resolved <- function(self) {
400398

401399
# internal ----------------------------------------------------------------
402400

403-
# nolint next: cyclocomp_linter.
404401
arg_parse_value <- function(self, ca) {
405402
default <-
406403
if (is_arg(self$default)) {
@@ -508,7 +505,7 @@ is_arg <- function(x) {
508505
methods::is(x, "scribeArg")
509506
}
510507

511-
ARG_PAT <- "^-[a-z]$|^---?[a-z]+$|^--?[a-z](+[-]?[a-z]+)+$" # nolint: object_name_linter, line_length_linter.
508+
ARG_PAT <- "^-[a-z]$|^---?[a-z]+$|^--?[a-z](+[-]?[a-z]+)+$" # nolint: object_name_linter, line_length_linter.
512509

513510
arg_actions <- function() {
514511
c("default", "list", "flag", "dots")

R/class-args.R

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#' {scribe} argument
32
#'
43
#' ReferenceClass object for managing arguments
@@ -75,32 +74,32 @@
7574
# nolint next: object_name_linter.
7675
scribeArg <- methods::setRefClass(
7776
"scribeArg",
78-
fields = list(
79-
aliases = "character",
80-
action = "character",
81-
default = "ANY",
82-
convert = "ANY",
83-
n = "integer",
84-
info = "character",
85-
options = "list",
77+
fields = list(
78+
aliases = "character",
79+
action = "character",
80+
default = "ANY",
81+
convert = "ANY",
82+
n = "integer",
83+
info = "character",
84+
options = "list",
8685
positional = "logical",
87-
resolved = "logical",
88-
value = "ANY",
89-
stop = "character",
90-
execute = "function"
86+
resolved = "logical",
87+
value = "ANY",
88+
stop = "character",
89+
execute = "function"
9190
)
9291
)
9392

9493
scribeArg$methods(
9594
initialize = function(
9695
aliases = "",
97-
action = arg_actions(),
96+
action = arg_actions(),
9897
default = NULL,
9998
convert = scribe_convert(),
100-
n = NA_integer_,
101-
info = NA_character_,
99+
n = NA_integer_,
100+
info = NA_character_,
102101
options = list(),
103-
stop = c("none", "hard", "soft"),
102+
stop = c("none", "hard", "soft"),
104103
execute = invisible
105104
) {
106105
"
@@ -109,15 +108,15 @@ scribeArg$methods(
109108
See \\strong{fields} for parameter information.
110109
"
111110
arg_initialize(
112-
self = .self,
111+
self = .self,
113112
aliases = aliases,
114-
action = action,
113+
action = action,
115114
default = default,
116115
convert = convert,
117-
n = n,
118-
info = info,
116+
n = n,
117+
info = info,
119118
options = options,
120-
stop = stop,
119+
stop = stop,
121120
execute = execute
122121
)
123122
},
@@ -186,7 +185,7 @@ scribeSuperArg$methods(
186185
}
187186

188187
arg_initialize(
189-
self = .self,
188+
self = .self,
190189
aliases = aliases,
191190
...
192191
)

0 commit comments

Comments
 (0)