-
Notifications
You must be signed in to change notification settings - Fork 41
/
index-des-extensions.Rmd
95 lines (79 loc) · 2.28 KB
/
index-des-extensions.Rmd
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---
title: "Index des extensions"
---
```{r options, results='hide', echo=FALSE, message=FALSE, warning=FALSE}
fichiers = list.files(pattern = ".Rmd")
fichiers <- fichiers[fichiers != 'index_fonctions.Rmd']
fichiers <- fichiers[fichiers != 'index_extensions.Rmd']
fichiers <- fichiers[fichiers != 'index_concepts.Rmd']
lf <- data.frame()
require(stringr)
for (f in fichiers) {
content <- readLines(f, encoding = "UTF-8")
content <- paste(content, collapse = " ")
chapitre <- str_match(content, 'title: "([^"]+)"')
chapitre <- chapitre[,2]
m <- str_match_all(content, '`([a-zA-Z0-9._%]+)`[{]data-pkg="([a-zA-Z0-9._]+)"')
m <- m[[1]]
if (nrow(m)>0)
lf <- rbind (lf, data.frame(
package = m[,3],
chapitre = chapitre,
page = str_replace(f, ".Rmd", ".html")
))
m <- str_match_all(content, '`([a-zA-Z0-9._%]+)`\\{\\.pkg\\}')
m <- m[[1]]
if (nrow(m)>0)
lf <- rbind (lf, data.frame(
package = m[,2],
chapitre = chapitre,
page = str_replace(f, ".Rmd", ".html")
))
m <- str_match_all(content, 'library\\(([a-zA-Z0-9._%]+)\\)')
m <- m[[1]]
if (nrow(m)>0)
lf <- rbind (lf, data.frame(
package = m[,2],
chapitre = chapitre,
page = str_replace(f, ".Rmd", ".html")
))
}
lf$package <- as.character(lf$package)
lf$chapitre <- as.character(lf$chapitre)
lf$page <- as.character(lf$page)
lf$initiale <- toupper(str_sub(lf$package, 1, 1))
lf <- lf[order(lf$initiale, lf$package, lf$chapitre), ]
lf <- lf[!duplicated(lf), ]
res <- ""
i <- ""
p <- ""
f <- ""
for (j in 1:nrow(lf)) {
if (lf[j, "initiale"] != i)
res <- paste0(res, '\n<h2 id="', lf[j, "initiale"], '">', lf[j, "initiale"], "</h2>\n\n")
i <- lf[j, "initiale"]
if (lf[j, "package"] != p) {
res <- paste0(res,
"\n<code class=\"pkg\">", lf[j, "package"], "</code>", "\n\n"
)
}
p <- lf[j, "package"]
res <- paste0(res, "* [", lf[j, "chapitre"], "](", lf[j, "page"], ")\n")
}
```
<nav class="index">
<ul class="pagination pagination-sm">
```{r, results='asis', echo=FALSE}
toc <- ""
for (i in unique(lf$initiale)) {
toc <- paste0(toc, '\n<li><a href="#', i, '">', i, '</a></li>')
}
cat(toc)
```
</ul>
</nav>
<div id="index_extensions" class="liste_index">
```{r, results='asis', echo=FALSE}
cat(res)
```
</div>