Skip to content

Commit

Permalink
minor udge case report
Browse files Browse the repository at this point in the history
  • Loading branch information
jangorecki committed Oct 18, 2024
1 parent b4defcf commit 8be3eb5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkgup/vignettes.Rmd
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
```{r, echo=FALSE, results='asis'}
if (tail(strsplit(getwd(), "/", fixed=TRUE)[[1L]], 1L) == "docs") {
if (tail(strsplit(getwd(), "/", fixed=TRUE)[[1L]], 1L) == "pkgup") {
unlink("./vignettes")
} else {
stop("vignettes.Rmd should be running from ./docs dir")
stop("vignettes.Rmd should be running from ./pkgup dir")
}
invisible(file.copy("../vignettes", ".", recursive=TRUE))
rmd = list.files("./vignettes", "*.Rmd", full.names=TRUE)
html = paste0(substr(rmd, 1L, nchar(rmd)-3L), "html")
if (!length(rmd)) {
cat("no vignettes\n")
} else {
title = function(f) {
title1 = function(f) {
if (!file.exists(f))
stop("file ", f, " does not exists")
l = readLines(f)
t = paste(head(strsplit(basename(f), ".", fixed=TRUE)[[1L]], -1L), collapse=".") ## default, basename without extension
for (i in seq_along(l)) {
Expand All @@ -24,7 +25,7 @@ if (!length(rmd)) {
}
sapply(f, title1)
}
unlink(rmd)
html = paste0(substr(rmd, 1L, nchar(rmd)-3L), "html")
lapply(html, function(f) cat(sprintf("[%s](%s)\n", title(rmd), f))) |> invisible()
}
```

0 comments on commit 8be3eb5

Please sign in to comment.