ThinkR-open / attachment

Tools to deal with dependencies in scripts, Rmd and packages
https://thinkr-open.github.io/attachment/
Other
108 stars 13 forks source link

Escape code that needs to be escaped #47

Closed statnmap closed 2 years ago

statnmap commented 2 years ago

With the code below {attachment} detects nknitr which is because knitr is written as character in the code of the function and is on a new line. Indeed, when {attachment} reads this code, it probably reads it with FALSE}\nknitr::opts_chunk, then thinks that nknitr is a package.
We may need to escape these escapes or replace with space, or something else

create_vignette_head <- function(pkg, vignette_name, yaml_options = NULL) {
  pkgname <- basename(pkg)

  # Get all yaml options except Title, output, editor_options
  yaml_options <- yaml_options[
    !names(yaml_options) %in% c("output", "title", "editor_options")]

  enc2utf8(
    glue(
      '---
title: ".{vignette_name}."
output: rmarkdown::html_vignette',
      ifelse(length(yaml_options) != 0,
             glue::glue_collapse(
               c("",
                 glue("{names(yaml_options)}: \"{yaml_options}\""), ""),
               sep = "\n"),
             "\n"),
      'vignette: >
  %\\VignetteIndexEntry{.{vignette_name}.}
  %\\VignetteEngine{knitr::rmarkdown}
  %\\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(.{pkgname}.)
',
.open = ".{", .close = "}."
)

) }

LBeaulaton commented 2 years ago

Hi thanks for all your work. I confirm this issue. I have a warning message with a carriage return before 'keyring::key_set' and I get the following message: Erreur dans att_to_desc_from_is(path.d, imports, suggests, normalize, must.exist) : The package nkeyring is missing or misspelled. Please correct your typo or install it.