├── vignettes ├── .gitignore └── BiocAddins.Rmd ├── .Rbuildignore ├── NEWS.md ├── NAMESPACE ├── man ├── useBiocManager.Rd ├── useRproj.Rd ├── vignetteAsREADME.Rd ├── reBuildREADMEmd.Rd ├── runBiocCheck.Rd ├── updateNEWS.Rd ├── versionBump.Rd └── addSSHremote.Rd ├── R ├── useBiocManager.R ├── useRproj.R ├── runBiocCheck.R ├── reBuildREADMEmd.R ├── addSSHremote.R ├── versionBump.R ├── vignetteAsREADME.R └── updateNEWS.R ├── inst ├── resources │ ├── README_template.Rmd │ └── template.Rproj ├── scripts │ └── README.Rmd └── rstudio │ └── addins.dcf ├── .gitignore ├── DESCRIPTION └── README.md /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | -------------------------------------------------------------------------------- /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^BiocAddins.Rproj$ 2 | ^\.Rproj\.user$ 3 | 4 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # BiocAddins 1.0.0 2 | 3 | * `addSSHremote` adds a Git remote pointing to the Bioconductor upstream 4 | repository 5 | * update `versionBump` to include auto-commit of `DESCRIPTION` file 6 | * Added a `NEWS.md` file to track changes to the package. 7 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(addSSHremote) 4 | export(reBuildREADMEmd) 5 | export(runBiocCheck) 6 | export(updateNEWS) 7 | export(useBiocManager) 8 | export(useRproj) 9 | export(versionBump) 10 | export(vignetteAsREADME) 11 | import(BiocManager) 12 | importFrom(BiocBaseUtils,isScalarCharacter) 13 | importFrom(desc,desc) 14 | importFrom(rstudioapi,openProject) 15 | -------------------------------------------------------------------------------- /man/useBiocManager.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/useBiocManager.R 3 | \name{useBiocManager} 4 | \alias{useBiocManager} 5 | \title{BiocManager: The Bioconductor Package Manager} 6 | \usage{ 7 | useBiocManager() 8 | } 9 | \description{ 10 | Make Bioconductor packages available via \code{BiocManager}, ensuring 11 | proper versioning with the current R installation. 12 | } 13 | \examples{ 14 | 15 | useBiocManager() 16 | 17 | } 18 | -------------------------------------------------------------------------------- /R/useBiocManager.R: -------------------------------------------------------------------------------- 1 | #' BiocManager: The Bioconductor Package Manager 2 | #' 3 | #' Make Bioconductor packages available via `BiocManager`, ensuring 4 | #' proper versioning with the current R installation. 5 | #' 6 | #' @examples 7 | #' 8 | #' useBiocManager() 9 | #' 10 | #' @import BiocManager 11 | #' 12 | #' @export 13 | useBiocManager <- function() { 14 | if (!requireNamespace("BiocManager", quietly = TRUE)) 15 | utils::install.packages("BiocManager") 16 | requireNamespace("BiocManager") 17 | } 18 | -------------------------------------------------------------------------------- /inst/resources/README_template.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | knit: (function(inputFile, encoding) { 4 | rmarkdown::render(input=inputFile, encoding=encoding, output_dir="../../") }) 5 | --- 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | cache = TRUE, 12 | out.width = "100%" 13 | ) 14 | ``` 15 | 16 | ```{r,echo=FALSE,eval=FALSE} 17 | ## Generate the ./README.md (relative to base folder) 18 | rmarkdown::render(input = "inst/scripts/README.Rmd", output_dir = ".") 19 | ``` 20 | 21 | ```{r, child="../../vignettes/%s"} 22 | 23 | ``` 24 | -------------------------------------------------------------------------------- /inst/scripts/README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | knit: (function(inputFile, encoding) { 4 | rmarkdown::render(input=inputFile, encoding=encoding, output_dir="../../") }) 5 | --- 6 | 7 | ```{r, include = FALSE} 8 | knitr::opts_chunk$set( 9 | collapse = TRUE, 10 | comment = "#>", 11 | cache = TRUE, 12 | out.width = "100%" 13 | ) 14 | ``` 15 | 16 | ```{r,echo=FALSE,eval=FALSE} 17 | ## Generate the ./README.md (relative to base folder) 18 | rmarkdown::render(input = "inst/scripts/README.Rmd", output_dir = ".") 19 | ``` 20 | 21 | ```{r, child="../../vignettes/BiocAddins.Rmd"} 22 | 23 | ``` 24 | -------------------------------------------------------------------------------- /inst/resources/template.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 4 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | AutoAppendNewline: Yes 16 | StripTrailingWhitespace: Yes 17 | 18 | BuildType: Package 19 | PackageUseDevtools: Yes 20 | PackageInstallArgs: --no-multiarch --with-keep.source --no-test-load --no-staged-install 21 | PackageBuildArgs: --no-build-vignettes 22 | PackageCheckArgs: --no-vignettes 23 | PackageRoxygenize: rd,collate,namespace 24 | -------------------------------------------------------------------------------- /man/useRproj.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/useRproj.R 3 | \name{useRproj} 4 | \alias{useRproj} 5 | \title{Add an .Rproj file based on a template} 6 | \usage{ 7 | useRproj(pkgDir = ".", overwrite = FALSE) 8 | } 9 | \arguments{ 10 | \item{pkgDir}{The package directory to be build usually the current working 11 | directory (i.e., ".")} 12 | 13 | \item{overwrite}{logical; should existing destination files be overwritten?} 14 | } 15 | \description{ 16 | This function creates an \verb{.Rproj} file with standard options. 17 | } 18 | \examples{ 19 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 20 | useRproj() 21 | \dontshow{\}) # examplesIf} 22 | } 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # Session Data files 6 | .RData 7 | 8 | # Example code in package build process 9 | *-Ex.R 10 | 11 | # Output files from R CMD build 12 | /*.tar.gz 13 | 14 | # Output files from R CMD check 15 | /*.Rcheck/ 16 | 17 | # RStudio files 18 | .Rproj.user/ 19 | 20 | # produced vignettes 21 | vignettes/*.html 22 | vignettes/*.pdf 23 | 24 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 25 | .httr-oauth 26 | 27 | # knitr and R markdown default cache directories 28 | *_cache/ 29 | /cache/ 30 | *.html 31 | 32 | # Temporary files created by R markdown 33 | *.utf8.md 34 | *.knit.md 35 | 36 | # Shiny token, see https://shiny.rstudio.com/articles/shinyapps.html 37 | rsconnect/ 38 | inst/doc 39 | 40 | *.Rproj 41 | !inst/resources/template.Rproj 42 | -------------------------------------------------------------------------------- /R/useRproj.R: -------------------------------------------------------------------------------- 1 | #' Add an .Rproj file based on a template 2 | #' 3 | #' This function creates an `.Rproj` file with standard options. 4 | #' 5 | #' @inheritParams addSSHremote 6 | #' @inheritParams base::files 7 | #' 8 | #' @importFrom rstudioapi openProject 9 | #' 10 | #' @examplesIf interactive() 11 | #' useRproj() 12 | #' 13 | #' @export 14 | useRproj <- function(pkgDir = ".", overwrite = FALSE) { 15 | pkg_name <- devtools::as.package(pkgDir)[["package"]] 16 | template <- system.file( 17 | "resources", "template.Rproj", package = "BiocAddins", mustWork = TRUE 18 | ) 19 | rproj_file <- file.path(pkgDir, paste0(pkg_name, ".Rproj")) 20 | if (!file.exists(rproj_file)) 21 | file.copy( 22 | from = template, 23 | to = rproj_file, 24 | overwrite = overwrite 25 | ) 26 | rstudioapi::openProject(path = rproj_file) 27 | } 28 | -------------------------------------------------------------------------------- /R/runBiocCheck.R: -------------------------------------------------------------------------------- 1 | #' Shortcut for executing `BiocCheck` on the current package 2 | #' 3 | #' `BiocCheck` provides Bioconductor flavored checks for 4 | #' your package. It provides recommendations for good 5 | #' practices. 6 | #' 7 | #' @param pkgDir The package directory to be build usually the current working 8 | #' directory (i.e., ".") 9 | #' 10 | #' @param callr logical(1) Whether to use `callr` to execute the check in 11 | #' a background R session. This is helpful for avoiding namespace collisions 12 | #' and adding objects to the current environment. 13 | #' 14 | #' @param ... Additional arguments for `BiocCheck` 15 | #' 16 | #' @examplesIf interactive() 17 | #' runBiocCheck() 18 | #' 19 | #' @export 20 | runBiocCheck <- function(pkgDir = ".", callr = TRUE, ...) { 21 | pkgPath <- devtools::as.package(pkgDir)[["path"]] 22 | BiocCheck::BiocCheck(package = pkgPath, callr = callr, ...) 23 | } 24 | -------------------------------------------------------------------------------- /man/vignetteAsREADME.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/vignetteAsREADME.R 3 | \name{vignetteAsREADME} 4 | \alias{vignetteAsREADME} 5 | \title{Use the vignette as a README.md file} 6 | \usage{ 7 | vignetteAsREADME(pkgDir = ".", vignette, dir = "inst/scripts") 8 | } 9 | \arguments{ 10 | \item{pkgDir}{The package directory to be build usually the current working 11 | directory (i.e., ".")} 12 | 13 | \item{vignette}{character(1) The filename of the vignette to be used as 14 | the \code{README.md} file} 15 | 16 | \item{dir}{character(1) The directory location within the package where to 17 | save the source vignette that will be converted to a \code{README.md}.} 18 | } 19 | \description{ 20 | Create an R Markdown file that takes the vignette and knits it as the 21 | \code{README.md} file 22 | } 23 | \examples{ 24 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 25 | vignetteAsREADME() 26 | \dontshow{\}) # examplesIf} 27 | } 28 | -------------------------------------------------------------------------------- /man/reBuildREADMEmd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/reBuildREADMEmd.R 3 | \name{reBuildREADMEmd} 4 | \alias{reBuildREADMEmd} 5 | \title{Rebuild the README.md from the README.Rmd file} 6 | \usage{ 7 | reBuildREADMEmd(pkgDir = ".", readme, dir = "inst/scripts") 8 | } 9 | \arguments{ 10 | \item{pkgDir}{The package directory to be build usually the current working 11 | directory (i.e., ".")} 12 | 13 | \item{readme}{\code{character(1)} The path to the \code{README.Rmd} to be rendered into 14 | the \code{README.md} file} 15 | 16 | \item{dir}{character(1) The directory location within the package where to 17 | save the source vignette that will be converted to a \code{README.md}.} 18 | } 19 | \description{ 20 | This function rebuilds the \code{README.md} file by running the command in the 21 | \code{README.Rmd} file. 22 | } 23 | \examples{ 24 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 25 | reBuildREADMEmd() 26 | \dontshow{\}) # examplesIf} 27 | } 28 | -------------------------------------------------------------------------------- /man/runBiocCheck.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/runBiocCheck.R 3 | \name{runBiocCheck} 4 | \alias{runBiocCheck} 5 | \title{Shortcut for executing \code{BiocCheck} on the current package} 6 | \usage{ 7 | runBiocCheck(pkgDir = ".", callr = TRUE, ...) 8 | } 9 | \arguments{ 10 | \item{pkgDir}{The package directory to be build usually the current working 11 | directory (i.e., ".")} 12 | 13 | \item{callr}{logical(1) Whether to use \code{callr} to execute the check in 14 | a background R session. This is helpful for avoiding namespace collisions 15 | and adding objects to the current environment.} 16 | 17 | \item{...}{Additional arguments for \code{BiocCheck}} 18 | } 19 | \description{ 20 | \code{BiocCheck} provides Bioconductor flavored checks for 21 | your package. It provides recommendations for good 22 | practices. 23 | } 24 | \examples{ 25 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 26 | runBiocCheck() 27 | \dontshow{\}) # examplesIf} 28 | } 29 | -------------------------------------------------------------------------------- /R/reBuildREADMEmd.R: -------------------------------------------------------------------------------- 1 | #' Rebuild the README.md from the README.Rmd file 2 | #' 3 | #' This function rebuilds the `README.md` file by running the command in the 4 | #' `README.Rmd` file. 5 | #' 6 | #' @inheritParams vignetteAsREADME 7 | #' 8 | #' @param readme `character(1)` The path to the `README.Rmd` to be rendered into 9 | #' the `README.md` file 10 | #' 11 | #' @examplesIf interactive() 12 | #' reBuildREADMEmd() 13 | #' 14 | #' @export 15 | reBuildREADMEmd <- function(pkgDir = ".", readme, dir = "inst/scripts") { 16 | pkgPath <- devtools::as.package(pkgDir)[["path"]] 17 | 18 | if (missing(readme)) 19 | readme <- file.path(pkgPath, dir, "README.Rmd") 20 | 21 | if (!BiocBaseUtils::isScalarCharacter(readme)) 22 | stop("The argument 'readme' must be a character(1).", call. = FALSE) 23 | 24 | if (!file.exists(readme)) 25 | stop( 26 | "'", readme, "' does not exist; use 'Vignette to README.md'", 27 | call. = FALSE 28 | ) 29 | 30 | rmarkdown::render( 31 | input = readme, output_dir = pkgPath 32 | ) 33 | } 34 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: BiocAddins 2 | Title: Bioconductor Addins for RStudio 3 | Version: 0.99.26 4 | Authors@R: person( 5 | "Marcel", "Ramos", , "marcel.ramos@sph.cuny.edu", 6 | c("aut", "cre"), c(ORCID = "0000-0002-3242-0582") 7 | ) 8 | Description: BiocAddins provides a set of RStudio Addins that make it easy 9 | to work with Bioconductor. These Addins are developer centric and include 10 | actions such as running BiocCheck, bumping package versions, and creating 11 | Rproj files. Experimental Addins include using the vignette as a 12 | README file, rendering the README from an RMarkdown file, and 13 | updating the NEWS file from recent commits. 14 | Depends: R (>= 4.0.0) 15 | Imports: 16 | BiocCheck, 17 | BiocBaseUtils, 18 | BiocManager, 19 | desc, 20 | devtools, 21 | gert, 22 | newsfeed, 23 | rstudioapi, 24 | utils 25 | Remotes: waldronlab/newsfeed 26 | License: Artistic-2.0 27 | Encoding: UTF-8 28 | RoxygenNote: 7.3.2 29 | Roxygen: list(markdown = TRUE) 30 | Suggests: 31 | BiocStyle, 32 | knitr, 33 | rmarkdown 34 | VignetteBuilder: knitr 35 | Date: 2025-06-20 36 | -------------------------------------------------------------------------------- /man/updateNEWS.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/updateNEWS.R 3 | \name{updateNEWS} 4 | \alias{updateNEWS} 5 | \title{Add the last commit messages since a 'version bump' to NEWS.md} 6 | \usage{ 7 | updateNEWS( 8 | pkgDir = ".", 9 | vpattern = "Changes in version", 10 | git_log_pattern = "version bump|bump version" 11 | ) 12 | } 13 | \arguments{ 14 | \item{pkgDir}{The package directory to be build usually the current working 15 | directory (i.e., ".")} 16 | 17 | \item{vpattern}{The set of keywords in the \code{NEWS.md} file header that denotes 18 | a section, e.g., \verb{Changes in version} or the 'pkgname'.} 19 | 20 | \item{git_log_pattern}{The words that delimit the last version bump in the 21 | package; by default either \verb{version bump} or \verb{bump version}.} 22 | } 23 | \description{ 24 | Take the last series of Git commit messages and append them to the NEWS.md 25 | file for updating. 26 | } 27 | \examples{ 28 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 29 | updateNEWS(pkgDir = ".", vpattern = "BiocAddins") 30 | \dontshow{\}) # examplesIf} 31 | } 32 | -------------------------------------------------------------------------------- /man/versionBump.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/versionBump.R 3 | \name{versionBump} 4 | \alias{versionBump} 5 | \title{Bump the current package's patch version} 6 | \usage{ 7 | versionBump(pkgDir = ".", commit = getOption("BiocAddins.autocommit", TRUE)) 8 | } 9 | \arguments{ 10 | \item{pkgDir}{The package directory to be build usually the current working 11 | directory (i.e., ".")} 12 | 13 | \item{commit}{\code{logical(1)} whether to automatically commit the changes to 14 | the \code{DESCRIPTION} file with \code{gert}. Defaults to \code{TRUE}.} 15 | } 16 | \description{ 17 | Take the packages version number (x.y.z) and bump the \code{z} version of the 18 | package. This is also known as the 'patch' version. Note this function 19 | also updates the \code{Date} field in the \code{DESCRIPTION} file. 20 | } 21 | \details{ 22 | Set the option \code{options('BiocAddins.autocommit')} to \code{FALSE} to 23 | avoid automatic \code{DESCRIPTION} file commits. 24 | } 25 | \examples{ 26 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 27 | versionBump() 28 | \dontshow{\}) # examplesIf} 29 | } 30 | -------------------------------------------------------------------------------- /R/addSSHremote.R: -------------------------------------------------------------------------------- 1 | #' Add the Bioconductor upstream remote SSH location 2 | #' 3 | #' Note that this function will only be of use for packages that are already 4 | #' in Bioconductor and have maintainer access. 5 | #' 6 | #' @inheritParams vignetteAsREADME 7 | #' 8 | #' @param ssh_loc character(1) The SSH address for Bioconductor repositories; 9 | #' by default `git@git.bioconductor.org`. 10 | #' 11 | #' @param remote character(1) The name of the remote to be added by default 12 | #' this should be `upstream`. 13 | #' 14 | #' @param slug character(1) The slug that immediately follows the SSH address 15 | #' this is `packages` for Bioconductor and the username for GitHub 16 | #' addresses 17 | #' 18 | #' @examplesIf interactive() 19 | #' addSSHremote() 20 | #' 21 | #' @export 22 | addSSHremote <- function( 23 | pkgDir = ".", 24 | remote = "upstream", 25 | ssh_loc = "git@git.bioconductor.org", 26 | slug = "packages" 27 | ) { 28 | pkg_name <- devtools::as.package(pkgDir)[["package"]] 29 | gert::git_remote_add( 30 | url = paste0(ssh_loc, ":", slug, "/", pkg_name), 31 | name = remote 32 | ) 33 | message("Success.") 34 | gert::git_remote_list() 35 | } 36 | -------------------------------------------------------------------------------- /inst/rstudio/addins.dcf: -------------------------------------------------------------------------------- 1 | Name: Use BiocManager 2 | Description: BiocManager provides access to Bioconductor R packages 3 | Binding: useBiocManager 4 | Interactive: false 5 | 6 | Name: Run BiocCheck 7 | Description: Runs BiocCheck on the current Bioconductor package 8 | Binding: runBiocCheck 9 | Interactive: false 10 | 11 | Name: Bump Version 12 | Description: Perform a +1 patch version ('Z') bump 13 | Binding: versionBump 14 | Interactive: false 15 | 16 | Name: Vignette to README.md 17 | Description: Use a package's vignette as the README.md file 18 | Binding: vignetteAsREADME 19 | Interactive: false 20 | 21 | Name: Git log to NEWS.md 22 | Description: Add the latest Git commit messages to the NEWS.md file 23 | Binding: updateNEWS 24 | Interactive: false 25 | 26 | Name: Add Upstream Remote 27 | Description: Uses git to add the upstream remote on git.bioconductor.org 28 | Binding: addSSHremote 29 | Interactive: false 30 | 31 | Name: Create & open .Rproj 32 | Description: Creates and opens an package.Rproj file from a template 33 | Binding: useRproj 34 | Interactive: false 35 | 36 | Name: Render README.md 37 | Description: rmarkdown::render README.md from README.Rmd 38 | Binding: reBuildREADMEmd 39 | Interactive: false 40 | -------------------------------------------------------------------------------- /man/addSSHremote.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/addSSHremote.R 3 | \name{addSSHremote} 4 | \alias{addSSHremote} 5 | \title{Add the Bioconductor upstream remote SSH location} 6 | \usage{ 7 | addSSHremote( 8 | pkgDir = ".", 9 | remote = "upstream", 10 | ssh_loc = "git@git.bioconductor.org", 11 | slug = "packages" 12 | ) 13 | } 14 | \arguments{ 15 | \item{pkgDir}{The package directory to be build usually the current working 16 | directory (i.e., ".")} 17 | 18 | \item{remote}{character(1) The name of the remote to be added by default 19 | this should be \code{upstream}.} 20 | 21 | \item{ssh_loc}{character(1) The SSH address for Bioconductor repositories; 22 | by default \code{git@git.bioconductor.org}.} 23 | 24 | \item{slug}{character(1) The slug that immediately follows the SSH address 25 | this is \code{packages} for Bioconductor and the username for GitHub 26 | addresses} 27 | } 28 | \description{ 29 | Note that this function will only be of use for packages that are already 30 | in Bioconductor and have maintainer access. 31 | } 32 | \examples{ 33 | \dontshow{if (interactive()) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} 34 | addSSHremote() 35 | \dontshow{\}) # examplesIf} 36 | } 37 | -------------------------------------------------------------------------------- /R/versionBump.R: -------------------------------------------------------------------------------- 1 | #' Bump the current package's patch version 2 | #' 3 | #' Take the packages version number (x.y.z) and bump the `z` version of the 4 | #' package. This is also known as the 'patch' version. Note this function 5 | #' also updates the `Date` field in the `DESCRIPTION` file. 6 | #' 7 | #' @details Set the option `options('BiocAddins.autocommit')` to `FALSE` to 8 | #' avoid automatic `DESCRIPTION` file commits. 9 | #' 10 | #' @inheritParams runBiocCheck 11 | #' 12 | #' @param commit `logical(1)` whether to automatically commit the changes to 13 | #' the `DESCRIPTION` file with `gert`. Defaults to `TRUE`. 14 | #' 15 | #' @importFrom desc desc 16 | #' 17 | #' @examplesIf interactive() 18 | #' versionBump() 19 | #' 20 | #' @export 21 | versionBump <- 22 | function(pkgDir = ".", commit = getOption('BiocAddins.autocommit', TRUE)) 23 | { 24 | pkgPath <- devtools::as.package(pkgDir)[["path"]] 25 | desc <- desc::desc(file = file.path(pkgPath, "DESCRIPTION")) 26 | desc$bump_version("patch") 27 | if (!is.na(desc$get("Date"))) 28 | desc$set("Date", Sys.Date()) 29 | desc$write() 30 | if (commit) { 31 | gert::git_add(files = "DESCRIPTION") 32 | gert::git_commit( 33 | message = paste0("version bump ", as.character(desc$get_version())) 34 | ) 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /R/vignetteAsREADME.R: -------------------------------------------------------------------------------- 1 | #' Use the vignette as a README.md file 2 | #' 3 | #' Create an R Markdown file that takes the vignette and knits it as the 4 | #' `README.md` file 5 | #' 6 | #' @inheritParams runBiocCheck 7 | #' 8 | #' @param vignette character(1) The filename of the vignette to be used as 9 | #' the `README.md` file 10 | #' 11 | #' @param dir character(1) The directory location within the package where to 12 | #' save the source vignette that will be converted to a `README.md`. 13 | #' 14 | #' @importFrom BiocBaseUtils isScalarCharacter 15 | #' 16 | #' @examplesIf interactive() 17 | #' vignetteAsREADME() 18 | #' 19 | #' @export 20 | vignetteAsREADME <- function(pkgDir = ".", vignette, dir = "inst/scripts") { 21 | pkgDir <- devtools::as.package(pkgDir)[["path"]] 22 | if (missing(vignette)) { 23 | vigs <- list.files(file.path(pkgDir, "vignettes"), full.names = TRUE) 24 | rmds <- tolower(tools::file_ext(vigs)) == "rmd" 25 | vignette <- vigs[rmds] 26 | } 27 | if (!isScalarCharacter(vignette)) 28 | stop("Provide a 'vignette' template input to use as the README.md") 29 | rmtemp <- system.file( 30 | "resources", "README_template.Rmd", package = "BiocAddins", 31 | mustWork = TRUE 32 | ) 33 | temptext <- readLines(rmtemp) 34 | repline <- grep("vignettes/%s", fixed = TRUE, temptext) 35 | temptext[repline] <- sprintf(temptext[repline], basename(vignette)) 36 | 37 | if (!dir.exists(dir)) 38 | dir.create(dir, recursive = TRUE) 39 | 40 | newtemp <- file.path(dir, "README.Rmd") 41 | writeLines(text = temptext, con = newtemp) 42 | } 43 | -------------------------------------------------------------------------------- /R/updateNEWS.R: -------------------------------------------------------------------------------- 1 | .NEWS_LOCS <- c("inst/NEWS", "NEWS.md", "inst/NEWS.Rd", "NEWS", "inst/NEWS.md") 2 | 3 | .findNEWSfile <- function(pkg) { 4 | dpkg <- devtools::as.package(pkg) 5 | npaths <- file.path(dpkg[["path"]], .NEWS_LOCS) 6 | newlo <- file.exists(npaths) 7 | if (sum(newlo) > 1 || sum(newlo) < 1) 8 | stop("Multiple NEWS files found in package folder") 9 | npaths[newlo] 10 | } 11 | 12 | #' Add the last commit messages since a 'version bump' to NEWS.md 13 | #' 14 | #' Take the last series of Git commit messages and append them to the NEWS.md 15 | #' file for updating. 16 | #' 17 | #' @inheritParams vignetteAsREADME 18 | #' 19 | #' @param vpattern The set of keywords in the `NEWS.md` file header that denotes 20 | #' a section, e.g., `Changes in version` or the 'pkgname'. 21 | #' 22 | #' @param git_log_pattern The words that delimit the last version bump in the 23 | #' package; by default either `version bump` or `bump version`. 24 | #' 25 | #' @examplesIf interactive() 26 | #' updateNEWS(pkgDir = ".", vpattern = "BiocAddins") 27 | #' 28 | #' @export 29 | updateNEWS <- function( 30 | pkgDir = ".", 31 | vpattern = "Changes in version", 32 | git_log_pattern = "version bump|bump version" 33 | ) { 34 | pkg_name <- devtools::as.package(pkgDir)[["package"]] 35 | newsfeed::validate(pkgDir, pkg_name) 36 | newsfile <- newsfeed:::.findNEWSfile(pkgDir) 37 | newsext <- tools::file_ext(newsfile) 38 | if (!identical(newsext, "md")) 39 | stop("Currently, only 'NEWS.md' files are supported") 40 | newslines <- readLines(newsfile) 41 | firstheader <- grep("^\\s*#", newslines) + 1 42 | 43 | gitlog <- gert::git_log() 44 | commit_msgs <- gsub("\\n", "", gitlog[["message"]]) 45 | bumps <- grep(git_log_pattern, commit_msgs, ignore.case = TRUE) 46 | start <- 1 %in% bumps + 1 47 | last <- min(bumps[bumps > 1]) - 1 48 | all <- commit_msgs[seq(start, last)] 49 | all <- paste("*", all) 50 | 51 | newnews <- unlist(append(newslines, all, firstheader)) 52 | writeLines(newnews, con = newsfile) 53 | } 54 | -------------------------------------------------------------------------------- /vignettes/BiocAddins.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Bioconductor Utilities as RStudio Addins" 3 | author: 4 | - name: Marcel Ramos 5 | affiliation: Roswell Park Cancer Institute, Buffalo, NY 6 | date: "`r BiocStyle::doc_date()`" 7 | vignette: > 8 | %\VignetteIndexEntry{Bioconductor Utilities as RStudio Addins} 9 | %\VignetteEngine{knitr::rmarkdown} 10 | %\VignetteEncoding{UTF-8} 11 | output: BiocStyle::html_document 12 | Package: BiocAddins 13 | --- 14 | 15 | ```{r, include = FALSE} 16 | knitr::opts_chunk$set( 17 | collapse = TRUE, 18 | comment = "#>" 19 | ) 20 | ``` 21 | 22 | # Installation 23 | 24 | ```{r setup, eval=FALSE} 25 | BiocManager::install("Bioconductor/BiocAddins") 26 | ``` 27 | 28 | # Utility functions 29 | 30 | ## Installing BiocManager 31 | 32 | Bioconductor uses BiocManager to distribute packages and manage Bioconductor 33 | versions. It is important for users to make use of BiocManager instead of 34 | `install.packages` in order to ensure proper package versioning. 35 | 36 | The RStudio Addin makes it easy for users to obtain and install `BiocManager` 37 | from CRAN. 38 | 39 | ```{r,eval=FALSE} 40 | useBiocManager() 41 | ``` 42 | 43 | After installation of `BiocManager`, users may install a package via the 44 | `install` function: 45 | 46 | ```{r,eval=FALSE} 47 | BiocManager::install("Biobase") 48 | ``` 49 | 50 | # Developer section 51 | 52 | ## Run BiocCheck 53 | 54 | Developers can run BiocCheck quite easily with the RStudio Addin from the 55 | dropdown menu. It essentially runs: 56 | 57 | ```{r, eval=FALSE} 58 | BiocCheck::BiocCheck() 59 | ``` 60 | 61 | We recommend using the following keyboard shortcut: 62 | 63 | Ctrl / (Mac) + shift + C 64 | 65 | ## Version Bumps 66 | 67 | BiocAddins makes it easy to bump your package's version by running the 68 | `bumpVersion` function: 69 | 70 | ```{r,eval=FALSE} 71 | bumpVersion() 72 | ``` 73 | 74 | Note that this will increase the `Z` version of the package by 1, a.k.a, the 75 | patch version. 76 | 77 | ## Installing devel 78 | 79 | Developers who wish to install the development version of Bioconductor can 80 | do so _after_ installing `BiocManager`: 81 | 82 | ```{r, eval=FALSE} 83 | BiocManager::install(version = "devel") 84 | ``` 85 | 86 | Developers must ensure that the correct version of R is being used. 87 | For more information, please review the `BiocManager` package vignette. 88 | 89 | ## Session Info 90 | 91 | ```{r} 92 | sessionInfo() 93 | ``` 94 | 95 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Installation 3 | 4 | ``` r 5 | BiocManager::install("Bioconductor/BiocAddins") 6 | ``` 7 | 8 | # Utility functions 9 | 10 | ## Installing BiocManager 11 | 12 | Bioconductor uses BiocManager to distribute packages and manage 13 | Bioconductor versions. It is important for users to make use of 14 | BiocManager instead of `install.packages` in order to ensure proper 15 | package versioning. 16 | 17 | The RStudio Addin makes it easy for users to obtain and install 18 | `BiocManager` from CRAN. 19 | 20 | ``` r 21 | useBiocManager() 22 | ``` 23 | 24 | After installation of `BiocManager`, users may install a package via the 25 | `install` function: 26 | 27 | ``` r 28 | BiocManager::install("Biobase") 29 | ``` 30 | 31 | # Developer section 32 | 33 | ## Run BiocCheck 34 | 35 | Developers can run BiocCheck quite easily with the RStudio Addin from 36 | the dropdown menu. It essentially runs: 37 | 38 | ``` r 39 | BiocCheck::BiocCheck() 40 | ``` 41 | 42 | We recommend using the following keyboard shortcut: 43 | 44 | Ctrl / (Mac) + shift + C 45 | 46 | 47 | ## Version Bumps 48 | 49 | BiocAddins makes it easy to bump your package’s version by running the 50 | `bumpVersion` function: 51 | 52 | ``` r 53 | bumpVersion() 54 | ``` 55 | 56 | Note that this will increase the `Z` version of the package by 1, a.k.a, 57 | the patch version. 58 | 59 | ## Installing devel 60 | 61 | Developers who wish to install the development version of Bioconductor 62 | can do so *after* installing `BiocManager`: 63 | 64 | ``` r 65 | BiocManager::install(version = "devel") 66 | ``` 67 | 68 | Developers must ensure that the correct version of R is being used. For 69 | more information, please review the `BiocManager` package vignette. 70 | 71 | ## Session Info 72 | 73 | ``` r 74 | sessionInfo() 75 | #> R Under development (unstable) (2023-11-17 r85547) 76 | #> Platform: x86_64-pc-linux-gnu 77 | #> Running under: Ubuntu 22.04.3 LTS 78 | #> 79 | #> Matrix products: default 80 | #> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 81 | #> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0 82 | #> 83 | #> locale: 84 | #> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 85 | #> [6] LC_MESSAGES=en_US.UTF-8 LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C 86 | #> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C 87 | #> 88 | #> time zone: America/New_York 89 | #> tzcode source: system (glibc) 90 | #> 91 | #> attached base packages: 92 | #> [1] stats graphics grDevices utils datasets methods base 93 | #> 94 | #> other attached packages: 95 | #> [1] colorout_1.2-2 96 | #> 97 | #> loaded via a namespace (and not attached): 98 | #> [1] miniUI_0.1.1.1 compiler_4.4.0 BiocManager_1.30.22 BiocBaseUtils_1.5.0 promises_1.2.1 Rcpp_1.0.11 stringr_1.5.1 99 | #> [8] later_1.3.2 yaml_2.3.8 fastmap_1.1.1 mime_0.12 R6_2.5.1 BiocAddins_0.99.19 knitr_1.45 100 | #> [15] htmlwidgets_1.6.4 tibble_3.2.1 desc_1.4.3 profvis_0.3.8 shiny_1.8.0 pillar_1.9.0 rlang_1.1.2 101 | #> [22] utf8_1.2.4 cachem_1.0.8 stringi_1.8.3 xfun_0.41 httpuv_1.6.13 fs_1.6.3 pkgload_1.3.3 102 | #> [29] memoise_2.0.1 cli_3.6.2 magrittr_2.0.3 digest_0.6.33 rstudioapi_0.15.0 xtable_1.8-4 remotes_2.4.2.1 103 | #> [36] devtools_2.4.5 lifecycle_1.0.4 vctrs_0.6.5 evaluate_0.23 glue_1.6.2 urlchecker_1.0.1 codetools_0.2-19 104 | #> [43] sessioninfo_1.2.2 pkgbuild_1.4.3 fansi_1.0.6 rmarkdown_2.25 purrr_1.0.2 pkgconfig_2.0.3 tools_4.4.0 105 | #> [50] usethis_2.2.2 ellipsis_0.3.2 htmltools_0.5.7 106 | ``` 107 | --------------------------------------------------------------------------------