Skip to content

Commit

Permalink
support rplumber syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzwalthert committed Dec 26, 2017
1 parent 1b21f75 commit d730f18
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 2 deletions.
2 changes: 1 addition & 1 deletion R/rules-spacing.R
Expand Up @@ -186,7 +186,7 @@ start_comments_with_space <- function(pd, force_one = FALSE) {

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

comments$space_after_prefix <- nchar(
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/parse_comments/rplumber-in.R
@@ -0,0 +1,12 @@
# myfile.R

#* @get /mean
normalMean <- function(samples=10) {
data <- rnorm(samples)
mean(data)
}

#* @post /sum
addTwo <- function(a, b) {
as.numeric(a) + as.numeric(b)
}
67 changes: 67 additions & 0 deletions tests/testthat/parse_comments/rplumber-in_tree

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

12 changes: 12 additions & 0 deletions tests/testthat/parse_comments/rplumber-out.R
@@ -0,0 +1,12 @@
# myfile.R

#* @get /mean
normalMean <- function(samples=10) {
data <- rnorm(samples)
mean(data)
}

#* @post /sum
addTwo <- function(a, b) {
as.numeric(a) + as.numeric(b)
}
7 changes: 6 additions & 1 deletion tests/testthat/test-parse_comments.R
Expand Up @@ -34,5 +34,10 @@ test_that("comments are treated corectly", {
transformer = style_text,
write_back = TRUE), NA)

# top-level test with indention
})

test_that("rplumber tags / syntax is handled properly", {
expect_warning(test_collection("parse_comments",
"rplumber",
transformer = style_text), NA)
})

0 comments on commit d730f18

Please sign in to comment.