Skip to content

Commit f83f119

Browse files
Merge pull request #306 from lorenzwalthert/rplumber
- support rplumber syntax (#306).
2 parents 50453cb + d730f18 commit f83f119

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

R/rules-spacing.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ start_comments_with_space <- function(pd, force_one = FALSE) {
186186

187187
comments <- rematch2::re_match(
188188
pd$text[comment_pos],
189-
"^(?<prefix>#+'*)(?<space_after_prefix> *)(?<text>.*)$"
189+
"^(?<prefix>#+['\\*]*)(?<space_after_prefix> *)(?<text>.*)$"
190190
)
191191

192192
comments$space_after_prefix <- nchar(
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# myfile.R
2+
3+
#* @get /mean
4+
normalMean <- function(samples=10) {
5+
data <- rnorm(samples)
6+
mean(data)
7+
}
8+
9+
#* @post /sum
10+
addTwo <- function(a, b) {
11+
as.numeric(a) + as.numeric(b)
12+
}

tests/testthat/parse_comments/rplumber-in_tree

Lines changed: 67 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# myfile.R
2+
3+
#* @get /mean
4+
normalMean <- function(samples=10) {
5+
data <- rnorm(samples)
6+
mean(data)
7+
}
8+
9+
#* @post /sum
10+
addTwo <- function(a, b) {
11+
as.numeric(a) + as.numeric(b)
12+
}

tests/testthat/test-parse_comments.R

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,10 @@ test_that("comments are treated corectly", {
3434
transformer = style_text,
3535
write_back = TRUE), NA)
3636

37-
# top-level test with indention
37+
})
38+
39+
test_that("rplumber tags / syntax is handled properly", {
40+
expect_warning(test_collection("parse_comments",
41+
"rplumber",
42+
transformer = style_text), NA)
3843
})

0 commit comments

Comments
 (0)