Skip to content

Commit ece45d4

Browse files
committed
Merge branch 'cran-release'
2 parents 9dc7269 + 29b2643 commit ece45d4

37 files changed

+457
-429
lines changed

DESCRIPTION

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: gitdown
22
Title: Turn Your Git Commit Messages into a HTML Book
3-
Version: 0.1.0
3+
Version: 0.1.1
44
Authors@R:
55
c(person(given = "Sébastien",
66
family = "Rochette",
@@ -22,7 +22,8 @@ Description: Read all commit messages of your local git repository and
2222
organisms required to testify for every changes in their source code,
2323
in relation to features requests.
2424
License: MIT + file LICENSE
25-
URL: https://github.com/Thinkr-open/gitdown
25+
URL: https://thinkr-open.github.io/gitdown/,
26+
https://github.com/Thinkr-open/gitdown
2627
BugReports: https://github.com/Thinkr-open/gitdown/issues
2728
Depends:
2829
R (>= 3.4)
@@ -45,4 +46,5 @@ Suggests:
4546
VignetteBuilder:
4647
knitr
4748
Encoding: UTF-8
49+
Roxygen: list(markdown = TRUE)
4850
RoxygenNote: 7.1.1

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# gitdown 0.1.1
2+
3+
* Improve documentation
4+
15
# gitdown 0.1.0
26

37
* Get ready for CRAN

R/fake_repo.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#' @importFrom git2r init config add commit tag
1010
#' @export
1111
#'
12-
#' @return A few files and an initiated git repository in 'path'.
13-
#' Returns the path of the fake repository.
12+
#' @return Character. Path of a fake repository used for reproducible examples.
13+
#' Fake repository contains a few files with an initiated git repository.
1414
#' @examples
1515
#' # Fake repository with git
1616
#' fake_repo()

R/get_commits.R

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,17 @@
33
#' @inheritParams git2r::commits
44
#' @param silent Logical. Whether to hide messages.
55
#'
6-
#' @return A tibble with commits content, information and associated tags
6+
#' @return A tibble with one line for each commit and the following columns:
7+
#'
8+
#' - sha: sha of the commit
9+
#' - summary: First line of the commit message
10+
#' - message: Full content of the commit message
11+
#' - author: author of the commit
12+
#' - email: email of the author
13+
#' - when: commit time
14+
#' - order: order of commit messages. 1 is the oldest.
15+
#' - tag.name: name of tag associated with all commits since the last tag
16+
#' - tag.message: message of the tagged commit
717
#'
818
#' @importFrom git2r commits tags
919
#' @importFrom purrr map_dfr flatten
@@ -61,13 +71,26 @@ get_commits_tags <- function(repo = ".", ref = "master",
6171

6272
#' Get commits associated with a text pattern
6373
#'
64-
#' @param pattern Named vector with regex pattern to expose commits, like c("Issues" = "#[[:digit:]]") for issues
65-
#' @param pattern.table data.frame with two columns: pattern and description.
74+
#' @param pattern Named vector with regex pattern to expose commits, like `c("Issues" = "#\[\[:digit:\]\]")` for issues
75+
#' @param pattern.table data.frame with two columns: pattern and description of the pattern.
6676
#' This is used as correspondence table to add some names to existing patterns.
6777
#' @inheritParams git2r::commits
6878
#' @inheritParams get_commits_tags
6979
#'
70-
#' @return A tibble with commits content, information, associated tags and associated patterns found.
80+
#' @return A tibble with one line for each commit, duplicated if
81+
#' associated with multiple patterns and the following columns:
82+
#'
83+
#' - sha: sha of the commit
84+
#' - summary: First line of the commit message
85+
#' - message: Full content of the commit message
86+
#' - author: author of the commit
87+
#' - email: email of the author
88+
#' - when: commit time
89+
#' - order: order of commit messages. 1 is the oldest.
90+
#' - tag.name: name of tag associated with all commits since the last tag
91+
#' - tag.message: message of the tagged commit
92+
#' - pattern.type: name of the pattern found in the commit message
93+
#' - pattern.content: pattern found in the commit message
7194
#'
7295
#' @importFrom dplyr mutate distinct rowwise tibble left_join mutate
7396
#' @importFrom dplyr if_else mutate_all filter select
@@ -150,6 +173,7 @@ get_commits_pattern <- function(repo = ".", pattern = c("Ticket" = "#[[:digit:]]
150173
#' @inheritParams stringi::stri_extract_all
151174
#'
152175
#' @importFrom stringi stri_extract_all
176+
#' @noRd
153177

154178
my_extract <- function(message, pattern) {
155179
# res <- unlist(str_extract_all(message, pattern, simplify = FALSE))

R/get_info_files.R

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#' @param object hunks list
44
#'
55
#' @return time
6+
#' @noRd
67
get_time <- function(object) {
78
pluck(object, "final_signature", "when", "time")
89
}
@@ -12,7 +13,16 @@ get_time <- function(object) {
1213
#' @param path path to the file
1314
#' @param repo repo of the git project
1415
#'
15-
#' @return A list with information on first and last modification time of the selected file.
16+
#' @return A list with information of the selected file:
17+
#'
18+
#' - file: file name
19+
#' - in_repository: Logical. Whether the file has already been commit once in the
20+
#' git repository
21+
#' - first_modif: time of first modification. Commit time if in the git repository,
22+
#' system date of creation otherwise.
23+
#' - last_modif: time of last modification. Commit time if in the git repository,
24+
#' system date of last modification otherwise.
25+
#'
1626
#' @export
1727
#'
1828
#' @importFrom git2r blame
@@ -61,14 +71,23 @@ get_info <- function(path, repo = ".") {
6171
)
6272
}
6373

64-
#' Get the first and last modification time of files of a repository
74+
#' Get the first and last modification time of files of a directory
6575
#'
6676
#' @param repo git repository
67-
#' @param path Default to R folder. Use "" for the complete repository.
77+
#' @param path Default to R folder. Use "" for the complete directory
6878
#' @param recursive Logical. Should the listing recurse into directories?
6979
#' @param untracked Logical. Should the not tracked files be included?
7080
#'
71-
#' @return A list of files with information on first and last modification time.
81+
#' @return A list of files with information of each file:
82+
#'
83+
#' - file: file name
84+
#' - in_repository: Logical. Whether the file has already been commit once in the
85+
#' git repository
86+
#' - first_modif: time of first modification. Commit time if in the git repository,
87+
#' system date of creation otherwise.
88+
#' - last_modif: time of last modification. Commit time if in the git repository,
89+
#' system date of last modification otherwise.
90+
#'
7291
#' @export
7392
#'
7493
#' @importFrom purrr map
@@ -147,7 +166,8 @@ present_files <- function(repo = ".", path = "R",
147166

148167
#' Creates and updates a vignette in the 'vignette/' directory of a package with last modification time of tracked files
149168
#'
150-
#' @return Creates and updates the content of the "modification_files.Rmd" vignette
169+
#' @return No return value, called for side effect.
170+
#' Creates and updates the content of the "modification_files.Rmd" vignette
151171
#' @export
152172
#'
153173
#' @rdname create_vignette_last_modif

R/git_down.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#' Turns the history of git into a bookdown.
1+
#' Turns the active branch history of git into a bookdown.
22
#'
33
#' Read all commit messages of your local git repository and
44
#' sort them according to tags or specific text pattern into chapters of
@@ -10,12 +10,12 @@
1010
#' @param open Should the bookdown be opened once compiled? Default is TRUE.
1111
#' @param author Author of the bookdown
1212
#' @param ref the name of the branch, by default master
13-
#' @param ... Other parameters to pass to \code{\link[rmarkdown]{render}}
13+
#' @param ... Other parameters to pass to [rmarkdown::render()]
1414
#'
1515
#' @inheritParams get_commits_pattern
1616
#' @export
1717
#'
18-
#' @return A directory with content of a HTML gitbook
18+
#' @return Path of the HTML gitbook saved in the repo/book_path directory.
1919
#'
2020
#' @importFrom attempt if_not
2121
#' @importFrom rmarkdown render
@@ -28,17 +28,20 @@
2828
#' repo <- fake_repo()
2929
#' res <- git_down(repo, pattern = c("Tickets" = "ticket[[:digit:]]+", "Issues" = "#[[:digit:]]+"),
3030
#' open = FALSE)
31+
#' \dontrun{
3132
#' # Open the book
32-
#' # browseURL(res)
33-
#'
33+
#' browseURL(res)
34+
#' }
3435
#' # With table of correspondence
3536
#' pattern.table <- data.frame(number = c("#2", "#1"),
3637
#' title = c("#2 A second issue to illustrate a blog post",
3738
#' "#1 An example of issue"))
3839
#' res <- git_down(repo, pattern = c("Issues" = "#[[:digit:]]+"),
3940
#' pattern.table = pattern.table, open = FALSE)
41+
#' \dontrun{
4042
#' # Open the book
41-
#' # browseURL(res)
43+
#' browseURL(res)
44+
#' }
4245

4346
git_down <- function(repo = ".", book_path = "gitdown",
4447
open = TRUE, author = "John Doe",

R/gitdown-package.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#' @description Read all commit messages of your local git repository
2+
#' and sort them according to tags or specific text pattern into chapters
3+
#' of a HTML book using 'bookdown'.
4+
#' The git history book presentation helps organisms required to testify
5+
#' for every changes in their source code, in relation to features requests.
6+
#'
7+
#' The main functions to be used in this package are [git_down()] and [create_vignette_last_modif()]
8+
#' @keywords internal
9+
"_PACKAGE"
10+
11+
# The following block is used by usethis to automatically manage
12+
# roxygen namespace tags. Modify with care!
13+
## usethis namespace: start
14+
## usethis namespace: end
15+
NULL

R/utils-pipe.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#' Pipe operator
22
#'
3-
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
3+
#' See `magrittr::[\%>\%][magrittr::pipe]` for details.
44
#'
55
#' @name %>%
66
#' @rdname pipe
77
#' @keywords internal
88
#' @export
99
#' @importFrom magrittr %>%
1010
#' @usage lhs \%>\% rhs
11+
#' @param lhs A value or the magrittr placeholder.
12+
#' @param rhs A function call using the magrittr semantics.
13+
#' @return The result of calling `rhs(lhs)`.
1114
NULL

R/utils.R

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#' @param file Path of file
44
#' @param pattern Pattern to replace
55
#' @param replacement A character vector of replacements
6-
#'
6+
#' @noRd
77
replace_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
2020
write_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

3132
presentation_commit <- function(commit) {
3233
res <- paste0(
@@ -65,6 +66,7 @@ presentation_commit <- function(commit) {
6566
#'
6667
#' @importFrom purrr map_chr
6768
#'
69+
#' @noRd
6870

6971
each_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
9295
to_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

112134
nest_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

237271
clean_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

254289
clean_text <- function(x) {
255290
x %>%

0 commit comments

Comments
 (0)