GeoBosh / Rdpack

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

CSL support? #31

Open jinghuazhao opened 1 year ago

jinghuazhao commented 1 year ago

This may sound too ambitious -- but it will be great there is support for Citation Style Language (CSL) (https://citationstyles.org/), which is possible in package vignettes through a unified REFERENCES.bib.

A side effect of Rd is that citations will be duplicated which will make the package considerably closer to the 5MB ceiling for CRAN; hope R could be smarter with citations.

By all means thanks for the excellent work.

GeoBosh commented 1 year ago

Thanks for the suggestion. Could you give more details on what functionality you have in mind?

I don't quite understand the second paragraph (about the duplication). Citations from REFERENCES.bib appear in help pages if and only if they are requested. They have little effect on the size of pdf manual even if repeated in many help pages, especially if the manual is compressed.

jinghuazhao commented 1 year ago

Thanks for the quick reply. OK -- I have used CSL and recently your Rdpack in a number of packages including this one from CRAN, https://github.com/jinghuazhao/R/tree/master/gap, where I used natture-genetics.csl, The appearances in the reference section is much simplified than other styles such as American Journal of Human Genetics which includes everything.

As for the second paragraph -- we have the nice \inertRef and \insertCite in R but R translates it and unnecessarily into Rd which copies contents from REFERENCE.bib but removes it upon installation. Some references could be really long and this is a massive overhead. It would be nice R does not do that but produces the references on the fly. One example is the recent consortium called Host Genetics Initiatives whose paper includes ~3,000 authors it is unimaginable one can have a nice citation but a simplified one.

GeoBosh commented 1 year ago
  1. I could add a new style or styles. In your example above, I particularly like that the links are over the titles, which significantly reduces clutter.

  2. Regarding the second part, do you want the references to appear in the pdf manual? Please note that 'dynamic' or 'on the fly' generation means that a particular content is rendered when the help page is built, including when the pdf file is built (same for static html pages).

Actually, the Rd files are not changed when the package is built. It is true though that R expands some Rd macros and saves them in an rds object, which indeed increases the size of the package. There are good reasons to expand the macros when building a package and there are good reasons to expand later. Actually, in Rdpack 2.2 I switched to expanding the Rd macros at installation but that has other issues and CRAN were justifiably not happy since this creates additional work for them.

I could consider providing a way to request expansion when rendering the pages in html and text format but that would be separate macros or expressions.

jinghuazhao commented 1 year ago

Thanks for the comments -- I reckoned the idea will be effort from CRAN perhaps only matters to them when the point reaches the same prominence as Sweave itself, say. It is true that Rd files remain unchanged but are turned to binary format for easy access from R upon installation. It is also nice to have the references appear in the PDF. I am less familiar with feature request but feel reasonable -- the feasible way would be you work out something efficient and become a core member? Over the years, CRAN has implemented ever-increasing stringent rules to call foreign languages and syntax (also compact PDF, etc ) but would appear less consistent with this for very relaxed citations.

GeoBosh commented 1 year ago

Dynamic content can be achieved without changes to R, as I indicated in the last sentence of my previous comment. Given that you have such important packages on CRAN (and your contributors to the gap package), CRAN may be lenient if something is not quite in line.:)

jinghuazhao commented 1 year ago

Indeed it is a good thing Rd is unchanged. Never mind whichever package, it will be on the same page with others; I wish to be a good user to take advantages of things available.