luisDVA / annotater

Annotate Package Load Calls
https://annotater.liomys.mx/
Other
99 stars 2 forks source link

Task 17: Feature - Annotate R version #24

Closed jcrodriguez1989 closed 2 weeks ago

jcrodriguez1989 commented 3 weeks ago

Develops https://github.com/luisDVA/annotater/issues/17 At the beginning of the file to annotate, it will add:

# R version 4.2.1 (2022-06-23)
# Platform: x86_64-apple-darwin17.0 (64-bit)
# Running under: macOS 15.0
# Rstudio 2024.9.0.375 (Cranberry Hibiscus)
# 
jcrodriguez1989 commented 2 weeks ago

You're absolutely right, I totally forgot the Rmd/Qmd use case. I will think about working alternatives.

jcrodriguez1989 commented 2 weeks ago

@luisDVA , please let me know if the current changes fix the markdown issues. I don't use Rmd and Qmd that much, so probably my tests are not that extensive.

In this version, the R version should be added as the first line of the first ```{r} chunk, if there is no such chunk, it will add it as the header of the file. Because I am not aware of a way of detecting wether an unsaved file is a markdown or script file.

luisDVA commented 2 weeks ago

good idea! this is a nice approach, but in Quarto inserting comments this way may prevent the code block options from being applied.

for example: if the "hashpipe" operator is used to specify any options, adding anything before this section will void the options.

```{r}
#| include: false
#| eval: true
...


I wonder if the regex can be changed to paste the annotations after the last `#|` in the first chunk 🤔
jcrodriguez1989 commented 2 weeks ago

@luisDVA , good note! Let me know if it works correct with these last changes.

luisDVA commented 2 weeks ago

works great now with all formats. gracias y aguante Córdoba