Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

formatting a R6 object with roxygen2 documentation fails #83

Closed
3 tasks done
maarten-k opened this issue Feb 20, 2020 · 1 comment
Closed
3 tasks done

formatting a R6 object with roxygen2 documentation fails #83

maarten-k opened this issue Feb 20, 2020 · 1 comment
Labels

Comments

@maarten-k
Copy link

formatting a R6 object with roxygen2 documentation fails with:

tidying /tmp/r6.R
Error in base::parse(text = code, keep.source = FALSE) : 
  <text>:7:1: unexpected symbol
6: invisible(".BeGiN_TiDy_IdEnTiFiEr_HaHaHa#' @field name First or full name of the person..HaHaHa_EnD_TiDy_IdEnTiFiEr")
7: name

It would be nice to have this formated in an nice way.

code to reproduce:

code of the R6 is taken from https://www.tidyverse.org/blog/2019/11/roxygen2-7-0-0/

cat > /tmp/r6.R << 'EOF'
#' 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"))
    }
  )
)
EOF
Rscript -e 'formatR::tidy_file("/tmp/r6.R")'

version info

R version 3.6.0 (2019-04-26)
Platform: x86_64-conda_cos6-linux-gnu (64-bit)
Running under: KDE neon User Edition 5.18

Locale:
LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
LC_TIME=nl_NL.UTF-8 LC_COLLATE=en_US.UTF-8
LC_MONETARY=nl_NL.UTF-8 LC_MESSAGES=en_US.UTF-8
LC_PAPER=nl_NL.UTF-8 LC_NAME=C
LC_ADDRESS=C LC_TELEPHONE=C
LC_MEASUREMENT=nl_NL.UTF-8 LC_IDENTIFICATION=C

Package version:
formatR_1.7


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('formatR'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('yihui/formatR').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

@yihui
Copy link
Owner

yihui commented Feb 21, 2020

It is a known limitation: https://yihui.org/formatr/#6-further-notes Thanks!

@yihui yihui closed this as completed Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants