-
Notifications
You must be signed in to change notification settings - Fork 235
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
RC class - weird NAMESPACE #433
Comments
Your examples are parsed as
and
as of roxygen2 5.0.0. The roxygen-style comments inside the ref class definition are now part of the documentation. If you want to add the description to the documentation, use
Otherwise, simply revert to using plain comments:
See also #428 and http://stackoverflow.com/a/33530515/946850. |
So, how do you document RC classes methods and their parameters ? And how do you export only the methods you want to export? I'd expect something like this would work:
Sorry if I'm acting blind, but I cannot find an example of documenting RC methods and their parameters with roxygen. |
Does your proposed syntax work with pre-5.0.0 roxygen2? |
It does not cause errors and correctly exports the marked methods. |
Thanks, I'll take a look. It would help if you could edit your second-to last comment with the code to add triple-backticks before and after the code block. |
thx, done |
https://github.com/krlmlr/rc is what I get with roxygen2 4.1.1. Are you seeing a different behavior? Please file a pull request to that repo to show where the problem is. |
I do get a different namespace file, but I now realized that is due to us having some postprocessing, sorry about that. So the only difference is that it does not cause an error. Since I'm obviously writing the docs in a wrong way - what is the right way to document RC classes? All I found is this http://stackoverflow.com/questions/23707709/documenting-reference-class-with-roxygen2-r-cmd-check-codoc-mismatches-warning and this http://r-pkgs.had.co.nz/man.html non of which shows how to document methods. |
Actually, I think something like your syntax is what we should strive towards for RC/R6 classes (#306, #388). This was one of the reasons for this change. For now, there are docstrings: https://github.com/klutometis/roxygen/blob/master/NEWS.md#roxygen2-310 |
Actually I assumed that the docstring is no longer supported, because the example code:
Produces error: Error: '\c' is an unrecognized escape in character string starting ""Take numbers \c" Without the \code{} it does work, unless the method is "inherited", i.e.
produces
I.e. - the entry for method
produces
In my case the ancestor RC class is a library which has no docstring and in that case the child class cannot be documented at all, since roxygen seems to take the empty parent comment. |
Need to escape the Sorry, I cannot help with the inheritance issue. |
Ok, so to sum it up:
I tried to put up together a sample commented RC class:
This generates the following Rd file:
and NAMESPACE
Please correct me if I'am wrong in some point and something can be done easier. If possible I'd like to ask if the above example can be put into docs. |
@odinuv Thanks for this summary. I have pretty much arrived at the same place as you after a fair bit of pain and agree that something needs adding to the official docs! #' some description
#' @import methods
#' @exportClass SomeClass
SomeClass <- setRefClass(
'SomeClass',
contains = c('Application'),
fields = list(
),
methods = list(
#' method description
#' @param bar parameter description
#' @exportMethod
foo = function(bar) {
},
#' private method description
#' @param foo foo parameter description
#' @param bar bar parameter description
fooBar = function(foo, bar) {
}
#' another public method description
#' @param foo foo parameter description
#' @param bar bar parameter description
#' @exportMethod
fooBazBar = function(foo, bar) {
}
)
) |
Discussion of RC/R6 method docs in #388 |
Given the following code
I get a NAMESPACE file:
Using this code:
i get a namespace file:
Just for reference - this results in errors like: "classes some, lengthy, description were specified for export but not defined" or "Error in namespaceExport(ns, exports) : undefined exports: description, lengthy, some"
The text was updated successfully, but these errors were encountered: