Skip to content

Commit

Permalink
feat: add quick_init to start biocbook locally
Browse files Browse the repository at this point in the history
  • Loading branch information
js2264 committed Nov 16, 2023
1 parent 9e83955 commit 44b4b26
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export(edit_yml)
export(init)
export(preview)
export(publish)
export(quick_init)
export(releases)
export(status)
exportClasses(BiocBook)
Expand Down
35 changes: 34 additions & 1 deletion R/doc.R
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ NULL
#' `BiocBook`s are local R packages containing an extra `pages` folder to
#' write up online book chapters.
#'
#' 1. A new `BiocBook` should be created using `init(new_package = "...")`.
#' 1. A new `BiocBook` should be created using `init(new_package = "...")` (or
#' alternatively, locally with `quick_init(new_package = "...", user = "...")`).
#' 2. A newly created `BiocBook` can be accessed to in R using `biocbook <- BiocBook(path = "...")`.
#' 3. To edit an existing `BiocBook` object, several helper functions exist:
#' - `add_preamble(biocbook)`
Expand Down Expand Up @@ -112,6 +113,37 @@ NULL
#'
#' The `init(new_package = "...")` function returns a `BiocBook` object.
#'
#' @section Quickly create a local `BiocBook`:
#'
#' Alternatively, a **local** `BiocBook` can be quickly created using the
#' `quick_init(new_package = "...", user = "...")` function.
#'
#' This function only creates a new **local** repository, using the
#' `BiocBook` template from `js2264/BiocBook`.
#'
#' It does **NOT**:
#'
#' - Check that the provided package name is available;
#' - Set up/push the local repository to a **remote** Github repository;
#' - Set up a `gh-pages` to serve rendered books;
#'
#' This implies that functions committing/pushing (`publish()`)
#' or checking remote status (`status()`) do not work properly with a
#' `BiocBook` initiated with `quick_init()`, unless a remote is manually
#' set up.
#'
#' To enable Github support for a local `BiocBook`, one has to manually
#' initiate a `git` repository and add a remote as follows:
#'
#' ```{sh eval = FALSE}
#' git init
#' git symbolic-ref HEAD refs/heads/devel
#' git add .
#' git commit -m 'first commit'
#' git remote add origin [email protected]:<user>/<biocbook>.git
#' git push --set-upstream origin devel
#' ```
#'
#' @section Editing an existing `BiocBook`:
#'
#' `BiocBook` objects can be modified using the following helper functions:
Expand Down Expand Up @@ -156,6 +188,7 @@ NULL
#' @param new_package Name to use when initiating a new `BiocBook`.
#' This name should be compatible with package naming conventions
#' from R and Bioconductor (i.e. no `_` or `-`, no name starting with a number).
#' @param user Ideally, the Github ID of the main author/organization.
#' @param push Optional. Logical, whether to automatically push commits to
#' remote Github origin. If NA, a prompt will ask whether to push commits or
#' not (default: NA).
Expand Down
8 changes: 8 additions & 0 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ init <- function(

}

#' @rdname BiocBook
#' @export

quick_init <- function(new_package, user) {
.init_folder(new_package, user)
invisible(BiocBook(new_package))
}

.preflight_checks <- function(new_package, skip_availability = FALSE, .local = FALSE) {

cli::cat_rule("Running preflight checklist", col = "cyan", line = 2)
Expand Down
41 changes: 40 additions & 1 deletion man/BiocBook.Rd

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

0 comments on commit 44b4b26

Please sign in to comment.