Nothing
# This file will update the "function reference" section of the SimEngine
# website (https://avi-kenny.github.io/SimEngine/function-reference)
# !!!!! Run this file manually for now (eventually automate it via devtools);
# !!!!! it should be run after building the docs (SHFT+CTRL+D)
if (F) {
library(tools)
library(magrittr)
fns <- dir("man")[!(dir("man") %in% c("figures", "SimEngine-package.Rd"))]
fns <- substring(fns, 1, nchar(fns)-3)
fn_ref_path <- "docs/docs/function-reference/"
# Delete old files
for (fn in dir(fn_ref_path)) {
if (!(fn %in% c("function-reference.md"))) {
unlink(paste0(fn_ref_path, fn))
}
}
for (i in 1:length(fns)) {
# Variables
fn <- fns[i]
if (substr(fn, start = nchar(fn) - 5, stop = nchar(fn)) == ".sim_obj") {
fn2 <- substr(fn, start = 1, stop = nchar(fn) - 6)
} else {
fn2 <- fn
}
path_rd <- paste0("man/", fn, ".Rd")
path_html <- paste0(fn_ref_path, fn2, ".html")
path_md <- paste0(fn_ref_path, fn2, ".md")
# Convert Rd file to HTML
Rd2HTML(
Rd = parse_Rd(path_rd),
out = path_html,
package = "SimEngine"
)
# Read in HTML, line by line
cxn <- file(path_html, open="r")
lines <- readLines(cxn)
# Create new file
sink(path_md)
# Write Jekyll header
cat("---\n")
cat("layout: page\n")
cat(paste("title:", fn2, "\n"))
cat(paste("nav_order:", i, "\n"))
cat(paste0("permalink: /function-reference/", fn2, "/\n"))
cat("parent: Function reference\n")
cat("---\n\n")
# Rewrite/truncate HTML fragment
for (j in 1:length(lines)) {
line <- lines[j]
# Skip first 16 lines
if (j>=17) {
# Make replacements
line %<>% sub("<pre><code class='language-R'>", "```R\n", ., fixed=T)
line %<>% sub("</code></pre>", "```", ., fixed=T)
line %<>% gsub("<", "<", ., fixed=T)
line %<>% gsub(">", ">", ., fixed=T)
line %<>% gsub("<code>", "<span style='font-family:"SFMono-Regular",Menlo,Consolas,Monospace; font-size:0.85em'>", ., fixed=T)
line %<>% gsub("</code>", "</span>", ., fixed=T)
# Write lines
if (!(line %in% c("</div>", "</body></html>"))) {
cat(line)
cat("\n")
}
}
}
# Close connections
sink()
close(cxn)
# Delete original HTML file
unlink(path_html)
}
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.