Pakillo / grateful

Facilitate citation of R packages
https://pakillo.github.io/grateful/
Other
230 stars 18 forks source link

some packages not generating citations #44

Closed jkylearmstrong closed 6 months ago

jkylearmstrong commented 6 months ago

Here is a reproducible example, some packages such as survival or future are not generating citations. I'm not sure if the error is because they have multiple citations? I looked at get_citation_and_citekey and add_citekey both give outputs

---
title: "example"
bibliography:
  - grateful-refs.bib
format: pdf
---

```{r}
library('survival')
library('future')
grateful:::get_citation_and_citekey('survival')
grateful:::add_citekey('survival', citation(package = "survival"))
grateful::cite_packages(output = "paragraph",
                        out.dir = here::here(),
                        omit = NULL,
                        include.RStudio = F,
                        passive.voice = T)
sessionInfo()

[example.pdf](https://github.com/user-attachments/files/15538446/example.pdf)
Pakillo commented 6 months ago

Hi @jkylearmstrong

Thanks for the reprex. This in fact looks like a bug in how citation keys are parsed here. In particular, citation keys containing a '-' (like those for future 'RJ-2021-048' or survival package 'survival-package') are missed.

I think changing the regex to '{[\w-]+,$' could fix it, but need to make sure it works fine in all cases (comments/suggestions/alternatives welcome). I'll push a fix asap

Thanks!

jkylearmstrong commented 6 months ago

You would probably know better than I, my regex is horrible! :)

Pakillo commented 6 months ago

Should be fixed now (v 0.2.9). Please let me know if you still find problems. Thanks for reporting!

jkylearmstrong commented 5 months ago

@Pakillo - tested with the github version and it seems to work for the survival package. Thanks for putting this together! very helpful!

Pakillo commented 5 months ago

Great! Thanks for checking. Happy citing!