Skip to content

Commit 326c7fe

Browse files
committed
Trying to fix help
1 parent 1c23d5b commit 326c7fe

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

R/help.R

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@
3838
sub("\\s+$", "", formatted)
3939
}
4040

41+
.iscam_rd_to_lines <- function(rd) {
42+
tmp <- tempfile(fileext = ".txt")
43+
on.exit(unlink(tmp), add = TRUE)
44+
tools::Rd2txt(rd, out = tmp)
45+
readLines(tmp, warn = FALSE)
46+
}
47+
4148
.iscam_show_help <- function(topic) {
4249
pkg_man <- system.file("man", package = "ISCAM")
4350
pkg_rd <- if (nzchar(pkg_man)) {
@@ -46,7 +53,7 @@
4653
""
4754
}
4855
if (nzchar(pkg_rd) && file.exists(pkg_rd)) {
49-
capture.output(tools::Rd2txt(pkg_rd, out = "")) |>
56+
.iscam_rd_to_lines(pkg_rd) |>
5057
.iscam_format_help() |>
5158
paste(collapse = "\n") |>
5259
cat("\n", sep = "")
@@ -68,7 +75,7 @@
6875
rd_path <- rd_paths[1]
6976

7077
if (!is.na(rd_path) && nzchar(rd_path)) {
71-
capture.output(tools::Rd2txt(rd_path, out = "")) |>
78+
.iscam_rd_to_lines(rd_path) |>
7279
.iscam_format_help() |>
7380
paste(collapse = "\n") |>
7481
cat("\n", sep = "")
@@ -81,9 +88,17 @@
8188
return(invisible(FALSE))
8289
}
8390

84-
utils:::.getHelpFile(help_obj) |>
85-
tools::Rd2txt(out = "") |>
86-
capture.output() |>
91+
rd_db <- tools::Rd_db("ISCAM")
92+
rd_key <- c(paste0(topic, ".Rd"), topic) |>
93+
intersect(names(rd_db))
94+
95+
if (length(rd_key) == 0) {
96+
cat("No documentation available for", topic, "\n")
97+
return(invisible(FALSE))
98+
}
99+
100+
rd_db[[rd_key[1]]] |>
101+
.iscam_rd_to_lines() |>
87102
.iscam_format_help() |>
88103
paste(collapse = "\n") |>
89104
cat("\n", sep = "")

0 commit comments

Comments
 (0)