Remove empty lines between roxygen docs and code?
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
Research direction
Start by reproducing the reported cases with styler::style_text and reviewing the existing behavior for roxygen documentation and R6 lists. The proposed rule is not settled: determine whether empty lines should be removed or reduced to one, and how comment blocks are handled. Done means the project has an agreed, consistent formatting rule and matching behavior.
Written by the indexing model from the issue text.
Description
AFAIK, there are currently no guidelines about this in the tidyverse style guide, but I was wondering if {styler} should adopt a convention to remove empty lines between roxygen documentation and the code.
- Actual
In the wild, I often come across codebases that have formatting like the following. The count of empty spurious lines may differ across files. Currently, {styler} preserves such empty lines.
styler::style_text(
"#' @export
foo <- function() NULL"
)
#> #' @export
#>
#>
#>
#> foo <- function() NULL
- Expected new behavior
I wish {styler} could remove such inconsistencies and adopt a single rule. I'd propose that it removes all empty lines by default, but I am also open to other rules (e.g. always have a single empty line). The point is more about consistency in formatting.
#> #' @export
#> foo <- function() NULL
- Exception
Just like in formatting R6 lists, I think one exception to this rule could be the presence of a comment block before the function. In such cases, a single empty line can be preserved.
styler::style_text(
"#' @export
# bla bla bla
foo <- function() NULL"
)
#> #' @export
#>
#> # bla bla bla
#> foo <- function() NULL
Curious to hear what you think.
- Dominant language
- R
- Stars
- 773
- Forks
- 74
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from r-lib/styler
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
NEWS page broken? Open
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
documentation
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·