Skip to content

Commit

Permalink
Add changelog md file function
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelbharti committed Sep 30, 2024
1 parent d7e579f commit 4ab77fa
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 4 deletions.
61 changes: 61 additions & 0 deletions R/init_changelog_md.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#' A changelog markdown template to document project progress
#'
#' @param path Path where markdown file is created
#' @param confirm Confirm path; logical input.
#'
#' @return Return markdown file in specified or current working directory
#' @export
#'
#' @examples
#' init_changelog_md()
init_changelog_md <- function(path = getwd(), confirm = TRUE){


# Display a message before the prompt
cat("You current working directory will be:\n")
cat(path)

if(confirm){
user_input <- tolower(
readline(
prompt = "Do you wish to create a Change log MD here? (y/yes to confirm): "
)
)
}else{
user_input <- "y"
}


# Check if the user input is 'y' or 'yes'
if (user_input %in% c("y", "yes")) {
wd_path <- path

markdown_content <- "
# CHANGELOG
``` txt
YYYY-MM-DD John Doe
* Big Change 1
* Another Change 2
```
"
aa <- file.path(wd_path,"CHANGELOG.md")
file.create(aa, showWarnings = FALSE)

if(file.exists(aa)){
fileConn <- file(aa)

writeLines(
markdown_content,
fileConn
)
close(fileConn)

}

} else {
cat("Change log MD initialization canceled.\n")
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CHANGELOG

``` txt
YYYY-MM-DD John Doe
* Big Change 1
* Another Change 2
```
3 changes: 3 additions & 0 deletions inst/markdown/templates/changelog_md_template/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
name: "CHANGELOG MD"
description: "A template to document project progress"
create_dir: false
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ print(paste0("Last updated: ",Sys.time()))

------------------------------------------------------------------------

# Project Introduction

Write some project description

# CHANGELOG
------------------------------------------------------------------------

YYYY-MM-DD John Doe
Expand Down
22 changes: 22 additions & 0 deletions man/init_changelog_md.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4ab77fa

Please sign in to comment.