33# ' @param file Path of file
44# ' @param pattern Pattern to replace
55# ' @param replacement A character vector of replacements
6- # '
6+ # ' @noRd
77replace_in_file <- function (file , pattern , replacement ) {
88 a <- readLines(file )
99 a <- gsub(pattern , replacement , a )
@@ -16,7 +16,7 @@ replace_in_file <- function(file, pattern, replacement) {
1616# ' @param dir Name of the dir where to write file
1717# ' @param rmd name and type of the file to write in
1818# ' @param repo Path to directory where to store "dir"
19- # '
19+ # ' @noRd
2020write_in <- function (x , repo , dir = " gitdown" , rmd = " index.Rmd" ) {
2121 dir_out <- normalizePath(file.path(repo , dir ))
2222 if (! dir.exists(dir_out )) {dir.create(dir_out )}
@@ -27,6 +27,7 @@ write_in <- function(x, repo, dir = "gitdown", rmd = "index.Rmd") {
2727# ' Presentation of commit
2828# '
2929# ' @param commit one line data from get_commits_pattern
30+ # ' @noRd
3031
3132presentation_commit <- function (commit ) {
3233 res <- paste0(
@@ -65,6 +66,7 @@ presentation_commit <- function(commit) {
6566# '
6667# ' @importFrom purrr map_chr
6768# '
69+ # ' @noRd
6870
6971each_commit <- function (commits , pattern.content , link_pattern , pattern.type , pattern.title ) {
7072 # if no commits
@@ -89,6 +91,7 @@ each_commit <- function(commits, pattern.content, link_pattern, pattern.type, pa
8991
9092# ' To singular
9193# ' @param x Character
94+ # ' @noRd
9295to_singular <- function (x ) {
9396 gsub(" s$" , " " , x )
9497}
@@ -101,13 +104,32 @@ to_singular <- function(x) {
101104# ' @importFrom stringi stri_extract_all
102105# ' @importFrom tidyr nest
103106# '
104- # ' @return A tibble with a row for each different pattern found and
107+ # ' @return A tibble with a row for each different pattern found in commit messages
108+ # ' and following columns:
109+ # '
110+ # ' - pattern.type: name of the pattern found in the commit message
111+ # ' - pattern.content: pattern found in the commit message
112+ # ' - pattern.title: pattern.content or title used in the pattern.table
105113# ' a nested 'data' column with all related commits
114+ # ' - pattern_numeric: extraction of numeric value in pattern.content
115+ # ' - link_pattern: internal url of the pattern in the future HTML gitbook
116+ # ' - data: a nested list of tibbles with commits content as issued from [get_commits_pattern()]
106117# '
107118# ' @export
108119# ' @examples
109120# ' repo <- fake_repo()
110121# ' nest_commits_by_pattern(repo)
122+ # '
123+ # ' # With table of correspondence
124+ # ' pattern.table <- data.frame(
125+ # ' number = c("#2", "#1", "#1000"),
126+ # ' title = c("#2 A second issue to illustrate a blog post",
127+ # ' "#1 An example of issue",
128+ # ' "#1000 issue with no commit"))
129+ # ' nest_commits_by_pattern(
130+ # ' repo,
131+ # ' pattern.table = pattern.table,
132+ # ' pattern = c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"))
111133
112134nest_commits_by_pattern <- function (repo ,
113135 pattern = c(" Issues" = " #[[:digit:]]+" ),
@@ -172,7 +194,18 @@ nest_commits_by_pattern <- function(repo,
172194# ' @importFrom purrr map_chr pmap
173195# ' @export
174196# ' @return A tibble with a row for each different pattern found and
175- # ' a 'text' column to be included in a markdown file.
197+ # ' a 'text' column to be included in a markdown file:
198+ # '
199+ # ' - pattern.content: pattern found in the commit message
200+ # ' - link_pattern: internal url of the pattern in the future HTML gitbook
201+ # ' - text: list of vectors of markdown text to present commits of each pattern
202+ # ' in the HTML gitbook output
203+ # ' - pattern.type: name of the pattern found in the commit message
204+ # ' - pattern.title: pattern.content or title used in the pattern.table
205+ # ' a nested 'data' column with all related commits
206+ # ' - pattern_numeric: extraction of numeric value in pattern.content
207+ # ' - data: a nested list of tibbles with commits content as issued from [get_commits_pattern()]
208+ # '
176209# ' @examples
177210# ' repo <- fake_repo()
178211# ' res_commits <- nest_commits_by_pattern(
@@ -233,6 +266,7 @@ each_pattern <- function(nest_commits, pattern.type) {
233266
234267# ' Clean link
235268# ' @param x Character to clean to transform as slug
269+ # ' @noRd
236270
237271clean_link <- function (x ) {
238272 x %> %
@@ -250,6 +284,7 @@ clean_link <- function(x) {
250284# '
251285# ' Removes stars, underscores, \{\} and []
252286# ' @param x Character to clean to transform as slug
287+ # ' @noRd
253288
254289clean_text <- function (x ) {
255290 x %> %
0 commit comments