Skip to content

Duplicated documentation in R6 #1504

@cbielow

Description

@cbielow

when documenting (via roxygenize() or Ctrl-Shift-d in R studio) any R6 class in my package using roxygen2_7.2.3 , e.g. the one from the example here (https://www.tidyverse.org/blog/2019/11/roxygen2-7-0-0/#r6-documentation)

i.e. input file

#' R6 Class representing a person
#'
#' A person has a name and a hair color.
Person <- R6::R6Class("Person",
                      public = list(
                        #' @field name First or full name of the person.
                        name = NULL,
                        
                        #' @field hair Hair color of the person.
                        hair = NULL,
                        
                        #' @description
                        #' Create a new person object.
                        #' @param name Name.
                        #' @param hair Hair color.
                        #' @return A new `Person` object.
                        initialize = function(name = NA, hair = NA) {
                          self$name <- name
                          self$hair <- hair
                          self$greet()
                        },
                        
                        #' @description
                        #' Change hair color.
                        #' @param val New hair color.
                        #' @examples
                        #' P <- Person("Ann", "black")
                        #' P$hair
                        #' P$set_hair("red")
                        #' P$hair
                        set_hair = function(val) {
                          self$hair <- val
                        },
                        
                        #' @description
                        #' Say hi.
                        greet = function() {
                          cat(paste0("Hello, my name is ", self$name, ".\n"))
                        }
                      )
)

results in Person.rd (note the duplicated text in \description)

% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/person.R
\name{Person}
\alias{Person}
\title{R6 Class representing a person}
\description{
R6 Class representing a person

R6 Class representing a person
}
\details{
A person has a name and a hair color.
}
\examples{
...
> sessionInfo()
R version 4.1.3 (2022-03-10)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 14393)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] roxygen2_7.2.3 rmzqc_0.5.2 

loaded via a namespace (and not attached):
 [1] jsonvalidate_1.3.2 digest_0.6.31      brio_1.1.3         ontologyIndex_2.10 R6P_0.3.0         
 [6] R6_2.5.1           jsonlite_1.8.4     lifecycle_1.0.3    magrittr_2.0.3     evaluate_0.21     
[11] rlang_1.1.0        cli_3.6.1          rstudioapi_0.14    testthat_3.1.7     vctrs_0.6.1       
[16] rmarkdown_2.21     tools_4.1.3        purrr_1.0.1        yaml_2.3.7         xfun_0.39         
[21] fastmap_1.1.1      compiler_4.1.3     htmltools_0.5.5    knitr_1.43   

Metadata

Metadata

Assignees

No one assigned

    Labels

    R6 6️⃣bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions