altdoc
altdoc copied to clipboard
refactor/use tinkr in rd2md
or simply use Rd2md::Rd2markdown?
(I think I thought about that but let it aside for some reason)
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")
}
This is probably outdated as quarto
will be preferred to convert Rd to md (#54, #62)