Skip to content

Commit

Permalink
Remove R6 tag if cannot be matched to anything
Browse files Browse the repository at this point in the history
  • Loading branch information
gaborcsardi committed Oct 3, 2019
1 parent efff7ea commit b52ac49
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions R/rd-r6.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ topic_add_r6_methods <- function(rd, block, env) {
if (is.na(tag$line) || tag$line < block$line) next
# Not a method tag?
if (! tag$tag %in% r6_tags) next
del <- c(del, i)
meth <- find_method_for_tag(methods, tag)
if (is.na(meth)) {
roxy_tag_warning(tag, "Cannot find matching R6 method")
Expand Down
26 changes: 26 additions & 0 deletions tests/testthat/test-rd-r6.R
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,32 @@ test_that("R56 edge cases, class without anything", {
expect_false(grepl("active", format(rd), ignore.case = TRUE))
})

test_that("warning if no method comes after the docs", {
text <- "
#' @title Title
#' @description Description.
#' @details Details.
#' @field field1 Yep.
C <- R6::R6Class(
public = list(
#' @description Method 1.
method1 = function() { },
#' @description Dangling.
field1 = NULL
)
)"

eval(parse(text = text, keep.source = TRUE))
block <- parse_text(text, env = environment())[[1]]
rd <- RoxyTopic$new()

expect_warning(
topic_add_r6_methods(rd, block, environment()),
"Cannot find matching R6 method"
)
doc <- format(rd)
})

test_that("integration test", {

wd <- getwd()
Expand Down

0 comments on commit b52ac49

Please sign in to comment.