diff --git a/R/rd-r6.R b/R/rd-r6.R index 6cac60a93..4b3e5ce09 100644 --- a/R/rd-r6.R +++ b/R/rd-r6.R @@ -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") diff --git a/tests/testthat/test-rd-r6.R b/tests/testthat/test-rd-r6.R index 40d6f766b..cf808b62f 100644 --- a/tests/testthat/test-rd-r6.R +++ b/tests/testthat/test-rd-r6.R @@ -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()