1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
library(pkgdown)
library(testthat)
debug(pkgdown:::topic_index)
build_reference_index(".")
extract_tag(rd[[1]], "tag_title") # gives "\n"
extract_tag(rd[[4]], "tag_title") # gives the title
extract_tag(rd[[1]], "tag_alias") # one aliase
extract_tag(rd[[13]], "tag_alias") # two aliases
library(magrittr)
extract_tag_1 <- function(x, tag) {
x %>%
purrr::keep(inherits, tag) %>%
unlist %>%
paste(collapse = "") %>%
trimws
}
extract_tag <- function(x, tag) {
x %>%
purrr::keep(inherits, tag) %>%
purrr::map_chr(c(1, 1))
}
extract_tag_1 <- function(x, tag) {
x %>%
purrr::keep(inherits, tag) %>%
purrr::map_chr(function(x) trimws(paste(x, collapse = " ")))
}
subset(rd[[1]][[1]],
sapply(extract_tag_1(rd[[1]], "tag_title"), function(x) trimws(paste(x, collapse = " ")))
extract_tag_1(rd[[1]], "tag_title")
extract_tag_1(rd[[4]], "tag_title")
extract_tag_1(rd[[1]], "tag_alias") # one aliase
extract_tag_1(rd[[13]], "tag_alias") # two aliases
|