altdoc icon indicating copy to clipboard operation
altdoc copied to clipboard

refactor/use tinkr in rd2md

Open etiennebacher opened this issue 2 years ago • 1 comments

or simply use Rd2md::Rd2markdown?

(I think I thought about that but let it aside for some reason)

etiennebacher avatar Apr 06 '22 15:04 etiennebacher

The reason is that the code block in Details in reformat_md() was not properly parsed.

Possible to use the following code and to remove custom rd2md() once https://github.com/quantsch/Rd2md/issues/6 has been resolved:

make_reference <- function() {

  if (fs::file_exists("docs/reference.md")) fs::file_delete("docs/reference.md")
  fs::file_create("docs/reference.md")

  files <- list.files("man")
  files <- files[grepl("\\.Rd", files)]

  lapply(files, function(x){
    input <- paste0("man/", x)
    Rd2md::Rd2markdown(input, "docs/reference.md", append = TRUE)
  })

  reformat_md("docs/reference.md", first = TRUE)

  x <- readLines("docs/reference.md")
  title <- gsub(".Rd", "", files)
  title <- gsub("_", " ",  title)
  title <- tools::toTitleCase(title)
  subsections <- which(grepl("^## ", x))
  for (i in seq_along(title)) {
    id <- subsections[i]
    x[id] <- paste0("## ", title[i])
  }

  y <- c("# Reference\n", x)
  writeLines(y, "docs/reference.md")
}

etiennebacher avatar Apr 07 '22 07:04 etiennebacher

This is probably outdated as quarto will be preferred to convert Rd to md (#54, #62)

etiennebacher avatar Nov 08 '23 15:11 etiennebacher