Nvim-R icon indicating copy to clipboard operation
Nvim-R copied to clipboard

Problems rendering citations created with Rdpack

Open dhersz opened this issue 3 years ago • 1 comments

Hi! I have recently started using Rdpack to manage citations in the documentation of a package I'm developing. They don't seem to render correctly when reading the docs with Nvim-R, although they do work fine with RStudio and pkgdown.

Here's a sample documentation code from accessibility:

#' Floating catchment area accessibility
#'
#' Calculates accessibility accounting for the competition of resources using
#' one of the multiple accessibility metrics in the floating catchment area
#' family. The function currently includes `2SFCA` 2-Step Floating Catchment
#' Area \insertCite{luo2003measures}{accessibility}, and `BFCA` Balanced
#' Floating Catchment Area \insertCite{paez2019demand}{accessibility}.
#' Accessibility can be calculated using multiple alternative decay functions
#' passed through the `decay_function` parameter.
#' ...
#' ...
#' ...
#' @references
#' \insertAllCited{}

This is how it gets rendered by Nvim-R:

Description:

     Calculates accessibility accounting for the competition of
     resources using one of the multiple accessibility metrics in the
     floating catchment area family. The function currently includes
     2SFCA 2-Step Floating Catchment Area
     \Sexpr[results=rd,stage=build]{if(!exists(".Rdpack.currefs"))
     .Rdpack.currefs <-
     new.env();Rdpack::insert_citeOnly(key="luo2003measures",package="accessibility",
     cached_env=.Rdpack.currefs)}, and ‘BFCA’ Balanced Floating
     Catchment Area
     \Sexpr[results=rd,stage=build]{if(!exists(".Rdpack.currefs"))
     .Rdpack.currefs <-
     new.env();Rdpack::insert_citeOnly(key="paez2019demand",package="accessibility",
     cached_env=.Rdpack.currefs)}. Accessibility can be calculated
     using multiple alternative decay functions passed through the
     ‘decay_function’ parameter.

This is how it looks in the pkgdown page and in RStudio:

Description Calculates accessibility accounting for the competition of resources using one of the multiple accessibility metrics in the floating catchment area family. The function currently includes ⁠2SFCA⁠ 2-Step Floating Catchment Area (Luo and Wang 2003), and BFCA Balanced Floating Catchment Area (Paez et al. 2019). Accessibility can be calculated using multiple alternative decay functions passed through the decay_function parameter.

I tried searching for related issues here but couldn't find any. Perhaps this is something related to, more generally, Rd macros, and not necessarily Rdpack?

dhersz avatar Jul 14 '22 16:07 dhersz

I'm no longer developing new R packages. So, it would be great if someone could do a pull request fixing the issue...

jalvesaq avatar Jul 16 '22 13:07 jalvesaq

I installed the accessibility package... There is no citation in the description of floating_catchment_area, but there is one in cumulative_interval. Using R-devel (4.3.0), when I press <LocalLeader>rh over the function name, the description appears to me as:

image

And, during omni completion, the floating window shows:

image

jalvesaq avatar Oct 25 '22 11:10 jalvesaq

Hi @jalvesaq, thanks for looking into this. I'm not sure what happened, but now the citations also render correctly here! Very cool.

Thank you again, and if I ever come across this issue again I'll try to further investigate what's causing it. Cheers.

dhersz avatar Oct 25 '22 13:10 dhersz