Skip to content

Commit

Permalink
docs(website): better "usage" section for expressions in subnamespaces (
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennebacher committed Jan 3, 2024
1 parent c039011 commit accb214
Showing 1 changed file with 11 additions and 43 deletions.
54 changes: 11 additions & 43 deletions altdoc/altdoc_postprocessing.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ for (i in to_modify) {
"<code class='language-R'>pl$",
orig
)
} else if (which_class %in% c(
"ExprBin", "ExprCat", "ExprDT", "ExprList",
"ExprMeta", "ExprName", "ExprStr", "ExprStruct"
)) {
subns = tolower(gsub("Expr", "", which_class))

new = gsub(
paste0("<code class='language-R'>", which_class, "_"),
paste0("<code class='language-R'>&lt;Expr&gt;$", subns, "$"),
orig
)
} else {
new = gsub(
paste0("<code class='language-R'>", which_class, "_"),
Expand All @@ -67,46 +78,3 @@ for (i in to_modify) {

writeLines(new, i)
}


### Add a "Usage" section if there is none (which is the case for all Expr)

# Expr_classes = c("pl", "ExprList", "ExprBin", "ExprCat", "ExprDT", "ExprMeta",
# "ExprName", "ExprStr", "ExprStruct")
#
# to_modify2 = grep(
# paste0("/", paste(Expr_classes, collapse = "|")),
# list_man_html,
# value = TRUE
# )
#
# for (i in to_modify2) {
# which_class = gsub("docs/man/(.*)_.*$", "\\1", i)
# orig = readLines(i, warn = FALSE)
#
# if (any(grepl("<h2 id=\"usage\">Usage</h2>", orig))) {
# next
# }
#
# before_usage = grep("id=\"description\">", orig) + 1
# after_usage = grep("id=\"description\">", orig) + 2
# if (length(before_usage) == 0) {
# next
# }
#
# usage = if (grep("^Expr", which_class)) {
# paste0("&lt;Expr&gt;$", tolower(gsub("^Expr", "", which_class)))
# } else if (which_class == "pl") {
# "pl"
# }
#
# usage = paste0(usage, "$")
# new = c(
# orig[1:before_usage],
# "<h2 id=\"usage\">Usage</h2>",
# paste0("<pre><code class='language-R'>", usage),
# "</code></pre>",
# orig[after_usage:length(orig)]
# )
# writeLines(new, i)
# }

0 comments on commit accb214

Please sign in to comment.