Skip to content

Commit

Permalink
chore: updates for better experience
Browse files Browse the repository at this point in the history
  • Loading branch information
radbasa committed Aug 21, 2024
1 parent ea5f235 commit f0ab89f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ BugReports: https://github.com/Appsilon/rhino/issues
License: LGPL-3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Depends:
R (>= 2.10)
Imports:
box (>= 1.1.3),
box.linters (>= 10.1.0),
box.linters (>= 0.10.2),
cli,
config,
fs,
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# rhino (development version)

* integrate {box.linters} styling functions
* add compatibility check for `treesitter` and `treesitter.r` dependencies
* Integrated {box.linters} styling functions to style `box::use()` calls according to the Rhino style guide.
* Added compatibility check for `treesitter` and `treesitter.r` dependencies

# [rhino 1.9.0](https://github.com/Appsilon/rhino/releases/tag/v1.9.0)

Expand Down
17 changes: 12 additions & 5 deletions R/tools.R
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,12 @@ rhino_style <- function() {
#' spacing around math operators is not modified to avoid conflicts with `box::use()` statements.
#'
#' `box.linters::style_*` functions require the `treesitter` and `treesitter.r` packages. These, in
#' turn, require R >= 4.3.0.
#' turn, require R >= 4.3.0. `box.linters` provides styling functions specific to the `box::use()`
#' calls. These include:
#' * Separate `box::use()` calls for packages and local modules
#' * Alphabetically sorted packages, modules, and functions.
#' * Trailing commas
#'
#'
#' @param paths Character vector of files and directories to format.
#' @return None. This function is called for side effects.
Expand All @@ -158,21 +163,23 @@ rhino_style <- function() {
#' }
#' @export
format_r <- function(paths) {
style_box_use <- box.linters::style_box_use_dir
if (!box.linters::is_treesitter_installed()) {
cli::cli_abort(
style_box_use <- function (path) { }
cli::cli_warn(
c(
"x" = "The packages {{treesitter}} and {{treesitter.r}} are required by `format_r()`",
"x" = "The packages {{treesitter}} and {{treesitter.r}} are required by some features of `format_r()`.", #nolint
"i" = "These package require R version >= 4.3.0 to install."
)
)
}

for (path in paths) {
if (fs::is_dir(path)) {
box.linters::style_box_use_dir(path)
style_box_use(path)
styler::style_dir(path, style = rhino_style)
} else {
box.linters::style_box_use_file(path)
style_box_use(path)
styler::style_file(path, style = rhino_style)
}
}
Expand Down
8 changes: 7 additions & 1 deletion man/format_r.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f0ab89f

Please sign in to comment.