From 2b763934d4ea457d47c853b81d2f92dbabb4b382 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Sat, 31 Jan 2026 21:07:48 +0300 Subject: [PATCH 1/4] Pre-run examples in site manual --- site/generate_reference.R | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/site/generate_reference.R b/site/generate_reference.R index 5b90c41fae..2a4cbb64ce 100644 --- a/site/generate_reference.R +++ b/site/generate_reference.R @@ -3,6 +3,7 @@ library(tools) library(xml2) +library(data.table) # Create reference directory ref_dir = "site/reference" @@ -48,8 +49,23 @@ for (rd_file in rd_files) { out_file = file.path(ref_dir, paste0(info$name, ".html")) temp_html = tempfile(fileext = ".html") - Rd2HTML(rd_file, out = temp_html, package = "data.table", Links = topic_links, Links2 = character()) - html_root = read_html(temp_html) + Rd2HTML(rd_file, out = temp_html, package = "data.table", Links = topic_links, Links2 = character(), Rhtml = TRUE) + + # The blocks are unsafe to parse as HTML, as an --> inside R code would terminate the comment. + env = new.env() + html_text = readLines(temp_html) + begin.rcode = which(startsWith(html_text, "") + stopifnot(length(begin.rcode) == length(end.rcode), begin.rcode < end.rcode) + for (i in seq_along(begin.rcode)) { + text = html_text[begin.rcode[i]:end.rcode[i]] + text[1] = sub('^" for (rd_file in rd_files) { info = all_info[[rd_file]] @@ -54,12 +57,12 @@ for (rd_file in rd_files) { # The blocks are unsafe to parse as HTML, as an --> inside R code would terminate the comment. env = new.env() html_text = readLines(temp_html) - begin.rcode = which(startsWith(html_text, "") + begin.rcode = which(grepl(Rhtml.begin, html_text)) + end.rcode = which(grepl(Rhtml.end, html_text)) stopifnot(length(begin.rcode) == length(end.rcode), begin.rcode < end.rcode) for (i in seq_along(begin.rcode)) { text = html_text[begin.rcode[i]:end.rcode[i]] - text[1] = sub('^