Eric
Eric

Reputation: 1701

Docstring format for R reference classes

I have a specific question, but then a "teach a man to fish" question...

I am writing an R package using Reference Classes. As described here, I am placing docstrings within each method, which roxygen then picks up and places into the class' documentation (Rd) file. Here is an example method along with the docstring:

MyClass$methods(mymethod = function(argument) {
  "Do something useful
  \\subsection{Parameters}{
  \\itemize{
  \\item{\\code{argument} A useful argument.}
  }}
  \\subsection{Return Value}{Always returns 42}
  \\subsection{Example}{
  \\code{ cl <- MyClass$new() }
  \\code{ cl$mymethod() } 
  \\code{ cl$mymethod(12) }}"
  return(42)
})

The problem with this is that all my code in the "example" section ends up on one line:

cl <- MyClass$new() cl$mymethod() cl$mymethod(12)

So my immediate question is: how do I break the lines in my example code?

And my "teach a man to fish" question is, where is this docstring syntax for R documented? All my googling thus far has come up with docstring documentation for other languages that seems to have quite a different syntax and format.

Thank you!

Upvotes: 3

Views: 436

Answers (0)

Related Questions