Skip to content

Commit 0868b0f

Browse files
more CRAN fixes
1 parent 82847c0 commit 0868b0f

17 files changed

+121
-17
lines changed

R/config.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323
#' @inheritParams fallback_doc
2424
#' @return
2525
#' Character vector of length one with the path to the config file used.
26+
#' @examples
27+
#' \dontrun{
28+
#' use_precommit_config()
29+
#' }
2630
#' @export
2731
use_precommit_config <- function(config_source = getOption("precommit.config_source"),
2832
force = FALSE,

R/exec.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
#' exists.
88
#' @return
99
#' A character vector of length one with the path to the pre-commit executable.
10+
#' @examples
11+
#' \dontrun{
12+
#' path_precommit_exec()
13+
#' }
1014
#' @export
1115
path_precommit_exec <- function(check_if_exists = TRUE) {
1216
final <- getOption("precommit.executable") %>%
@@ -27,6 +31,10 @@ path_precommit_exec <- function(check_if_exists = TRUE) {
2731
}
2832

2933
#' @rdname path_precommit_exec
34+
#' @examples
35+
#' \dontrun{
36+
#' path_pre_commit_exec()
37+
#' }
3038
#' @export
3139
path_pre_commit_exec <- function(check_if_exists = TRUE) {
3240
.Deprecated("path_precommit_exec", old = "path_pre_commit_exec")

R/install.R

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ install_system <- function(force) {
3535
#' @param force Whether or not to force a re-installation.
3636
#' @return
3737
#' The path to the pre-commit executable (invisibly).
38+
#' @examples
39+
#' \dontrun{
40+
#' install_precommit()
41+
#' }
3842
#' @export
3943
install_precommit <- function(force = FALSE) {
4044
install_system(force = force)
@@ -50,22 +54,21 @@ install_impl <- function() {
5054
}
5155

5256
install_repo <- function(root, install_hooks, legacy_hooks) {
53-
5457
withr::with_dir(root, {
5558
remove_usethis_readme_hook()
5659
out <- call_precommit(
57-
"install",
58-
if (install_hooks) "--install-hooks",
59-
if (legacy_hooks == 'remove') "--overwrite"
60+
"install",
61+
if (install_hooks) "--install-hooks",
62+
if (legacy_hooks == "remove") "--overwrite"
6063
)
6164
if (out$exit_status == 0) {
6265
if (any(grepl("Use -f to use only pre-commit.", out$stdout, fixed = TRUE))) {
63-
if (legacy_hooks == 'forbid') {
66+
if (legacy_hooks == "forbid") {
6467
rlang::abort(paste(
6568
"There are existing hooks installed for this repo and the argument",
66-
"`legacy_hooks` is set to `'forbid'`. We recommend inspecting these" ,
69+
"`legacy_hooks` is set to `'forbid'`. We recommend inspecting these",
6770
"and removing them manually or - if you are sure you don't need",
68-
"them anymore - call this function again with",
71+
"them anymore - call this function again with",
6972
"`legacy_hooks = 'remove'` to remove them for you.",
7073
"If you want to continue to use these hooks, set",
7174
"`legacy_hooks` to `'allow'`, which means pre-commit will run in ",
@@ -91,18 +94,18 @@ install_repo <- function(root, install_hooks, legacy_hooks) {
9194

9295
remove_usethis_readme_hook <- function() {
9396
legacy <- readLines(
94-
system.file("usethis-legacy-hook", package = 'precommit'),
97+
system.file("usethis-legacy-hook", package = "precommit"),
9598
encoding = "UTF-8"
9699
)
97100
candidate <- ".git/hooks/pre-commit"
98101
if (fs::file_exists(candidate)) {
99102
if (identical(readLines(candidate, encoding = "UTF-8"), legacy)) {
100103
fs::file_delete(candidate)
101104
usethis::ui_info(paste(
102-
"Removed the render-README hook, which was added with",
105+
"Removed the render-README hook, which was added with",
103106
"`usethis::use_readme_rmd()` to this repo at some point in the past.",
104-
"{{precommit}}'s equivalent is the hook with the id 'readme-rmd-rendered'.",
105-
"Add the hook to your .pre-commit-config.yaml as described here:",
107+
"{{precommit}}'s equivalent is the hook with the id 'readme-rmd-rendered'.",
108+
"Add the hook to your .pre-commit-config.yaml as described here:",
106109
"https://lorenzwalthert.github.io/precommit/#usage."
107110
))
108111
}
@@ -123,6 +126,10 @@ remove_usethis_readme_hook <- function() {
123126
#' @inheritParams fallback_doc
124127
#' @return
125128
#' `NULL` (invisibly). The function is called for its side effects.
129+
#' @examples
130+
#' \dontrun{
131+
#' uninstall_precommit()
132+
#' }
126133
#' @export
127134
uninstall_precommit <- function(scope = "repo",
128135
ask = "user",

R/open.R

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
#' @return
99
#' `NULL` (invisibly). The function is called for its side effects.
1010
#' @family helpers
11+
#' @examples
12+
#' \dontrun{
13+
#' open_config()
14+
#' }
1115
#' @export
1216
open_config <- function(root = here::here()) {
1317
if (rstudioapi::isAvailable()) {
@@ -18,8 +22,12 @@ open_config <- function(root = here::here()) {
1822
invisible(NULL)
1923
}
2024

21-
#' @export
2225
#' @rdname open_config
26+
#' @examples
27+
#' \dontrun{
28+
#' open_wordlist()
29+
#' }
30+
#' @export
2331
open_wordlist <- function(root = here::here()) {
2432
rstudioapi::navigateToFile(fs::path(root, "inst", "WORDLIST"))
2533
invisible(NULL)

R/roxygen2.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ extract_diff_root <- function(root = here::here()) {
5050
#' @return
5151
#' A logical vector of length 1.
5252
#' @inheritParams extract_diff_root
53+
#' @examples
54+
#' \dontrun{
55+
#' diff_requires_run_roxygenize()
56+
#' }
5357
#' @export
5458
diff_requires_run_roxygenize <- function(root = here::here()) {
5559
if (!rlang::is_installed("git2r")) {

R/setup.R

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
#' Get started.
44
#' @param install_hooks Whether to install environments for all available hooks.
55
#' If `FALSE`, environments are installed with first commit.
6-
#' @param legacy_hooks How to treat hooks already in the repo which are not
6+
#' @param legacy_hooks How to treat hooks already in the repo which are not
77
#' managed by pre-commit. "forbid", the default, will cause `use_precommit()`
8-
#' to fail if there are such hooks. "allow" will run these along with
8+
#' to fail if there are such hooks. "allow" will run these along with
99
#' pre-commit. "remove" will delete them.
1010
#' @inheritParams fallback_doc
1111
#' @inheritParams use_precommit_config
@@ -29,10 +29,14 @@
2929
#' @family helpers
3030
#' @return
3131
#' `NULL` (invisibly). The function is called for its side effects.
32+
#' @examples
33+
#' \dontrun{
34+
#' use_precommit()
35+
#' }
3236
#' @export
3337
use_precommit <- function(config_source = getOption("precommit.config_source"),
3438
force = FALSE,
35-
legacy_hooks = 'forbid',
39+
legacy_hooks = "forbid",
3640
open = rstudioapi::isAvailable(),
3741
install_hooks = TRUE,
3842
root = here::here()) {
@@ -58,6 +62,10 @@ use_precommit <- function(config_source = getOption("precommit.config_source"),
5862
#' @return
5963
#' The exit status from `pre-commit autoupdate` (invisibly).
6064
#' @inheritParams fallback_doc
65+
#' @examples
66+
#' \dontrun{
67+
#' autoupdate()
68+
#' }
6169
#' @export
6270
autoupdate <- function(root = here::here()) {
6371
withr::with_dir(root, {

cran-comments.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,18 @@
1313
## Downstream Dependencies
1414

1515
None.
16+
17+
## Resubmission
18+
19+
This is the first re-submission. I have:
20+
21+
- removed the redundant 'for R' from the `Title:` in DESCRIPTION.
22+
- extended `Description:` to be a longer description of what the package does in
23+
`DESCRIPTION`.
24+
- added return value documentation for exported function in the case there was
25+
none before.
26+
- added examples to the exported functions.
27+
28+
I was also asked to add references for the methods I implement but there are
29+
none as this is a tooling package that does not implement any statistical
30+
method.

inst/WORDLIST

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ dirname
2424
docopt
2525
docsearch
2626
docType
27+
dontrun
2728
emph
2829
env
2930
EOF
@@ -84,6 +85,7 @@ readme
8485
Renviron
8586
repo
8687
repos
88+
Resubmission
8789
reticulate
8890
Rhistory
8991
rlang

man/autoupdate.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/diff_requires_run_roxygenize.Rd

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)