GeoBosh / Rdpack

R package Rdpack provides functions and macros facilitating writing and management of R documentation.
https://geobosh.github.io/Rdpack/
28 stars 6 forks source link

R6 class methods #35

Closed albersonmiranda closed 3 months ago

albersonmiranda commented 3 months ago

Hi Georgi!

Closely related to #27 , I'm having a really hard time trying to get @references section to work. For every citation in this R6 class, I get a corresponding There are no references for Rd macro ⁠\insertAllCites⁠ on this help page. in References section. Replacing \insertAllCited{} by \insertCited{} didn't do the trick.

I'd really appreciate it if you could kindly point me in the right direction.

GeoBosh commented 3 months ago

Thanks for the report. I should document this explicitly, the exchange in #27 mostly clarifies this but is no joy to read. Here is a recap of the problem, see #27 for more details.

roxygen2 combines all @references appearing in methods descriptions and creates a single reference section at the top level. This suggests that you should at least get the list of references, combined at the top level of the class. Unfortunately, this does not happen, as roxygen2 mechanically merges the contents of all @references tags into a section at the top level of the class AND puts those before the descriptions of the methods. The net result is that the macro \insertAllCited is expanded before the other insert commands are seen - and you get the message that there are no references (yet).

So, if you want reference sections in methods pages, don't use @references. You can just remove @references from the methods sections (leaving in \insertCited{}) to see that this works. You can create roxygen subsections 'References' if you wish.

Note that I was not able to build your package. I installed rust but I get Rust errors when building the package and I have zero knowledge about Rust to fix them.

Let me know if this helps.

albersonmiranda commented 3 months ago

Thanks for the detailed recap! Using custom section didn't work for me (it generates same error than using @references)

#' @section References:
#' \insertCited{}

On the other hand, appending to @details worked:

#' @details
[...]
#' ## References:
#' \insertCited{}
GeoBosh commented 3 months ago

Indeed, a subsection, a could have given the example you succeeded with.

albersonmiranda commented 3 months ago

Perfect! Thank you very much!