Skip to content

Commit 29cf2da

Browse files
authored
cleanup in preparation for 0.1.0 CRAN release (#14)
1 parent 36235fe commit 29cf2da

20 files changed

+101
-70
lines changed

DESCRIPTION

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: roxytypes
2-
Title: Provides Typed Parameter Tags for Integration with 'roxygen2'
3-
Version: 0.0.0.9003
2+
Title: Typed Parameter Tags for Integration with 'roxygen2'
3+
Version: 0.1.0
44
Authors@R:
55
c(
66
person(
@@ -9,12 +9,17 @@ Authors@R:
99
role = c("aut", "cre")
1010
)
1111
)
12-
Description: Provides typed parameter tags for integration with 'roxygen2'.
12+
Description: Provides typed parameter documentation tags for integration
13+
with 'roxygen2'. Typed parameter tags provide a consistent interface for
14+
annotating expected types for parameters and returned values. Tools for
15+
converting from existing styles are also provided to easily adapt projects
16+
which implement typed documentation by convention rather than tag. Use the
17+
default format or provide your own.
1318
License: MIT + file LICENSE
1419
Encoding: UTF-8
1520
URL:
1621
https://github.com/openpharma/roxytypes,
17-
https://openpharma.github.io/roxytypes
22+
https://openpharma.github.io/roxytypes/
1823
BugReports:
1924
https://github.com/openpharma/roxytypes/issues
2025
Imports:
@@ -27,9 +32,6 @@ Suggests:
2732
testthat
2833
Enhances:
2934
roxylint
30-
Remotes:
31-
openpharma/roxylint
3235
Config/Needs/documentation:
33-
roxytypes
34-
Roxygen: list(markdown = TRUE, packages = "roxytypes")
35-
RoxygenNote: 7.2.3
36+
roxylint
37+
RoxygenNote: 7.3.1

NEWS.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
# roxytypes 0.0.0.dev
1+
# roxytypes v0.1.0
2+
3+
* first CRAN release
4+
5+
# roxytypes v0.0.0.9000
26

37
* Automatically apply default formatting based on field types. For `type`
4-
fields, this will perform a default formatting
5-
(see `roxytypes:::as.character.roxy_tag_field_type`). To use another
6-
formatting style in a config, use `"{unclass(type)}"` (@dgkf #13)
8+
fields, this will perform a default formatting (see
9+
`roxytypes:::as.character.roxy_tag_field_type`). To use another formatting
10+
style in a config, use `"{unclass(type)}"` (@dgkf #13)
711

812
* Improved the stability of some custom formatting syntax, and improved
913
documentation for user-provided custom formatting functions. (@dgkf #11)

R/convert.R

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@
4242
#' }
4343
#'
4444
#' @export
45-
convert <- function(path = ".",
46-
format = config(path, refresh = TRUE, cache = FALSE)$format, ...,
47-
unmatched = FALSE, verbose = interactive()) {
48-
45+
convert <- function(
46+
path = ".",
47+
format = config(path, refresh = TRUE, cache = FALSE)$format,
48+
...,
49+
unmatched = FALSE,
50+
verbose = interactive()) {
4951
# process format to build expression for matching tag decriptions
5052
format <- build_format_regex(format, ...)
5153

@@ -62,11 +64,15 @@ convert <- function(path = ".",
6264
edits <- build_convert_edits(format, tags, unmatched = unmatched)
6365

6466
continue <- 3
65-
if (nrow(edits) > 0 && verbose) repeat {
66-
preview_convert_edits(edits, n = continue)
67-
continue <- convert_continue_prompt()
68-
if (isTRUE(continue)) break # continue with edits
69-
if (!is.numeric(continue)) return(invisible(FALSE)) # abort
67+
if (nrow(edits) > 0 && verbose) {
68+
repeat {
69+
preview_convert_edits(edits, n = continue)
70+
continue <- convert_continue_prompt()
71+
if (isTRUE(continue)) break # continue with edits
72+
if (!is.numeric(continue)) {
73+
return(invisible(FALSE))
74+
} # abort
75+
}
7076
}
7177

7278
n_edits <- make_convert_edits(edits)

R/convert_cli.R

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@
33
#' Various functions for supporting conversion from standard roxygen tags to
44
#' `@typed` tags.
55
#'
6-
#' @typed format: string
7-
#' A regular expression to use to match existing param definitions.
8-
#' @typed tags: list(roxy_tag)
9-
#' A selection of [roxygen2::roxy_tag()]s that should be considered or
10-
#' converted.
11-
#' @typed unmatched: logical[1]
12-
#' Indicates whether `@param` tags that don't match the expected pattern
13-
#' should be converted anyways. In such cases, their entire description is
14-
#' migrated to a new `@typed` description and the new `@typed` tag's type is
15-
#' left blank.
166
#' @typed edit,edits: data.frame
177
#' As produced by `convert_edit_df`. Contains the edit source file, starting
188
#' line number, number of original lines modified, the new content to insert
@@ -64,9 +54,6 @@ convert_continue_prompt <- function() {
6454
#' @describeIn convert_helpers
6555
#' Preview diffs after applying conversion rules
6656
#'
67-
#' @param tags A list of [roxygen2::roxy_tag()]s to preview
68-
#' @param n The number of tags to preview
69-
#'
7057
#' @return `NULL`
7158
#'
7259
preview_convert_edits <- function(edits, n = 1) {

R/convert_config.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#' Tools for modifying configuration files
22
#'
3-
#' @typed path,root: character[1]
3+
#' @typed path: character[1]
44
#' A file path within the package directory.
55
#' @typed dcf: data.frame
66
#' The result of [read.dcf()] on the package description file.

R/convert_re.R

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
#' A regular expression to use to match a parameter description. By default,
2828
#' matches any string.
2929
#'
30+
#' @typedreturn character[1]:
31+
#' A regular expression string, built from component sub-expressions.
32+
#'
3033
#' @examples
3134
#' re <- roxytypes:::build_format_regex(
3235
#' "{as}{any}{bs}",
@@ -37,9 +40,12 @@
3740
#'
3841
#' roxytypes:::regex_capture(re, "aaaa\n\nbb", perl = TRUE)
3942
#'
40-
build_format_regex <- function(format, format_re, ...,
41-
type = re_backticked(), description = re_any()) {
42-
43+
build_format_regex <- function(
44+
format,
45+
format_re,
46+
...,
47+
type = re_backticked(),
48+
description = re_any()) {
4349
keywords <- list(..., type = type, description = description)
4450
keywords <- mapply(
4551
function(k, v) glue::glue("(?<{k}>{v})"),

R/state_config.R

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
#' documentation is being built to avoid constantly parsing configurations
88
#' during evaluation of each tag.
99
#'
10-
#' @typed x: roxy_tag
11-
#' An internal, intermediate `roxygen2` tag object upon which to evaluate
12-
#' configured behaviors.
13-
#' @typed config: list(format= )
14-
#' A list of configuration parameters.
15-
#' @typed e: environment
16-
#' A package environment used while running `roxygen2`.
1710
#' @typed path: character[1]
1811
#' A file path to use when searching for a config file. Either the file path
1912
#' to a `DESCRIPTION` or the root path of a package, depending on the context
@@ -50,8 +43,8 @@ CONFIG <- paste0(".", utils::packageName(), "_config") # nolint
5043
#' @typedreturn list
5144
#' A named list of configured behaviors.
5245
#'
53-
#' @importFrom cli cli_alert_info
5446
#' @keywords internal
47+
#' @importFrom cli cli_alert_info
5548
config <- function(path = getwd(), refresh = FALSE, cache = TRUE) {
5649
roxytypes_config <- roxygen2::roxy_meta_get("roxytypes")
5750
if (!refresh && length(roxytypes_config) > 0)
@@ -111,8 +104,8 @@ config_from_desc <- function(path = ".") {
111104
#' @describeIn config_helpers
112105
#' Load a configuration from a dotfile
113106
#'
114-
#' @importFrom utils packageName
115107
#' @keywords internal
108+
#' @importFrom utils packageName
116109
config_from_file <- function(path = ".") {
117110
pattern <- "^meta\\.[rR]"
118111

R/tag_typed.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ NULL
8383
#' Parse a `@typed` tag and return parsed components as value
8484
#'
8585
#' @inheritParams roxygen2::roxy_tag_parse
86+
#' @typedreturn roxygen2 tag
87+
#' A parsed `roxygen2` `@typed` rd_tag.
8688
#'
8789
#' @importFrom roxygen2 roxy_tag_parse
8890
#' @exportS3Method
@@ -108,6 +110,8 @@ roxy_tag_parse.roxy_tag_typed <- function(x) { # nolint
108110
#' Push typed fields into `@param` section
109111
#'
110112
#' @inheritParams roxygen2::roxy_tag_rd
113+
#' @typedreturn [roxygen2::rd_section]
114+
#' A `roxygen2` "param" rd_section with formatted type information.
111115
#'
112116
#' @importFrom glue glue
113117
#' @importFrom roxygen2 roxy_tag_rd

R/tag_typedreturn.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
#' The `@typedreturn` tag introduces a syntax for defining return types as a
44
#' `roxygen2` tag.
55
#'
6-
#' There are a couple important syntactic features:
6+
#' There is one important syntactic features:
77
#'
8-
#' * `:` delimiter between the variable name and type.
98
#' * `\n` after the type to separate it from the description.
109
#'
1110
#' @usage
@@ -21,6 +20,8 @@ NULL
2120
#' Parse a `@typedreturn` tag and return parsed components as value
2221
#'
2322
#' @inheritParams roxygen2::roxy_tag_parse
23+
#' @typedreturn roxygen2 tag
24+
#' A parsed `roxygen2` `@typedreturn` rd_tag.
2425
#'
2526
#' @importFrom roxygen2 roxy_tag_parse
2627
#' @exportS3Method
@@ -45,6 +46,8 @@ roxy_tag_parse.roxy_tag_typedreturn <- function(x) { # nolint
4546
#' Push typed fields into `@param` section
4647
#'
4748
#' @inheritParams roxygen2::roxy_tag_rd
49+
#' @typedreturn [roxygen2::rd_section]
50+
#' A `roxygen2` `@value` rd_tag with formatted type information.
4851
#'
4952
#' @importFrom glue glue
5053
#' @importFrom roxygen2 roxy_tag_rd

cran-comments.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# roxytypes
2+
3+
## Foreseable CRAN concerns:
4+
5+
### Examples for Non-Exported Functions
6+
7+
All uses of `:::` are to access non-exported functions from within this package.
8+
They are only used for the purpose of providing example code. If possible,
9+
I would like to keep these examples as I find they are a useful resource for
10+
would-be contributors and users filing bug reports.
11+
12+
### Ensuring that Functions do not Write to the User's Home
13+
14+
There is one function (`convert()`) that has the expressed purpose of
15+
modifying a package's code (converting from roxygen `@param` tags to roxytype
16+
`@typed` tags, a drop-in replacement for use with this package). When used
17+
interactively, users are provided with a prompt that displays proposed changes
18+
before any changes are made.
19+
20+
Tests all write to a sub-directory using `tmpfile()` to generate a unique
21+
temporary directory for each test fixture.

0 commit comments

Comments
 (0)