├── .Rbuildignore ├── .github ├── .gitignore ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── feature_request.md │ └── other_issue.md └── workflows │ ├── R-CMD-check.yaml │ ├── document-package.yaml │ ├── pkgdown.yaml │ ├── render-README.yaml │ ├── test-coverage.yaml │ ├── update-citation-cff.yaml │ └── update-codemeta.yaml ├── .gitignore ├── CITATION.cff ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── DESCRIPTION ├── LICENSE.md ├── NAMESPACE ├── NEWS.md ├── R ├── add_citation.R ├── add_code_of_conduct.R ├── add_codecov_badge.R ├── add_compendium.R ├── add_contributing.R ├── add_cran_badge.R ├── add_dependencies.R ├── add_dependencies_badge.R ├── add_description.R ├── add_dockerfile.R ├── add_github_actions_check.R ├── add_github_actions_check_badge.R ├── add_github_actions_citation.R ├── add_github_actions_codecov.R ├── add_github_actions_codecov_badge.R ├── add_github_actions_codemeta.R ├── add_github_actions_document.R ├── add_github_actions_pkgdown.R ├── add_github_actions_pkgdown_badge.R ├── add_github_actions_render.R ├── add_license.R ├── add_license_badge.R ├── add_lifecycle_badge.R ├── add_makefile.R ├── add_package_doc.R ├── add_r_depend.R ├── add_readme_rmd.R ├── add_renv.R ├── add_repostatus_badge.R ├── add_testthat.R ├── add_to_buildignore.R ├── add_to_gitignore.R ├── add_vignette.R ├── get_all_dependencies.R ├── get_all_functions.R ├── get_licenses.R ├── get_minimal_r_version.R ├── new_compendium.R ├── new_package.R ├── rcompendium-package.R ├── refresh.R ├── set_credentials.R ├── sysdata.rda ├── utils-checks.R ├── utils-deps.R ├── utils-gh.R ├── utils-io.R └── utils-sys.R ├── README.Rmd ├── README.md ├── _pkgdown.yml ├── codemeta.json ├── inst ├── CITATION ├── hexsticker │ ├── hexsticker.R │ └── icon.png ├── licenses │ ├── copyright-mit │ ├── license-agpl3 │ ├── license-apache2 │ ├── license-cc0 │ ├── license-ccby │ ├── license-gpl2 │ ├── license-gpl3 │ ├── license-lgpl21 │ ├── license-lgpl3 │ └── license-mit └── templates │ ├── CODE_OF_CONDUCT.md │ ├── CONTRIBUTING.md │ ├── DESCRIPTION │ ├── Dockerfile │ ├── R-CMD-check.yaml │ ├── README-comp.Rmd │ ├── README-pkg.Rmd │ ├── bug_report.md │ ├── citation │ ├── compendium-sticker.png │ ├── dockerignore │ ├── document-package.yaml │ ├── feature_request.md │ ├── fun-demo.R │ ├── gitignore │ ├── make.R │ ├── other_issue.md │ ├── package-package.R │ ├── package-sticker.R │ ├── package-sticker.png │ ├── package-vignette.Rmd │ ├── pkgdown.yaml │ ├── r_logo.png │ ├── render-README.yaml │ ├── test-coverage.yaml │ ├── test-demo.R │ ├── update-citation-cff.yaml │ └── update-codemeta.yaml ├── man ├── add_citation.Rd ├── add_code_of_conduct.Rd ├── add_codecov_badge.Rd ├── add_compendium.Rd ├── add_contributing.Rd ├── add_cran_badge.Rd ├── add_dependencies.Rd ├── add_dependencies_badge.Rd ├── add_description.Rd ├── add_dockerfile.Rd ├── add_github_actions_check.Rd ├── add_github_actions_check_badge.Rd ├── add_github_actions_citation.Rd ├── add_github_actions_codecov.Rd ├── add_github_actions_codecov_badge.Rd ├── add_github_actions_codemeta.Rd ├── add_github_actions_document.Rd ├── add_github_actions_pkgdown.Rd ├── add_github_actions_pkgdown_badge.Rd ├── add_github_actions_render.Rd ├── add_license.Rd ├── add_license_badge.Rd ├── add_lifecycle_badge.Rd ├── add_makefile.Rd ├── add_package_doc.Rd ├── add_r_depend.Rd ├── add_readme_rmd.Rd ├── add_renv.Rd ├── add_repostatus_badge.Rd ├── add_testthat.Rd ├── add_to_buildignore.Rd ├── add_to_gitignore.Rd ├── add_vignette.Rd ├── figures │ └── logo.png ├── get_all_dependencies.Rd ├── get_all_functions.Rd ├── get_licenses.Rd ├── get_minimal_r_version.Rd ├── new_compendium.Rd ├── new_package.Rd ├── rcompendium-package.Rd ├── refresh.Rd └── set_credentials.Rd ├── tests ├── testthat.R └── testthat │ ├── setup-tests.R │ ├── test-01-proj.R │ ├── test-02-description.R │ └── test-03-license.R └── vignettes ├── .gitignore ├── developing_a_package.Rmd ├── rcompendium.Rmd └── working_with_a_compendium.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^LICENSE\.md$ 2 | ^.*\.Rproj$ 3 | ^\.Rproj\.user$ 4 | ^README\.Rmd$ 5 | ^README\.html$ 6 | ^\.github$ 7 | ^CODE_OF_CONDUCT\.md$ 8 | ^rcompendium\.Rproj$ 9 | ^_pkgdown\.yml$ 10 | ^cran-comments\.md$ 11 | ^CRAN-SUBMISSION$ 12 | ^CITATION\.cff$ 13 | ^CONTRIBUTING\.md$ 14 | ^codemeta\.json$ 15 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Standard bug report template 4 | title: '' 5 | labels: 'bug' 6 | --- 7 | 8 | **Bug description** 9 | 10 | A clear and concise description of what the bug is. 11 | 12 | 13 | **Reproducible example** 14 | 15 | It is easier for developers to help if they can reproduce the problem. 16 | Could you please provide a minimal reproducible example? 17 | 18 | 19 | **Additional context** 20 | 21 | Add any other context about the problem here. 22 | 23 | 24 |
25 | ```r 26 | # Output of sessionInfo() 27 | ``` 28 |
29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Standard feature request template 4 | title: '' 5 | labels: 'enhancement' 6 | --- 7 | 8 | **Feature description** 9 | 10 | A clear and complete description of what the requested feature is. 11 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/other_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other issue 3 | about: Template for other issue types 4 | title: '' 5 | labels: '' 6 | --- 7 | -------------------------------------------------------------------------------- /.github/workflows/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | 4 | on: 5 | push: 6 | branches: [main, master] 7 | pull_request: 8 | branches: [main, master] 9 | 10 | name: R CMD Check 11 | 12 | jobs: 13 | R-CMD-check: 14 | runs-on: ${{ matrix.config.os }} 15 | 16 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 17 | 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | config: 22 | - {os: macos-latest, r: 'release'} 23 | - {os: windows-latest, r: 'release'} 24 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 25 | - {os: ubuntu-latest, r: 'release'} 26 | - {os: ubuntu-latest, r: 'oldrel-1'} 27 | 28 | env: 29 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 30 | R_KEEP_PKG_SOURCE: yes 31 | 32 | steps: 33 | - uses: actions/checkout@v4 34 | 35 | - uses: r-lib/actions/setup-pandoc@v2 36 | 37 | - uses: r-lib/actions/setup-r@v2 38 | with: 39 | r-version: ${{ matrix.config.r }} 40 | http-user-agent: ${{ matrix.config.http-user-agent }} 41 | use-public-rspm: true 42 | 43 | - uses: r-lib/actions/setup-r-dependencies@v2 44 | with: 45 | extra-packages: any::rcmdcheck 46 | needs: check 47 | 48 | - uses: r-lib/actions/check-r-package@v2 49 | with: 50 | upload-snapshots: true 51 | build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' 52 | -------------------------------------------------------------------------------- /.github/workflows/document-package.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | paths: ["R/**"] 6 | 7 | name: Document 8 | 9 | jobs: 10 | document: 11 | runs-on: ubuntu-latest 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - name: Checkout repo 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | 20 | - name: Setup R 21 | uses: r-lib/actions/setup-r@v2 22 | with: 23 | use-public-rspm: true 24 | 25 | - name: Install dependencies 26 | uses: r-lib/actions/setup-r-dependencies@v2 27 | with: 28 | extra-packages: any::roxygen2 29 | needs: roxygen2 30 | 31 | - name: Document 32 | run: roxygen2::roxygenise() 33 | shell: Rscript {0} 34 | 35 | - name: Commit and push changes 36 | run: | 37 | git config --local user.name "$GITHUB_ACTOR" 38 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 39 | git add man/\* NAMESPACE DESCRIPTION 40 | git commit -m "doc: update documentation" || echo "No changes to commit" 41 | git pull --ff-only 42 | git push origin 43 | -------------------------------------------------------------------------------- /.github/workflows/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | 4 | on: 5 | push: 6 | branches: [main, master] 7 | pull_request: 8 | branches: [main, master] 9 | release: 10 | types: [published] 11 | workflow_dispatch: 12 | 13 | name: Website 14 | 15 | jobs: 16 | pkgdown: 17 | runs-on: ubuntu-latest 18 | # Only restrict concurrency for non-PR jobs 19 | concurrency: 20 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 21 | env: 22 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 23 | permissions: 24 | contents: write 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - uses: r-lib/actions/setup-pandoc@v2 29 | 30 | - uses: r-lib/actions/setup-r@v2 31 | with: 32 | use-public-rspm: true 33 | 34 | - uses: r-lib/actions/setup-r-dependencies@v2 35 | with: 36 | extra-packages: any::pkgdown, local::. 37 | needs: website 38 | 39 | - name: Build site 40 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 41 | shell: Rscript {0} 42 | 43 | - name: Deploy to GitHub pages 44 | if: github.event_name != 'pull_request' 45 | uses: JamesIves/github-pages-deploy-action@v4.4.1 46 | with: 47 | clean: false 48 | branch: gh-pages 49 | folder: docs 50 | -------------------------------------------------------------------------------- /.github/workflows/render-README.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/blob/v2-branch/examples/render-rmarkdown.yaml 2 | 3 | on: 4 | push: 5 | paths: 'README.Rmd' 6 | 7 | name: Render README 8 | 9 | jobs: 10 | render-readme: 11 | runs-on: ubuntu-latest 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - name: Checkout repo 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | 20 | - uses: r-lib/actions/setup-pandoc@v2 21 | - uses: r-lib/actions/setup-r@v2 22 | 23 | - name: Install Rmarkdown 24 | run: Rscript -e 'install.packages("rmarkdown")' 25 | 26 | - name: Render README 27 | run: | 28 | RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^README.Rmd$')) 29 | Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]} 30 | 31 | - name: Commit results 32 | run: | 33 | git config --local user.name "$GITHUB_ACTOR" 34 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 35 | git commit README.md -m 'doc: render README' || echo "No changes to commit" 36 | git push origin || echo "No changes to commit" 37 | -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | 4 | on: 5 | push: 6 | branches: [main, master] 7 | pull_request: 8 | branches: [main, master] 9 | 10 | name: Test coverage 11 | 12 | jobs: 13 | test-coverage: 14 | runs-on: ubuntu-latest 15 | env: 16 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - uses: r-lib/actions/setup-r@v2 22 | with: 23 | use-public-rspm: true 24 | 25 | - uses: r-lib/actions/setup-r-dependencies@v2 26 | with: 27 | extra-packages: any::covr 28 | needs: coverage 29 | 30 | - name: Test coverage 31 | run: | 32 | covr::codecov( 33 | quiet = FALSE, 34 | clean = FALSE, 35 | install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") 36 | ) 37 | shell: Rscript {0} 38 | 39 | - name: Show testthat output 40 | if: always() 41 | run: | 42 | ## -------------------------------------------------------------------- 43 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 44 | shell: bash 45 | 46 | - name: Upload test results 47 | if: failure() 48 | uses: actions/upload-artifact@v4 49 | with: 50 | name: coverage-test-failures 51 | path: ${{ runner.temp }}/package 52 | -------------------------------------------------------------------------------- /.github/workflows/update-citation-cff.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | 3 | on: 4 | release: 5 | types: [published] 6 | push: 7 | branches: [master, main] 8 | paths: 9 | - DESCRIPTION 10 | - inst/CITATION 11 | workflow_dispatch: 12 | 13 | name: Update CITATION.cff 14 | 15 | jobs: 16 | update-citation-cff: 17 | runs-on: macos-latest 18 | env: 19 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 20 | steps: 21 | - uses: actions/checkout@v4 22 | - uses: r-lib/actions/setup-r@v2 23 | - uses: r-lib/actions/setup-r-dependencies@v2 24 | with: 25 | extra-packages: | 26 | any::cffr 27 | any::V8 28 | 29 | - name: Update CITATION.cff 30 | run: | 31 | # Update CITATION.cff file 32 | cffr::cff_write(keys = list()) 33 | shell: Rscript {0} 34 | 35 | - name: Commit results 36 | run: | 37 | git config --local user.name "$GITHUB_ACTOR" 38 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 39 | git add CITATION.cff 40 | git commit -m 'doc: update CITATION.cff' || echo "No changes to commit" 41 | git push origin || echo "No changes to commit" 42 | -------------------------------------------------------------------------------- /.github/workflows/update-codemeta.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | release: 3 | types: [published] 4 | push: 5 | branches: [master, main] 6 | paths: 7 | - DESCRIPTION 8 | - inst/CITATION 9 | - README.md 10 | workflow_dispatch: 11 | 12 | name: Update codemeta.json 13 | 14 | jobs: 15 | update-codemeta: 16 | runs-on: macos-latest 17 | env: 18 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: r-lib/actions/setup-r@v2 22 | - uses: r-lib/actions/setup-r-dependencies@v2 23 | with: 24 | extra-packages: | 25 | any::codemetar 26 | 27 | - name: Update codemeta.json 28 | run: codemetar::write_codemeta() 29 | shell: Rscript {0} 30 | 31 | - name: Commit results 32 | run: | 33 | git config --local user.name "$GITHUB_ACTOR" 34 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 35 | git add codemeta.json 36 | git commit -m 'Update codemeta.json' || echo "No changes to commit" 37 | git push origin || echo "No changes to commit" 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS files ---- 2 | .DS_Store 3 | 4 | # History files ---- 5 | .Rhistory 6 | .Rapp.history 7 | 8 | # Session Data files ---- 9 | .RData 10 | .Ruserdata 11 | 12 | # RStudio files ---- 13 | *.Rproj 14 | .Rproj.user/ 15 | 16 | # R Environment Variables ---- 17 | .Renviron 18 | 19 | # User-specific files ---- 20 | README.html 21 | CRAN-SUBMISSION 22 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: rcompendium 2 | Type: Package 3 | Title: Create a Package or Research Compendium Structure 4 | Version: 1.3.9000 5 | Authors@R: c( 6 | person(given = "Nicolas", 7 | family = "Casajus", 8 | role = c("aut", "cre", "cph"), 9 | email = "nicolas.casajus@fondationbiodiversite.fr", 10 | comment = c(ORCID = "0000-0002-5537-5294"))) 11 | Description: Makes easier the creation of R package or research compendium 12 | (i.e. a predefined files/folders structure) so that users can focus on the 13 | code/analysis instead of wasting time organizing files. A full 14 | ready-to-work structure is set up with some additional features: version 15 | control, remote repository creation, CI/CD configuration (check package 16 | integrity under several OS, test code with 'testthat', and build and deploy 17 | website using 'pkgdown'). This package heavily relies on the R packages 18 | 'devtools' and 'usethis' and follows recommendations made by Wickham H. 19 | (2015) and Marwick B. et al. (2018) 20 | . 21 | URL: https://github.com/FRBCesab/rcompendium, https://frbcesab.github.io/rcompendium/ 22 | BugReports: https://github.com/FRBCesab/rcompendium/issues 23 | License: GPL (>= 2) 24 | Encoding: UTF-8 25 | Depends: R (>= 2.10) 26 | Imports: 27 | cffr, 28 | cli, 29 | codemetar, 30 | devtools, 31 | gert, 32 | gh, 33 | gtools, 34 | renv, 35 | rmarkdown, 36 | rstudioapi, 37 | stringr, 38 | usethis, 39 | utils, 40 | xfun 41 | Roxygen: list(markdown = TRUE) 42 | RoxygenNote: 7.3.2 43 | VignetteBuilder: knitr 44 | Suggests: 45 | fs, 46 | knitr, 47 | testthat (>= 3.0.0), 48 | withr 49 | Config/testthat/edition: 3 50 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(add_citation) 4 | export(add_code_of_conduct) 5 | export(add_codecov_badge) 6 | export(add_compendium) 7 | export(add_contributing) 8 | export(add_cran_badge) 9 | export(add_dependencies) 10 | export(add_dependencies_badge) 11 | export(add_description) 12 | export(add_dockerfile) 13 | export(add_github_actions_check) 14 | export(add_github_actions_check_badge) 15 | export(add_github_actions_citation) 16 | export(add_github_actions_codecov) 17 | export(add_github_actions_codecov_badge) 18 | export(add_github_actions_codemeta) 19 | export(add_github_actions_document) 20 | export(add_github_actions_pkgdown) 21 | export(add_github_actions_pkgdown_badge) 22 | export(add_github_actions_render) 23 | export(add_license) 24 | export(add_license_badge) 25 | export(add_lifecycle_badge) 26 | export(add_makefile) 27 | export(add_package_doc) 28 | export(add_r_depend) 29 | export(add_readme_rmd) 30 | export(add_renv) 31 | export(add_repostatus_badge) 32 | export(add_testthat) 33 | export(add_to_buildignore) 34 | export(add_to_gitignore) 35 | export(add_vignette) 36 | export(get_all_dependencies) 37 | export(get_all_functions) 38 | export(get_licenses) 39 | export(get_minimal_r_version) 40 | export(new_compendium) 41 | export(new_package) 42 | export(refresh) 43 | export(set_credentials) 44 | importFrom(usethis,ui_code) 45 | importFrom(usethis,ui_done) 46 | importFrom(usethis,ui_field) 47 | importFrom(usethis,ui_info) 48 | importFrom(usethis,ui_line) 49 | importFrom(usethis,ui_oops) 50 | importFrom(usethis,ui_todo) 51 | importFrom(usethis,ui_value) 52 | -------------------------------------------------------------------------------- /R/add_citation.R: -------------------------------------------------------------------------------- 1 | #' Create a CITATION file 2 | #' 3 | #' @description 4 | #' This function creates a `CITATION` file in the folder `inst/`. This file 5 | #' contains a BiBTeX entry to cite the package as a manual. User will need to 6 | #' edit by hand some information (title, version, etc.). 7 | #' 8 | #' @param organisation A character of length 1. The name of the GitHub 9 | #' organisation to host the package. If `NULL` (default) the GitHub account 10 | #' will be used. This argument is used to set the URL of the package 11 | #' (hosted on GitHub). 12 | #' 13 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 14 | #' editor. 15 | #' 16 | #' @param overwrite A logical value. If this file is already present and 17 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 18 | #' 19 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 20 | #' `FALSE`. 21 | #' 22 | #' @inheritParams set_credentials 23 | #' 24 | #' @return No return value. 25 | #' 26 | #' @export 27 | #' 28 | #' @family create files 29 | #' 30 | #' @examples 31 | #' \dontrun{ 32 | #' add_citation() 33 | #' readCitationFile("inst/CITATION") 34 | #' citation("pkg") # If you have installed your package 35 | #' } 36 | 37 | add_citation <- function(given = NULL, family = NULL, organisation = NULL, 38 | open = TRUE, overwrite = FALSE, quiet = FALSE) { 39 | 40 | 41 | stop_if_not_logical(open, overwrite, quiet) 42 | 43 | path <- file.path(path_proj(), "inst", "CITATION") 44 | 45 | 46 | ## Do not replace current file but open it if required ---- 47 | 48 | if (file.exists(path) && !overwrite) { 49 | 50 | if (!open) { 51 | 52 | stop("An 'inst/CITATION' file is already present. If you want to ", 53 | "replace it, please use `overwrite = TRUE`.") 54 | 55 | } else { 56 | 57 | edit_file(path) 58 | return(invisible(NULL)) 59 | } 60 | } 61 | 62 | 63 | ## Get fields values ---- 64 | 65 | if (is.null(given)) given <- getOption("given") 66 | if (is.null(family)) family <- getOption("family") 67 | 68 | if (!is.null(organisation)) { 69 | 70 | github <- organisation 71 | 72 | } else { 73 | 74 | github <- gh::gh_whoami()$"login" 75 | 76 | if (is.null(github)) { 77 | stop("Unable to find GitHub username. Please run ", 78 | "`?gert::git_config_global` for more information.") 79 | } 80 | } 81 | 82 | stop_if_not_string(given, family, github) 83 | 84 | 85 | project_name <- get_package_name() 86 | pkg_version <- get_package_version() 87 | year <- format(Sys.Date(), "%Y") 88 | 89 | 90 | ## Copy Template ---- 91 | 92 | if (!dir.exists(file.path(path_proj(), "inst"))) 93 | dir.create(file.path(path_proj(), "inst"), showWarnings = FALSE) 94 | 95 | invisible( 96 | file.copy(system.file(file.path("templates", "citation"), 97 | package = "rcompendium"), path, overwrite = TRUE)) 98 | 99 | 100 | ## Change defaults values ---- 101 | 102 | xfun::gsub_file(path, "{{project_name}}", project_name, fixed = TRUE) 103 | xfun::gsub_file(path, "{{pkg_version}}", pkg_version, fixed = TRUE) 104 | xfun::gsub_file(path, "{{year}}", year, fixed = TRUE) 105 | xfun::gsub_file(path, "{{given}}", given, fixed = TRUE) 106 | xfun::gsub_file(path, "{{family}}", family, fixed = TRUE) 107 | xfun::gsub_file(path, "{{github}}", github, fixed = TRUE) 108 | 109 | 110 | ## Messages ---- 111 | 112 | if (!quiet) ui_done("Writing {ui_value('inst/CITATION')} file") 113 | 114 | if (open) edit_file(path) 115 | 116 | invisible(NULL) 117 | } 118 | -------------------------------------------------------------------------------- /R/add_code_of_conduct.R: -------------------------------------------------------------------------------- 1 | #' Add code of conduct 2 | #' 3 | #' @description 4 | #' This function creates a `CODE_OF_CONDUCT.md` file adapted from the 5 | #' Contributor Covenant, version 2.1 available at 6 | #' \url{https://www.contributor-covenant.org/version/2/1/code_of_conduct.html}. 7 | #' 8 | #' @param open A logical value. If `TRUE` (default) the `CONTRIBUTING.md` file 9 | #' is opened in the editor. 10 | #' 11 | #' @param overwrite A logical value. If files are already present and 12 | #' `overwrite = TRUE`, they will be erased and replaced. Default is `FALSE`. 13 | #' 14 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 15 | #' `FALSE`. 16 | #' 17 | #' @inheritParams set_credentials 18 | #' 19 | #' @return No return value. 20 | #' 21 | #' @export 22 | #' 23 | #' @family create files 24 | #' 25 | #' @examples 26 | #' \dontrun{ 27 | #' add_code_of_conduct() 28 | #' } 29 | 30 | add_code_of_conduct <- function(email = NULL, 31 | open = TRUE, overwrite = FALSE, quiet = FALSE) { 32 | 33 | 34 | stop_if_not_logical(open, overwrite, quiet) 35 | 36 | path <- file.path(path_proj(), "CODE_OF_CONDUCT.md") 37 | 38 | 39 | ## Do not replace current file but open it if required ---- 40 | 41 | if (file.exists(path) && !overwrite) { 42 | 43 | if (!open) { 44 | 45 | stop("A 'CODE_OF_CONDUCT.md' file is already present. If you want to ", 46 | "replace it, please use `overwrite = TRUE`.") 47 | 48 | } else { 49 | 50 | edit_file(path) 51 | return(invisible(NULL)) 52 | } 53 | } 54 | 55 | 56 | ## Get fields values ---- 57 | 58 | if (is.null(email)) email <- getOption("email") 59 | 60 | 61 | stop_if_not_string(email) 62 | 63 | 64 | ## Copy Template ---- 65 | 66 | invisible( 67 | file.copy(system.file(file.path("templates", "CODE_OF_CONDUCT.md"), 68 | package = "rcompendium"), path, overwrite = TRUE)) 69 | 70 | 71 | ## Change defaults values ---- 72 | 73 | xfun::gsub_file(path, "{{email}}", email, fixed = TRUE) 74 | 75 | 76 | ## Messages ---- 77 | 78 | if (!quiet) { 79 | ui_done("Writing {ui_value('CODE_OF_CONDUCT.md')} file") 80 | } 81 | 82 | add_to_buildignore("CODE_OF_CONDUCT.md", quiet = quiet) 83 | 84 | 85 | if (open) edit_file(path) 86 | 87 | invisible(NULL) 88 | } 89 | -------------------------------------------------------------------------------- /R/add_codecov_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a Codecov badge 2 | #' 3 | #' @description 4 | #' This function adds a **Code coverage** badge to the `README.Rmd`, i.e. the 5 | #' percentage of code cover by units tests. This percentage is computed by 6 | #' the codecov.io service. 7 | #' 8 | #' **Note:** this service must be manually activated for the package by visiting 9 | #' \url{https://about.codecov.io/}. 10 | #' 11 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 12 | #' contains a block starting with the line `` and ending 13 | #' with the line ``. 14 | #' 15 | #' Don't forget to re-render the `README.md`. 16 | #' 17 | #' @param organisation A character of length 1. The name of the GitHub 18 | #' organisation to host the package. If `NULL` (default) the GitHub account 19 | #' will be used. 20 | #' 21 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 22 | #' `FALSE`. 23 | #' 24 | #' @return A badge as a markdown expression. 25 | #' 26 | #' @export 27 | #' 28 | #' @family adding badges 29 | #' 30 | #' @examples 31 | #' \dontrun{ 32 | #' add_codecov_badge() 33 | #' } 34 | 35 | add_codecov_badge <- function(organisation = NULL, quiet = FALSE) { 36 | 37 | 38 | stop_if_not_logical(quiet) 39 | 40 | ## Check if GH Actions are set ---- 41 | 42 | if (!file.exists(file.path(path_proj(), ".github", "workflows", 43 | "test-coverage.yaml"))) { 44 | stop("Please run `add_github_actions_codecov()` to setup GitHub Actions.") 45 | } 46 | 47 | 48 | ## Retrieve GitHub pseudo/organization ---- 49 | 50 | if (!is.null(organisation)) { 51 | 52 | github <- organisation 53 | 54 | } else { 55 | 56 | github <- gh::gh_whoami()$"login" 57 | 58 | if (is.null(github)) { 59 | stop("Unable to find GitHub username. Please run ", 60 | "`?gert::git_config_global` for more information.") 61 | } 62 | } 63 | 64 | 65 | stop_if_not_string(github) 66 | 67 | 68 | ## Check URL ---- 69 | 70 | is_gh_user() 71 | 72 | project_name <- get_package_name() 73 | 74 | 75 | ## Create Badge Markdown Expression ---- 76 | 77 | alt <- "codecov" 78 | href <- paste0("https://codecov.io/gh/", github,"/", project_name) 79 | img <- paste0("https://codecov.io/gh/", github,"/", project_name, 80 | "/branch/", gert::git_branch(), "/graph/badge.svg") 81 | 82 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 83 | 84 | 85 | ## Add Badge ---- 86 | 87 | add_badge(badge, pattern = alt) 88 | 89 | 90 | if (!quiet) { 91 | ui_done(paste0("Adding {ui_field('codecov')} badge to ", 92 | "{ui_value('README.Rmd')}")) 93 | } 94 | 95 | invisible(badge) 96 | } 97 | -------------------------------------------------------------------------------- /R/add_compendium.R: -------------------------------------------------------------------------------- 1 | #' Create additional folders 2 | #' 3 | #' @description 4 | #' This function creates a compendium, i.e. additional folders to a package 5 | #' structure. By default, the following directories are created: 6 | #' `data`, `analyses/`, `outputs/`, and `figures/`. A `README.md` is added to 7 | #' each folder and must be edited. The argument `compendium` allows user to 8 | #' hoose its own compendium structure. All theses folders are added to the 9 | #' `.Rbuildignore` file. 10 | #' 11 | #' @param compendium A character vector specifying the folders to be created. 12 | #' 13 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 14 | #' `FALSE`. 15 | #' 16 | #' @return No return value. 17 | #' 18 | #' @export 19 | #' 20 | #' @family create files 21 | #' 22 | #' @examples 23 | #' \dontrun{ 24 | #' add_compendium() 25 | #' add_compendium(compendium = "paper") 26 | #' add_compendium(compendium = c("data", "outputs", "code", "manuscript")) 27 | #' } 28 | 29 | add_compendium <- function(compendium = NULL, quiet = FALSE) { 30 | 31 | stop_if_not_logical(quiet) 32 | 33 | if (is.null(compendium)) { 34 | compendium <- c("data", "outputs", "figures", "analyses") 35 | } 36 | 37 | if (!is.character(compendium)) { 38 | stop("Argument 'compendium' must be a character.") 39 | } 40 | 41 | path <- path_proj() 42 | 43 | for (i in 1:length(compendium)) { 44 | 45 | if (!dir.exists(file.path(path, compendium[i]))) { 46 | 47 | dir.create(file.path(path, compendium[i]), recursive = TRUE) 48 | 49 | if (!quiet) { 50 | ui_done("Creating {ui_value(paste0(compendium[i], '/'))} directory") 51 | } 52 | } 53 | 54 | add_to_buildignore(compendium, quiet = quiet) 55 | 56 | 57 | if (!file.exists(file.path(path, compendium[i], "README.md"))) { 58 | 59 | readme <- c("# README", 60 | "", 61 | "**{{ PLEASE DESCRIBE THE CONTENT OF THIS FOLDER}}**") 62 | 63 | writeLines(readme, con = file.path(path, compendium[i], "README.md")) 64 | 65 | if (!quiet) { 66 | 67 | ui_done(paste0("Adding a {ui_value('README.md')} to ", 68 | "{ui_value(paste0(compendium[i], '/'))} directory")) 69 | cli::cat_line() 70 | } 71 | } 72 | } 73 | 74 | invisible(NULL) 75 | } 76 | -------------------------------------------------------------------------------- /R/add_cran_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a CRAN Status badge 2 | #' 3 | #' @description 4 | #' This function adds a **CRAN Status** badge to the `README.Rmd`. If the 5 | #' package is not hosted on the CRAN the badge will indicate 6 | #' _not published on the CRAN_. 7 | #' 8 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 9 | #' contains a block starting with the line `` and ending 10 | #' with the line ``. 11 | #' 12 | #' Don't forget to re-render the `README.md`. 13 | #' 14 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 15 | #' `FALSE`. 16 | #' 17 | #' @return A badge as a markdown expression. 18 | #' 19 | #' @export 20 | #' 21 | #' @family adding badges 22 | #' 23 | #' @examples 24 | #' \dontrun{ 25 | #' add_cran_badge() 26 | #' } 27 | 28 | add_cran_badge <- function(quiet = FALSE) { 29 | 30 | 31 | stop_if_not_logical(quiet) 32 | 33 | ## Create Badge Markdown Expression ---- 34 | 35 | project_name <- get_package_name() 36 | 37 | alt <- "CRAN status" 38 | href <- paste0("https://CRAN.R-project.org/package=", project_name) 39 | img <- paste0("https://www.r-pkg.org/badges/version/", project_name) 40 | 41 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 42 | 43 | 44 | ## Add Badge ---- 45 | 46 | add_badge(badge, pattern = "CRAN status") 47 | 48 | 49 | if (!quiet) { 50 | ui_done(paste0("Adding {ui_field('CRAN status')} badge to ", 51 | "{ui_value('README.Rmd')}")) 52 | } 53 | 54 | invisible(badge) 55 | } 56 | -------------------------------------------------------------------------------- /R/add_dependencies_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a Dependencies badge 2 | #' 3 | #' @description 4 | #' This function adds or updates the **Dependencies** badge to the `README.Rmd`. 5 | #' The first number corresponds to the direct dependencies and the second to the 6 | #' recursive dependencies. 7 | #' 8 | #' **Note:** this function can work with packages not published on the CRAN 9 | #' and is based on the function [gtools::getDependencies()]. See also the 10 | #' function [get_all_dependencies()]. 11 | #' 12 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 13 | #' contains a block starting with the line `` and ending 14 | #' with the line ``. 15 | #' 16 | #' Don't forget to re-render the `README.md`. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return A badge as a markdown expression. 22 | #' 23 | #' @export 24 | #' 25 | #' @family adding badges 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_dependencies_badge() 30 | #' } 31 | 32 | add_dependencies_badge <- function(quiet = FALSE) { 33 | 34 | 35 | stop_if_not_logical(quiet) 36 | 37 | deps <- get_all_dependencies() 38 | deps <- unlist(lapply(deps, length)) 39 | 40 | 41 | ## Create Badge Markdown Expression ---- 42 | 43 | if (deps["direct_deps"] == 0) 44 | color <- "brightgreen" 45 | if (deps["direct_deps"] > 0 && 46 | deps["direct_deps"] < 5) 47 | color <- "green" 48 | if (deps["direct_deps"] > 4 && 49 | deps["direct_deps"] < 10) 50 | color <- "orange" 51 | if (deps["direct_deps"] > 9) 52 | color <- "red" 53 | 54 | url <- "https://img.shields.io/badge/dependencies" 55 | 56 | img <- paste0(url, "-", deps["direct_deps"], "/", deps["all_deps"], "-") 57 | img <- paste0(img, color, "?style=flat") 58 | 59 | badge <- paste0("[![Dependencies](", img, ")](#)") 60 | 61 | 62 | ## Add Badge ---- 63 | 64 | add_badge(badge, pattern = "Dependencies") 65 | 66 | 67 | if (!quiet) { 68 | ui_done(paste0("Adding {ui_field('Dependencies')} badge to ", 69 | "{ui_value('README.Rmd')}")) 70 | } 71 | 72 | invisible(badge) 73 | } 74 | -------------------------------------------------------------------------------- /R/add_description.R: -------------------------------------------------------------------------------- 1 | #' Create a DESCRIPTION file 2 | #' 3 | #' @description 4 | #' This function creates a `DESCRIPTION` file at the root of the project. This 5 | #' file contains metadata of the project. Some information (title, description, 6 | #' version, etc.) must be edited by hand. For more information: 7 | #' \url{https://r-pkgs.org/description.html}. 8 | #' User credentials can be passed as arguments but it is recommended to store 9 | #' them in the `.Rprofile` file with [set_credentials()]. 10 | #' 11 | #' @param organisation A character of length 1. The name of the GitHub 12 | #' organisation to host the package. If `NULL` (default) the GitHub account 13 | #' will be used. 14 | #' 15 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 16 | #' editor. 17 | #' 18 | #' @param overwrite A logical value. If a `DESCRIPTION` is already present and 19 | #' `overwrite = TRUE`, this file will be erased and replaced. Default is 20 | #' `FALSE`. 21 | #' 22 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 23 | #' `FALSE`. 24 | #' 25 | #' @inheritParams set_credentials 26 | #' 27 | #' @return No return value. 28 | #' 29 | #' @export 30 | #' 31 | #' @family create files 32 | #' 33 | #' @examples 34 | #' \dontrun{ 35 | #' add_description(organisation = "MySociety") 36 | #' } 37 | 38 | add_description <- function(given = NULL, family = NULL, email = NULL, 39 | orcid = NULL, organisation = NULL, open = TRUE, 40 | overwrite = FALSE, quiet = FALSE) { 41 | 42 | 43 | stop_if_not_logical(open, overwrite, quiet) 44 | 45 | 46 | path <- file.path(path_proj(), "DESCRIPTION") 47 | 48 | 49 | ## Do not replace current file but open it if required ---- 50 | 51 | if (file.exists(path) && !overwrite) { 52 | 53 | if (!open) { 54 | 55 | stop("A 'DESCRIPTION' file is already present. If you want to ", 56 | "replace it, please use `overwrite = TRUE`.") 57 | 58 | } else { 59 | 60 | edit_file(path) 61 | return(invisible(NULL)) 62 | } 63 | } 64 | 65 | 66 | ## Get fields values ---- 67 | 68 | if (is.null(given)) given <- getOption("given") 69 | if (is.null(family)) family <- getOption("family") 70 | if (is.null(email)) email <- getOption("email") 71 | if (is.null(orcid)) orcid <- getOption("orcid") 72 | 73 | if (!is.null(organisation)) { 74 | 75 | github <- organisation 76 | 77 | } else { 78 | 79 | github <- gh::gh_whoami()$"login" 80 | 81 | if (is.null(github)) { 82 | stop("Unable to find GitHub username. Please run ", 83 | "`?gert::git_config_global` for more information.") 84 | } 85 | } 86 | 87 | 88 | stop_if_not_string(given, family, email, github) 89 | 90 | if (!is.null(orcid)) stop_if_not_string(orcid) 91 | 92 | 93 | project_name <- get_package_name() 94 | roxygen2_version <- get_roxygen2_version() 95 | 96 | 97 | ## Copy Template ---- 98 | 99 | invisible( 100 | file.copy(system.file(file.path("templates", "DESCRIPTION"), 101 | package = "rcompendium"), path, overwrite = TRUE)) 102 | 103 | 104 | ## Change default values (in file) ---- 105 | 106 | xfun::gsub_file(path, "{{project_name}}", project_name, fixed = TRUE) 107 | xfun::gsub_file(path, "{{roxygen2_version}}", roxygen2_version, fixed = TRUE) 108 | xfun::gsub_file(path, "{{given}}", given, fixed = TRUE) 109 | xfun::gsub_file(path, "{{family}}", family, fixed = TRUE) 110 | xfun::gsub_file(path, "{{email}}", email, fixed = TRUE) 111 | xfun::gsub_file(path, "{{github}}", github, fixed = TRUE) 112 | 113 | if (!is.null(orcid)) xfun::gsub_file(path, "{{orcid}}", orcid, fixed = TRUE) 114 | 115 | 116 | ## Message ---- 117 | 118 | if (!quiet) ui_done("Writing {ui_value('DESCRIPTION')} file") 119 | 120 | if (open) edit_file(path) 121 | 122 | invisible(NULL) 123 | } 124 | -------------------------------------------------------------------------------- /R/add_github_actions_check.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to check package 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to check the package. 6 | #' This workflow is derived 7 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 8 | #' This file will be written as `.github/workflows/R-CMD-check.yaml`. 9 | #' 10 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 11 | #' editor. 12 | #' 13 | #' @param overwrite A logical value. If this file is already present and 14 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 15 | #' 16 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 17 | #' `FALSE`. 18 | #' 19 | #' @details 20 | #' This workflow runs `R CMD check` on the three major operating systems 21 | #' (Ubuntu, macOS, and Windows) using the latest release of R. The package is 22 | #' also checked on Ubuntu (latest version) using the development and previous 23 | #' versions of R. 24 | #' 25 | #' @return No return value. 26 | #' 27 | #' @export 28 | #' 29 | #' @family development functions 30 | #' 31 | #' @examples 32 | #' \dontrun{ 33 | #' add_github_actions_check() 34 | #' } 35 | 36 | add_github_actions_check <- function(open = FALSE, overwrite = FALSE, 37 | quiet = FALSE) { 38 | 39 | 40 | stop_if_not_logical(open, overwrite, quiet) 41 | 42 | if (!dir.exists(file.path(path_proj(), ".git"))) { 43 | stop("The project is not versioning with git.") 44 | } 45 | 46 | 47 | path <- file.path(path_proj(), ".github", "workflows", "R-CMD-check.yaml") 48 | 49 | 50 | ## Do not replace current file but open it if required ---- 51 | 52 | if (file.exists(path) && !overwrite) { 53 | 54 | if (!open) { 55 | 56 | stop("An '.github/workflows/R-CMD-check.yaml' file is already present. ", 57 | "If you want to replace it, please use `overwrite = TRUE`.") 58 | 59 | } else { 60 | 61 | edit_file(path) 62 | return(invisible(NULL)) 63 | } 64 | } 65 | 66 | 67 | ## Copy Template ---- 68 | 69 | dir.create(file.path(path_proj(), ".github", "workflows"), 70 | showWarnings = FALSE, recursive = TRUE) 71 | 72 | add_to_buildignore(".github", quiet = FALSE) 73 | 74 | invisible( 75 | file.copy(system.file(file.path("templates", "R-CMD-check.yaml"), 76 | package = "rcompendium"), path)) 77 | 78 | 79 | if (!quiet) 80 | ui_done("Writing {ui_value('.github/workflows/R-CMD-check.yaml')} file") 81 | 82 | if (open) edit_file(path) 83 | 84 | invisible(NULL) 85 | } 86 | -------------------------------------------------------------------------------- /R/add_github_actions_check_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a R CMD Check badge 2 | #' 3 | #' @description 4 | #' This function adds a **R CMD Check** badge to the `README.Rmd`. This function 5 | #' must be run after [add_github_actions_check()] which will setup GitHub 6 | #' Actions to check and test the package. 7 | #' 8 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 9 | #' contains a block starting with the line `` and ending 10 | #' with the line ``. 11 | #' 12 | #' Don't forget to re-render the `README.md`. 13 | #' 14 | #' @param organisation A character of length 1. The name of the GitHub 15 | #' organisation to host the package. If `NULL` (default) the GitHub account 16 | #' will be used. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return A badge as a markdown expression. 22 | #' 23 | #' @export 24 | #' 25 | #' @family adding badges 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_github_actions_check_badge() 30 | #' } 31 | 32 | add_github_actions_check_badge <- function(organisation = NULL, 33 | quiet = FALSE) { 34 | 35 | 36 | stop_if_not_logical(quiet) 37 | 38 | ## Check if GH Actions are set ---- 39 | 40 | if (!file.exists(file.path(path_proj(), ".github", "workflows", 41 | "R-CMD-check.yaml"))) { 42 | stop("Please run `add_github_actions_check()` to setup GitHub Actions.") 43 | } 44 | 45 | 46 | ## Retrieve GitHub pseudo/organization ---- 47 | 48 | if (!is.null(organisation)) { 49 | 50 | github <- organisation 51 | 52 | } else { 53 | 54 | github <- gh::gh_whoami()$"login" 55 | 56 | if (is.null(github)) { 57 | stop("Unable to find GitHub username. Please run ", 58 | "`?gert::git_config_global` for more information.") 59 | } 60 | } 61 | 62 | 63 | stop_if_not_string(github) 64 | 65 | 66 | ## Check URL ---- 67 | 68 | is_gh_user() 69 | 70 | project_name <- get_package_name() 71 | 72 | 73 | ## Create Badge Markdown Expression ---- 74 | 75 | alt <- "R CMD Check" 76 | href <- paste("https://github.com", github, project_name, 77 | "actions/workflows/R-CMD-check.yaml", sep = "/") 78 | img <- paste("https://github.com", github, project_name, 79 | "actions/workflows/R-CMD-check.yaml/badge.svg", sep = "/") 80 | 81 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 82 | 83 | 84 | ## Add Badge ---- 85 | 86 | add_badge(badge, pattern = alt) 87 | 88 | if (!quiet) { 89 | ui_done(paste0("Adding {ui_field('R CMD Check')} badge to ", 90 | "{ui_value('README.Rmd')}")) 91 | } 92 | 93 | 94 | invisible(badge) 95 | } 96 | -------------------------------------------------------------------------------- /R/add_github_actions_citation.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to update CITATION.cff 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to update the `CITATION.cff`. 6 | #' This workflow is derived 7 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 8 | #' This file will be written as `.github/workflows/update-citation-cff.yaml`. 9 | #' 10 | #' This function also create the `CITATION.cff` using the package [cffr]. 11 | #' 12 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 13 | #' editor. 14 | #' 15 | #' @param overwrite A logical value. If this file is already present and 16 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return No return value. 22 | #' 23 | #' @export 24 | #' 25 | #' @family development functions 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_github_actions_citation() 30 | #' } 31 | 32 | add_github_actions_citation <- function(open = FALSE, overwrite = FALSE, 33 | quiet = FALSE) { 34 | 35 | 36 | stop_if_not_logical(open, overwrite, quiet) 37 | 38 | if (!dir.exists(file.path(path_proj(), ".git"))) { 39 | stop("The project is not versioning with git.") 40 | } 41 | 42 | 43 | path <- file.path(path_proj(), ".github", "workflows", 44 | "update-citation-cff.yaml") 45 | 46 | 47 | ## Do not replace current file but open it if required ---- 48 | 49 | if (file.exists(path) && !overwrite) { 50 | 51 | if (!open) { 52 | 53 | stop("An '.github/workflows/update-citation-cff.yaml' file is already ", 54 | "present. If you want to replace it, please use `overwrite = TRUE`.") 55 | 56 | } else { 57 | 58 | edit_file(path) 59 | return(invisible(NULL)) 60 | } 61 | } 62 | 63 | 64 | ## Copy Template ---- 65 | 66 | dir.create(file.path(path_proj(), ".github", "workflows"), 67 | showWarnings = FALSE, recursive = TRUE) 68 | 69 | add_to_buildignore(".github", quiet = FALSE) 70 | 71 | invisible( 72 | file.copy(system.file(file.path("templates", "update-citation-cff.yaml"), 73 | package = "rcompendium"), path)) 74 | 75 | 76 | if (!quiet) 77 | ui_done(paste0("Writing {ui_value('.github/workflows/", 78 | "update-citation-cff.yaml')} file")) 79 | 80 | 81 | ## Add CITATION.cff file ---- 82 | 83 | cffr::cff_write(verbose = FALSE) 84 | 85 | 86 | ## Messages ---- 87 | 88 | if (!quiet) ui_done("Writing {ui_value('CITATION.cff')} file") 89 | 90 | if (open) edit_file(path) 91 | 92 | invisible(NULL) 93 | } 94 | -------------------------------------------------------------------------------- /R/add_github_actions_codecov.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to report code coverage 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to report code coverage when testing the package. 6 | #' This workflow is derived 7 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 8 | #' This file will be written as `.github/workflows/test-coverage.yaml`. 9 | #' 10 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 11 | #' editor. 12 | #' 13 | #' @param overwrite A logical value. If this file is already present and 14 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 15 | #' 16 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 17 | #' `FALSE`. 18 | #' 19 | #' @return No return value. 20 | #' 21 | #' @export 22 | #' 23 | #' @family development functions 24 | #' 25 | #' @examples 26 | #' \dontrun{ 27 | #' add_github_actions_codecov() 28 | #' } 29 | 30 | add_github_actions_codecov <- function(open = FALSE, overwrite = FALSE, 31 | quiet = FALSE) { 32 | 33 | 34 | stop_if_not_logical(open, overwrite, quiet) 35 | 36 | if (!dir.exists(file.path(path_proj(), ".git"))) { 37 | stop("The project is not versioning with git.") 38 | } 39 | 40 | 41 | path <- file.path(path_proj(), ".github", "workflows", "test-coverage.yaml") 42 | 43 | 44 | ## Do not replace current file but open it if required ---- 45 | 46 | if (file.exists(path) && !overwrite) { 47 | 48 | if (!open) { 49 | 50 | stop("An '.github/workflows/test-coverage.yaml' file is already ", 51 | "present. If you want to replace it, please use `overwrite = TRUE`") 52 | 53 | } else { 54 | 55 | edit_file(path) 56 | return(invisible(NULL)) 57 | } 58 | } 59 | 60 | 61 | ## Copy Template ---- 62 | 63 | dir.create(file.path(path_proj(), ".github", "workflows"), 64 | showWarnings = FALSE, recursive = TRUE) 65 | 66 | add_to_buildignore(".github", quiet = FALSE) 67 | 68 | invisible( 69 | file.copy(system.file(file.path("templates", "test-coverage.yaml"), 70 | package = "rcompendium"), path)) 71 | 72 | 73 | if (!quiet) 74 | ui_done("Writing {ui_value('.github/workflows/test-coverage.yaml')} file") 75 | 76 | if (open) edit_file(path) 77 | 78 | invisible(NULL) 79 | } 80 | -------------------------------------------------------------------------------- /R/add_github_actions_codecov_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a Test coverage badge 2 | #' 3 | #' @description 4 | #' This function adds a **Test coverage** badge to the `README.Rmd`. This 5 | #' function must be run after [add_github_actions_codecov()] which will setup 6 | #' GitHub Actions to report the percentage of code cover by units tests. 7 | #' 8 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 9 | #' contains a block starting with the line `` and ending 10 | #' with the line ``. 11 | #' 12 | #' Don't forget to re-render the `README.md`. 13 | #' 14 | #' @param organisation A character of length 1. The name of the GitHub 15 | #' organisation to host the package. If `NULL` (default) the GitHub account 16 | #' will be used. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return A badge as a markdown expression. 22 | #' 23 | #' @export 24 | #' 25 | #' @family adding badges 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_github_actions_codecov_badge() 30 | #' } 31 | 32 | add_github_actions_codecov_badge <- function(organisation = NULL, 33 | quiet = FALSE) { 34 | 35 | 36 | stop_if_not_logical(quiet) 37 | 38 | ## Check if GH Actions are set ---- 39 | 40 | if (!file.exists(file.path(path_proj(), ".github", "workflows", 41 | "test-coverage.yaml"))) { 42 | stop("Please run `add_github_actions_codecov()` to setup GitHub Actions.") 43 | } 44 | 45 | 46 | ## Retrieve GitHub pseudo/organization ---- 47 | 48 | if (!is.null(organisation)) { 49 | 50 | github <- organisation 51 | 52 | } else { 53 | 54 | github <- gh::gh_whoami()$"login" 55 | 56 | if (is.null(github)) { 57 | stop("Unable to find GitHub username. Please run ", 58 | "`?gert::git_config_global` for more information.") 59 | } 60 | } 61 | 62 | 63 | stop_if_not_string(github) 64 | 65 | 66 | ## Check URL ---- 67 | 68 | is_gh_user() 69 | 70 | project_name <- get_package_name() 71 | 72 | 73 | ## Create Badge Markdown Expression ---- 74 | 75 | alt <- "Test coverage" 76 | href <- paste("https://github.com", github, project_name, 77 | "actions/workflows/test-coverage.yaml", sep = "/") 78 | img <- paste("https://github.com", github, project_name, 79 | "actions/workflows/test-coverage.yaml/badge.svg", sep = "/") 80 | 81 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 82 | 83 | 84 | ## Add Badge ---- 85 | 86 | add_badge(badge, pattern = alt) 87 | 88 | if (!quiet) { 89 | ui_done(paste0("Adding {ui_field('Test coverage')} badge to ", 90 | "{ui_value('README.Rmd')}")) 91 | } 92 | 93 | 94 | invisible(badge) 95 | } 96 | -------------------------------------------------------------------------------- /R/add_github_actions_codemeta.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to update codemeta.json 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to update the `codemeta.json`. 6 | #' This workflow is derived 7 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 8 | #' This file will be written as `.github/workflows/update-citation-cff.yaml`. 9 | #' 10 | #' This function also create the `codemeta.json` using the package [codemetar]. 11 | #' 12 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 13 | #' editor. 14 | #' 15 | #' @param overwrite A logical value. If this file is already present and 16 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return No return value. 22 | #' 23 | #' @export 24 | #' 25 | #' @family development functions 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_github_actions_codemeta() 30 | #' } 31 | 32 | add_github_actions_codemeta <- function(open = FALSE, overwrite = FALSE, 33 | quiet = FALSE) { 34 | 35 | 36 | stop_if_not_logical(open, overwrite, quiet) 37 | 38 | if (!dir.exists(file.path(path_proj(), ".git"))) { 39 | stop("The project is not versioning with git.") 40 | } 41 | 42 | 43 | path <- file.path(path_proj(), ".github", "workflows", "update-codemeta.yaml") 44 | 45 | 46 | ## Do not replace current file but open it if required ---- 47 | 48 | if (file.exists(path) && !overwrite) { 49 | 50 | if (!open) { 51 | 52 | stop("An '.github/workflows/update-codemeta.yaml' file is already ", 53 | "present. If you want to replace it, please use `overwrite = TRUE`.") 54 | 55 | } else { 56 | 57 | edit_file(path) 58 | 59 | return(invisible(NULL)) 60 | } 61 | } 62 | 63 | 64 | ## Copy Template ---- 65 | 66 | dir.create(file.path(path_proj(), ".github", "workflows"), 67 | showWarnings = FALSE, recursive = TRUE) 68 | 69 | add_to_buildignore(".github", quiet = FALSE) 70 | 71 | invisible( 72 | file.copy(system.file(file.path("templates", "update-codemeta.yaml"), 73 | package = "rcompendium"), path)) 74 | 75 | 76 | if (!quiet) 77 | ui_done(paste0("Writing {ui_value('.github/workflows/", 78 | "update-codemeta.yaml')} file")) 79 | 80 | 81 | ## Add codemeta.json file ---- 82 | 83 | codemetar::write_codemeta(verbose = FALSE) 84 | 85 | 86 | ## Messages ---- 87 | 88 | if (!quiet) ui_done("Writing {ui_value('codemeta.json')} file") 89 | 90 | if (open) edit_file(path) 91 | 92 | invisible(NULL) 93 | } 94 | -------------------------------------------------------------------------------- /R/add_github_actions_document.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to document package 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to document the package and update the `Rd` files in the `man/`, the 6 | #' `NAMESPACE` and `DESCRIPTION` files. 7 | #' This workflow is derived 8 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 9 | #' This file will be written as `.github/workflows/document-package.yaml`. 10 | #' 11 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 12 | #' editor. 13 | #' 14 | #' @param overwrite A logical value. If this file is already present and 15 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 16 | #' 17 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 18 | #' `FALSE`. 19 | #' 20 | #' @return No return value. 21 | #' 22 | #' @export 23 | #' 24 | #' @family development functions 25 | #' 26 | #' @examples 27 | #' \dontrun{ 28 | #' add_github_actions_document() 29 | #' } 30 | 31 | add_github_actions_document <- function(open = FALSE, overwrite = FALSE, 32 | quiet = FALSE) { 33 | 34 | 35 | stop_if_not_logical(open, overwrite, quiet) 36 | 37 | if (!dir.exists(file.path(path_proj(), ".git"))) { 38 | stop("The project is not versioning with git.") 39 | } 40 | 41 | 42 | path <- file.path(path_proj(), ".github", "workflows", 43 | "document-package.yaml") 44 | 45 | 46 | ## Do not replace current file but open it if required ---- 47 | 48 | if (file.exists(path) && !overwrite) { 49 | 50 | if (!open) { 51 | 52 | stop("An '.github/workflows/document-package.yaml' file is already ", 53 | "present. If you want to replace it, please use `overwrite = TRUE`.") 54 | 55 | } else { 56 | 57 | edit_file(path) 58 | return(invisible(NULL)) 59 | } 60 | } 61 | 62 | 63 | ## Copy Template ---- 64 | 65 | dir.create(file.path(path_proj(), ".github", "workflows"), 66 | showWarnings = FALSE, recursive = TRUE) 67 | 68 | add_to_buildignore(".github", quiet = FALSE) 69 | 70 | invisible( 71 | file.copy(system.file(file.path("templates", "document-package.yaml"), 72 | package = "rcompendium"), path)) 73 | 74 | 75 | if (!quiet) { 76 | ui_done(paste0("Writing ", 77 | "{ui_value('.github/workflows/document-package.yaml')} ", 78 | "file")) 79 | } 80 | 81 | 82 | if (open) edit_file(path) 83 | 84 | invisible(NULL) 85 | } 86 | -------------------------------------------------------------------------------- /R/add_github_actions_pkgdown.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to build and deploy package website 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to automatically build and deploy the website using 6 | #' [`pkgdown`](https://pkgdown.r-lib.org/index.html). This workflow is derived 7 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 8 | #' This file will be written as `.github/workflows/pkgdown.yaml`. 9 | #' An additional empty file (`_pkgdown.yaml`) will also be written: it can be 10 | #' used to customize the website. 11 | #' 12 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 13 | #' editor. 14 | #' 15 | #' @param overwrite A logical value. If this file is already present and 16 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return No return value. 22 | #' 23 | #' @export 24 | #' 25 | #' @family development functions 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_github_actions_pkgdown() 30 | #' } 31 | 32 | add_github_actions_pkgdown <- function(open = FALSE, overwrite = FALSE, 33 | quiet = FALSE) { 34 | 35 | 36 | stop_if_not_logical(open, overwrite, quiet) 37 | 38 | if (!dir.exists(file.path(path_proj(), ".git"))) { 39 | stop("The project is not versioning with git.") 40 | } 41 | 42 | path <- file.path(path_proj(), ".github", "workflows", "pkgdown.yaml") 43 | 44 | 45 | ## Do not replace current file but open it if required ---- 46 | 47 | if (file.exists(path) && !overwrite) { 48 | 49 | if (!open) { 50 | 51 | stop("An '.github/workflows/pkgdown.yaml' file is already present. ", 52 | "If you want to replace it, please use `overwrite = TRUE`.") 53 | 54 | } else { 55 | 56 | edit_file(path) 57 | return(invisible(NULL)) 58 | } 59 | } 60 | 61 | 62 | ## Copy Template ---- 63 | 64 | dir.create(file.path(path_proj(), ".github", "workflows"), 65 | showWarnings = FALSE, recursive = TRUE) 66 | 67 | add_to_buildignore(".github", quiet = FALSE) 68 | 69 | invisible( 70 | file.copy(system.file(file.path("templates", "pkgdown.yaml"), 71 | package = "rcompendium"), path)) 72 | 73 | 74 | if (!quiet) 75 | ui_done("Writing {ui_value('.github/workflows/pkgdown.yaml')} file") 76 | 77 | 78 | ## Write (Empty) Custom Config file --- 79 | 80 | if (!file.exists(file.path(path_proj(), "_pkgdown.yaml"))) { 81 | file.create(file.path(path_proj(), "_pkgdown.yaml")) 82 | add_to_buildignore("_pkgdown.yaml", quiet = quiet) 83 | } 84 | 85 | 86 | if (open) edit_file(path) 87 | 88 | invisible(NULL) 89 | } 90 | -------------------------------------------------------------------------------- /R/add_github_actions_pkgdown_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a Website badge 2 | #' 3 | #' @description 4 | #' This function adds a **Website** badge to the `README.Rmd`. This function 5 | #' must be run after [add_github_actions_pkgdown()] which will setup 6 | #' GitHub Actions to build and deploy the package website. 7 | #' 8 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 9 | #' contains a block starting with the line `` and ending 10 | #' with the line ``. 11 | #' 12 | #' Don't forget to re-render the `README.md`. 13 | #' 14 | #' @param organisation A character of length 1. The name of the GitHub 15 | #' organisation to host the package. If `NULL` (default) the GitHub account 16 | #' will be used. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @return A badge as a markdown expression. 22 | #' 23 | #' @export 24 | #' 25 | #' @family adding badges 26 | #' 27 | #' @examples 28 | #' \dontrun{ 29 | #' add_github_actions_pkgdown_badge() 30 | #' } 31 | 32 | add_github_actions_pkgdown_badge <- function(organisation = NULL, 33 | quiet = FALSE) { 34 | 35 | 36 | stop_if_not_logical(quiet) 37 | 38 | ## Check if GH Actions are set ---- 39 | 40 | if (!file.exists(file.path(path_proj(), ".github", "workflows", 41 | "pkgdown.yaml"))) { 42 | stop("Please run `add_github_actions_pkgdown()` to setup GitHub Actions.") 43 | } 44 | 45 | 46 | ## Retrieve GitHub pseudo/organization ---- 47 | 48 | if (!is.null(organisation)) { 49 | 50 | github <- organisation 51 | 52 | } else { 53 | 54 | github <- gh::gh_whoami()$"login" 55 | 56 | if (is.null(github)) { 57 | stop("Unable to find GitHub username. Please run ", 58 | "`?gert::git_config_global` for more information.") 59 | } 60 | } 61 | 62 | stop_if_not_string(github) 63 | 64 | 65 | ## Check URL ---- 66 | 67 | is_gh_user() 68 | 69 | project_name <- get_package_name() 70 | 71 | 72 | ## Create Badge Markdown Expression ---- 73 | 74 | alt <- "Website" 75 | href <- paste("https://github.com", github, project_name, 76 | "actions/workflows/pkgdown.yaml", sep = "/") 77 | img <- paste("https://github.com", github, project_name, 78 | "actions/workflows/pkgdown.yaml/badge.svg", sep = "/") 79 | 80 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 81 | 82 | 83 | ## Add Badge ---- 84 | 85 | add_badge(badge, pattern = alt) 86 | 87 | if (!quiet) { 88 | ui_done(paste0("Adding {ui_field('Website deployment')} badge to ", 89 | "{ui_value('README.Rmd')}")) 90 | } 91 | 92 | 93 | invisible(badge) 94 | } 95 | -------------------------------------------------------------------------------- /R/add_github_actions_render.R: -------------------------------------------------------------------------------- 1 | #' Setup GitHub Actions to render README 2 | #' 3 | #' @description 4 | #' This function creates a configuration file (`.yaml`) to setup GitHub Actions 5 | #' to automatically knit the `README.Rmd` after a push. This workflow will be 6 | #' triggered only if the `README.Rmd` has been modified since the last commit. 7 | #' This workflow is derived 8 | #' from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 9 | #' This file will be written as `.github/workflows/render-README.yaml`. 10 | #' 11 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 12 | #' editor. 13 | #' 14 | #' @param overwrite A logical value. If this file is already present and 15 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 16 | #' 17 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 18 | #' `FALSE`. 19 | #' 20 | #' @return No return value. 21 | #' 22 | #' @export 23 | #' 24 | #' @family development functions 25 | #' 26 | #' @examples 27 | #' \dontrun{ 28 | #' add_github_actions_render() 29 | #' } 30 | 31 | add_github_actions_render <- function(open = FALSE, overwrite = FALSE, 32 | quiet = FALSE) { 33 | 34 | 35 | stop_if_not_logical(open, overwrite, quiet) 36 | 37 | if (!dir.exists(file.path(path_proj(), ".git"))) { 38 | stop("The project is not versioning with git.") 39 | } 40 | 41 | 42 | path <- file.path(path_proj(), ".github", "workflows", "render-README.yaml") 43 | 44 | 45 | ## Do not replace current file but open it if required ---- 46 | 47 | if (file.exists(path) && !overwrite) { 48 | 49 | if (!open) { 50 | 51 | stop("An '.github/workflows/render-README.yaml' file is already present.", 52 | " If you want to replace it, please use `overwrite = TRUE`.") 53 | 54 | } else { 55 | 56 | edit_file(path) 57 | return(invisible(NULL)) 58 | } 59 | } 60 | 61 | 62 | ## Copy Template ---- 63 | 64 | dir.create(file.path(path_proj(), ".github", "workflows"), 65 | showWarnings = FALSE, recursive = TRUE) 66 | 67 | add_to_buildignore(".github", quiet = FALSE) 68 | 69 | invisible( 70 | file.copy(system.file(file.path("templates", "render-README.yaml"), 71 | package = "rcompendium"), path)) 72 | 73 | 74 | if (!quiet) 75 | ui_done("Writing {ui_value('.github/workflows/render-README.yaml')} file") 76 | 77 | if (open) edit_file(path) 78 | 79 | invisible(NULL) 80 | } 81 | -------------------------------------------------------------------------------- /R/add_license_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a License badge 2 | #' 3 | #' @description 4 | #' This function adds or updates the **License** badge to the `README.Rmd`. 5 | #' This function reads the `License` field of the `DESCRIPTION` file. Ensure 6 | #' that this field is correctly defined. See [add_license()] for further detail. 7 | #' 8 | #' This function requires the presence of a `DESCRIPTION` file at the project 9 | #' root. See [add_description()] for further detail. 10 | #' 11 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 12 | #' contains a block starting with the line `` and ending 13 | #' with the line ``. 14 | #' 15 | #' Don't forget to re-render the `README.md`. 16 | #' 17 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 18 | #' `FALSE`. 19 | #' 20 | #' @return A badge as a markdown expression. 21 | #' 22 | #' @export 23 | #' 24 | #' @family adding badges 25 | #' 26 | #' @examples 27 | #' \dontrun{ 28 | #' add_license_badge() 29 | #' } 30 | 31 | add_license_badge <- function(quiet = FALSE) { 32 | 33 | 34 | ## Checks ---- 35 | 36 | stop_if_not_logical(quiet) 37 | 38 | user_license <- read_descr()$"License" 39 | user_license <- gsub(" \\+ file LICENSE", "", user_license) 40 | 41 | 42 | if (!is.null(user_license)) { 43 | 44 | if (user_license %in% licenses$"tag") { 45 | 46 | 47 | ## Create Badge Markdown Expression ---- 48 | 49 | color <- licenses[which(licenses$tag == user_license), "color"] 50 | 51 | user_license_encoded <- gsub("-", " v", user_license) 52 | user_license_encoded <- gsub("\\s", "%20", user_license_encoded) 53 | user_license_encoded <- gsub("\\(", "%28", user_license_encoded) 54 | user_license_encoded <- gsub("\\)", "%29", user_license_encoded) 55 | user_license_encoded <- gsub(">", "%3E", user_license_encoded) 56 | user_license_encoded <- gsub("=", "%3D", user_license_encoded) 57 | 58 | alt <- paste0("License: ", user_license) 59 | href <- licenses[which(licenses$tag == user_license), "url"] 60 | img <- paste0("https://img.shields.io/badge/License-", 61 | user_license_encoded, "-", color, ".svg") 62 | 63 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 64 | 65 | 66 | ## Add Badge ---- 67 | 68 | add_badge(badge, pattern = "License") 69 | 70 | if (!quiet) { 71 | ui_done(paste0("Adding {ui_field('License')} badge to ", 72 | "{ui_value('README.Rmd')}")) 73 | } 74 | 75 | } else { 76 | 77 | ui_oops("Unknow {ui_field('License')} type in {ui_value('DESCRIPTION')}") 78 | ui_todo("See {ui_code('?add_license()')} for further information") 79 | } 80 | 81 | } else { 82 | 83 | ui_oops("No {ui_field('License')} field in {ui_value('DESCRIPTION')}") 84 | ui_todo("See {ui_code('?add_license()')} for further information") 85 | } 86 | 87 | invisible(badge) 88 | } 89 | -------------------------------------------------------------------------------- /R/add_lifecycle_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a Life Cycle badge 2 | #' 3 | #' @description 4 | #' This function adds or updates the **Life Cycle** badge to the `README.Rmd`. 5 | #' It is based on the standard defined at 6 | #' \url{https://lifecycle.r-lib.org/articles/stages.html}. 7 | #' 8 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 9 | #' contains a block starting with the line `` and ending 10 | #' with the line ``. 11 | #' 12 | #' Don't forget to re-render the `README.md`. 13 | #' 14 | #' @param lifecycle A character of length 1. Accepted stages are: 15 | #' `'experimental'` (default), `'stable'`, `'deprecated'`, or `'superseded'`. 16 | #' 17 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 18 | #' `FALSE`. 19 | #' 20 | #' @details 21 | #' The project can have the following life cycle stage: 22 | #' \itemize{ 23 | #' \item **Experimental** - An experimental project is made available so user 24 | #' can try it out and provide feedback, but come with no promises for long 25 | #' term stability. 26 | #' \item **Stable** - A project is considered stable when the author is happy 27 | #' with its interface, does not see major issues, and is happy to share it 28 | #' with the world. 29 | #' \item **Superseded** - A superseded project has a known better 30 | #' alternative, and it is not going away. Superseded project will not receive 31 | #' new features, but will receive any critical bug fixes needed to keep it 32 | #' working. 33 | #' \item **Deprecated** - A deprecated project has a better alternative 34 | #' available and is scheduled for removal. 35 | #' } 36 | #' 37 | #' @return A badge as a markdown expression. 38 | #' 39 | #' @export 40 | #' 41 | #' @family adding badges 42 | #' 43 | #' @examples 44 | #' \dontrun{ 45 | #' add_lifecycle_badge() 46 | #' add_lifecycle_badge(lifecycle = "stable") 47 | #' } 48 | 49 | add_lifecycle_badge <- function(lifecycle = "experimental", quiet = FALSE) { 50 | 51 | 52 | ## Checks ---- 53 | 54 | stop_if_not_logical(quiet) 55 | 56 | stop_if_not_string(lifecycle) 57 | 58 | if (!(tolower(lifecycle) %in% c("experimental", "stable", "deprecated", 59 | "superseded"))) { 60 | stop("Argument 'lifecycle' must be of among 'experimental', 'stable', ", 61 | "'deprecated', or 'superseded'.") 62 | } 63 | 64 | 65 | if (!file.exists(file.path(path_proj(), "README.Rmd"))) { 66 | stop("The file 'README.Rmd' cannot be found.") 67 | } 68 | 69 | 70 | ## Create Badge Markdown Expression ---- 71 | 72 | color <- switch(lifecycle, 73 | `stable` = "green", 74 | `experimental` = "orange", 75 | `deprecated` = "orange", 76 | `superseded` = "blue") 77 | 78 | alt <- "LifeCycle" 79 | 80 | href <- paste0("https://lifecycle.r-lib.org/articles/stages.html#", 81 | lifecycle) 82 | 83 | img <- paste0("https://img.shields.io/badge/lifecycle-", lifecycle, "-", 84 | color) 85 | 86 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 87 | 88 | 89 | ## Add Badge ---- 90 | 91 | add_badge(badge, pattern = alt) 92 | 93 | 94 | if (!quiet) { 95 | ui_done(paste0("Adding {ui_field('Lifecycle')} badge to ", 96 | "{ui_value('README.Rmd')}")) 97 | } 98 | 99 | invisible(badge) 100 | } 101 | -------------------------------------------------------------------------------- /R/add_makefile.R: -------------------------------------------------------------------------------- 1 | #' Create a Make-like R file 2 | #' 3 | #' @description 4 | #' This function creates a Make-like R file (`make.R`) at the root of the 5 | #' project based on a template. To be used only if the project is a research 6 | #' compendium. The content of this file provides some guidelines. See also 7 | #' [new_compendium()] for further information. 8 | #' 9 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 10 | #' editor. 11 | #' 12 | #' @param overwrite A logical value. If this file is already present and 13 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 14 | #' 15 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 16 | #' `FALSE`. 17 | #' 18 | #' @inheritParams set_credentials 19 | #' 20 | #' @return No return value. 21 | #' 22 | #' @export 23 | #' 24 | #' @family create files 25 | #' 26 | #' @examples 27 | #' \dontrun{ 28 | #' add_makefile() 29 | #' } 30 | 31 | add_makefile <- function(given = NULL, family = NULL, email = NULL, 32 | open = TRUE, overwrite = FALSE, quiet = FALSE) { 33 | 34 | 35 | stop_if_not_logical(open, overwrite, quiet) 36 | 37 | path <- file.path(path_proj(), "make.R") 38 | 39 | 40 | ## Do not replace current file but open it if required ---- 41 | 42 | if (file.exists(path) && !overwrite) { 43 | 44 | if (!open) { 45 | 46 | stop("A 'make.R' file is already present. If you want to ", 47 | "replace it, please use `overwrite = TRUE`.") 48 | 49 | } else { 50 | 51 | edit_file(path) 52 | return(invisible(NULL)) 53 | } 54 | } 55 | 56 | 57 | ## Get fields values ---- 58 | 59 | if (is.null(given)) given <- getOption("given") 60 | if (is.null(family)) family <- getOption("family") 61 | if (is.null(email)) email <- getOption("email") 62 | 63 | stop_if_not_string(given, family, email) 64 | 65 | 66 | project_name <- get_package_name() 67 | today <- format(Sys.time(), "%Y/%m/%d") 68 | 69 | 70 | ## Copy Template ---- 71 | 72 | invisible( 73 | file.copy(system.file(file.path("templates", "make.R"), 74 | package = "rcompendium"), path, overwrite = TRUE)) 75 | 76 | 77 | ## Update default values ---- 78 | 79 | 80 | xfun::gsub_file(path, "{{date}}", today, fixed = TRUE) 81 | xfun::gsub_file(path, "{{project_name}}", project_name, fixed = TRUE) 82 | xfun::gsub_file(path, "{{given}}", given, fixed = TRUE) 83 | xfun::gsub_file(path, "{{family}}", family, fixed = TRUE) 84 | xfun::gsub_file(path, "{{email}}", email, fixed = TRUE) 85 | 86 | 87 | ## Message ---- 88 | 89 | if (!quiet) ui_done("Writing {ui_value('make.R')} file") 90 | 91 | add_to_buildignore("make.R", quiet = quiet) 92 | 93 | if (open) edit_file(path) 94 | 95 | invisible(NULL) 96 | } 97 | -------------------------------------------------------------------------------- /R/add_package_doc.R: -------------------------------------------------------------------------------- 1 | #' Create a package-level documentation file 2 | #' 3 | #' @description 4 | #' This function adds a package-level documentation file (`pkg-package.R`) in 5 | #' the `R/` folder. This file will make help available to the user via `?pkg` 6 | #' (where `pkg` is the name of the package). It a good place to put general 7 | #' directives like `@import` and `@importFrom`. 8 | #' 9 | #' @param open A logical value. If `TRUE` (default) the file is opened in the 10 | #' editor. 11 | #' 12 | #' @param overwrite A logical value. If this file is already present and 13 | #' `overwrite = TRUE`, it will be erased and replaced. Default is `FALSE`. 14 | #' 15 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 16 | #' `FALSE`. 17 | #' 18 | #' @return No return value. 19 | #' 20 | #' @export 21 | #' 22 | #' @family create files 23 | #' 24 | #' @examples 25 | #' \dontrun{ 26 | #' add_package_doc() 27 | #' } 28 | 29 | add_package_doc <- function(open = TRUE, overwrite = FALSE, quiet = FALSE) { 30 | 31 | 32 | stop_if_not_logical(open, overwrite, quiet) 33 | 34 | filename <- paste0(get_package_name(), "-package.R") 35 | path <- file.path(path_proj(), "R", filename) 36 | 37 | 38 | ## Do not replace current file but open it if required ---- 39 | 40 | if (file.exists(path) && !overwrite) { 41 | 42 | if (!open) { 43 | 44 | stop("A 'R/", filename, "' file is already present. If you want to ", 45 | "replace it, please use `overwrite = TRUE`.") 46 | 47 | } else { 48 | 49 | edit_file(path) 50 | return(invisible(NULL)) 51 | } 52 | } 53 | 54 | 55 | if (!dir.exists(file.path(path_proj(), "R"))) 56 | dir.create(file.path(path_proj(), "R"), showWarnings = FALSE) 57 | 58 | invisible( 59 | file.copy(system.file(file.path("templates", "package-package.R"), 60 | package = "rcompendium"), path, overwrite = TRUE)) 61 | 62 | 63 | if (!quiet) ui_done("Writing {ui_value(paste0('R/', filename))} file") 64 | 65 | if (open) edit_file(path) 66 | 67 | invisible(NULL) 68 | } 69 | -------------------------------------------------------------------------------- /R/add_r_depend.R: -------------------------------------------------------------------------------- 1 | #' Add minimal R version to DESCRIPTION 2 | #' 3 | #' @description 4 | #' This function adds the minimal R version to the `Depends` field of the 5 | #' `DESCRIPTION` file. This version corresponds to the higher version of R 6 | #' among all dependencies. If no dependencies mentions minimal R version, the 7 | #' `DESCRIPTION` is not modified. 8 | #' 9 | #' @return No return value. 10 | #' 11 | #' @export 12 | #' 13 | #' @family development functions 14 | #' 15 | #' @examples 16 | #' \dontrun{ 17 | #' add_r_depend() 18 | #' } 19 | 20 | add_r_depend <- function() { 21 | 22 | r_version <- get_minimal_r_version() 23 | 24 | if (!is.null(r_version)) { 25 | 26 | r_version <- paste0("R (>= ", r_version, ")") 27 | 28 | descr <- read_descr() 29 | 30 | if (is.null(descr$"Depends")) { # No Depends field 31 | 32 | descr$"Depends" <- r_version 33 | 34 | } else { 35 | 36 | depends <- unlist(strsplit(descr$"Depends", "\n\\s+|,|,\\s+")) 37 | 38 | is_r <- grep("R \\(.*\\)", depends) 39 | 40 | if (length(is_r)) { # No R version mentioned 41 | 42 | depends[is_r] <- r_version 43 | 44 | } else { # R version mentioned 45 | 46 | depends <- c(r_version, depends) 47 | } 48 | 49 | descr$"Depends" <- paste0(depends, collapse = ", ") 50 | } 51 | 52 | write_descr(descr) 53 | ui_done(paste0("Adding the following line to {ui_value('DESCRIPTION')}: ", 54 | "{ui_code(paste('Depends:', r_version))}")) 55 | 56 | } else { 57 | 58 | ui_done(paste0("No minimal R version detected")) 59 | } 60 | 61 | invisible(NULL) 62 | } 63 | -------------------------------------------------------------------------------- /R/add_renv.R: -------------------------------------------------------------------------------- 1 | #' Initialize renv 2 | #' 3 | #' @description 4 | #' This function initializes an `renv` environment for the project by running 5 | #' [renv::init()]. See \url{https://rstudio.github.io/renv/} for further detail. 6 | #' 7 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 8 | #' `FALSE`. 9 | #' 10 | #' @return No return value. 11 | #' 12 | #' @export 13 | #' 14 | #' @family create files 15 | #' 16 | #' @examples 17 | #' \dontrun{ 18 | #' add_renv() 19 | #' } 20 | 21 | add_renv <- function(quiet = FALSE) { 22 | 23 | stop_if_not_logical(quiet) 24 | 25 | if (!file.exists(file.path(path_proj(), "renv.lock"))) { 26 | 27 | 28 | ## Disable renv messages ---- 29 | 30 | renv_verbose <- options()$"renv.verbose" 31 | on.exit(options("renv.verbose" = renv_verbose)) 32 | options("renv.verbose" = FALSE) 33 | 34 | 35 | ## Init renv ---- 36 | 37 | renv::init(bare = FALSE, restart = FALSE) 38 | 39 | if (!quiet) { 40 | 41 | ui_done("Creating {ui_value('renv/')}") 42 | ui_done("Writing {ui_value('.Rprofile')}") 43 | ui_done("Writing {ui_value('renv.lock')}") 44 | cli::cat_line() 45 | ui_todo("Call {ui_code('renv::install()')} to install packages") 46 | ui_todo("Call {ui_code('renv::snapshot()')} to update the lockfile") 47 | } 48 | 49 | 50 | ## Add renv files to .Rbuildignore ---- 51 | 52 | add_to_buildignore("renv/") 53 | add_to_buildignore(".Rprofile") 54 | add_to_buildignore("renv.lock") 55 | 56 | 57 | ## Add renv files to .Rbuildignore ---- 58 | 59 | add_to_gitignore("renv/") 60 | add_to_gitignore(".Rprofile") 61 | 62 | 63 | ## Add renv to Import tag in DESCRIPTION ---- 64 | 65 | descr <- read_descr() 66 | 67 | deps <- c(get_deps_in_depends(), read_descr()$"Imports", 68 | read_descr()$"Suggests", read_descr()$"LinkingTo") 69 | 70 | deps_to_add <- c("renv") 71 | 72 | if (!is.null(deps)) { 73 | 74 | deps <- unlist(strsplit(deps, "\n\\s+|,|,\\s+")) 75 | deps <- deps[!(deps == "")] 76 | deps_to_add <- deps_to_add[!(deps_to_add %in% deps)] 77 | } 78 | 79 | 80 | if (length(deps_to_add)) { 81 | 82 | if (!is.null(descr$"Imports")) { 83 | 84 | deps_in_imports <- unlist(strsplit(descr$"Imports", "\n\\s+|,|,\\s+")) 85 | deps_in_imports <- deps_in_imports[!(deps_in_imports == "")] 86 | 87 | } else { 88 | 89 | deps_in_imports <- character(0) 90 | } 91 | 92 | deps_in_imports <- sort(unique(c(deps_in_imports, deps_to_add))) 93 | deps_in_imports <- paste0(deps_in_imports, collapse = ",\n ") 94 | 95 | descr$"Imports" <- paste0("\n ", deps_in_imports) 96 | 97 | if (!quiet) { 98 | msg <- paste0("Imports: ", gsub(",\n ", ", ", deps_in_imports)) 99 | ui_done(paste0("Adding the following line in ", 100 | "{ui_value('DESCRIPTION')}: {ui_code(msg)}")) 101 | } 102 | } 103 | 104 | write_descr(descr) 105 | 106 | 107 | ## Update makefile ---- 108 | 109 | path <- file.path(path_proj(), "make.R") 110 | 111 | if (file.exists(path)) { 112 | 113 | xfun::gsub_file(path, "devtools::install_deps(upgrade = \"never\")", 114 | "renv::restore()", fixed = TRUE) 115 | } 116 | } 117 | 118 | invisible(NULL) 119 | } 120 | -------------------------------------------------------------------------------- /R/add_repostatus_badge.R: -------------------------------------------------------------------------------- 1 | #' Add a Repository Status badge 2 | #' 3 | #' @description 4 | #' This function adds or updates the **Repository Status** badge of the project 5 | #' to the `README.Rmd`. It is based on the standard defined by the 6 | #' \url{https://www.repostatus.org} project. 7 | #' 8 | #' Make sure that 1) a `README.Rmd` file exists at the project root and 2) it 9 | #' contains a block starting with the line `` and ending 10 | #' with the line ``. 11 | #' 12 | #' Don't forget to re-render the `README.md`. 13 | #' 14 | #' @param status A character of length 1. Accepted status are: `'concept'` 15 | #' (default), `'wip'`, `'suspended'`, `'abandoned'`, `'active'`, 16 | #' `'inactive'`, or `'unsupported'`. 17 | #' 18 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 19 | #' `FALSE`. 20 | #' 21 | #' @details 22 | #' The project can have the following status: 23 | #' \itemize{ 24 | #' \item **Concept** - Minimal or no implementation has been done yet, or the 25 | #' repository is only intended to be a limited example, demo, or 26 | #' proof-of-concept. 27 | #' \item **WIP** - Initial development is in progress, but there has not yet 28 | #' been a stable, usable release suitable for the public. 29 | #' \item **Suspended** - Initial development has started, but there has not 30 | #' yet been a stable, usable release; work has been stopped for the time 31 | #' being but the author(s) intend on resuming work. 32 | #' \item **Abandoned** - Initial development has started, but there has not 33 | #' yet been a stable, usable release; the project has been abandoned and the 34 | #' author(s) do not intend on continuing development. 35 | #' \item **Active** - The project has reached a stable, usable state and is 36 | #' being actively developed. 37 | #' \item **Inactive** - The project has reached a stable, usable state but is 38 | #' no longer being actively developed; support/maintenance will be provided 39 | #' as time allows. 40 | #' \item **Unsupported** - The project has reached a stable, usable state but 41 | #' the author(s) have ceased all work on it. A new maintainer may be desired. 42 | #' } 43 | #' 44 | #' @return A badge as a markdown expression. 45 | #' 46 | #' @export 47 | #' 48 | #' @family adding badges 49 | #' 50 | #' @examples 51 | #' \dontrun{ 52 | #' add_repostatus_badge() 53 | #' add_repostatus_badge(status = "active") 54 | #' } 55 | 56 | add_repostatus_badge <- function(status = "concept", quiet = FALSE) { 57 | 58 | 59 | ## Checks ---- 60 | 61 | stop_if_not_logical(quiet) 62 | 63 | stop_if_not_string(status) 64 | 65 | if (!(tolower(status) %in% c("concept", "wip", "suspended", "abandoned", 66 | "active", "inactive", "unsupported"))) { 67 | 68 | stop("Argument 'status' must be of among 'concept', 'wip', 'suspended', ", 69 | "'abandoned', 'active', 'inactive', or 'unsupported'.") 70 | } 71 | 72 | if (!file.exists(file.path(path_proj(), "README.Rmd"))) { 73 | stop("The file 'README.Rmd' cannot be found.") 74 | } 75 | 76 | 77 | ## Create Badge Markdown Expression ---- 78 | 79 | status <- paste0( 80 | toupper(substr(status, 1, 1)), 81 | tolower(substr(status, 2, nchar(status)))) 82 | 83 | status <- ifelse(status == "Wip", "WIP", status) 84 | 85 | alt <- paste0("Project Status: ", 86 | status) 87 | href <- paste0("https://www.repostatus.org/#", 88 | tolower(status)) 89 | img <- paste0("https://www.repostatus.org/badges/latest/", 90 | tolower(status), ".svg") 91 | 92 | badge <- paste0("[![", alt, "](", img, ")](", href, ")") 93 | 94 | 95 | ## Add Badge ---- 96 | 97 | add_badge(badge, pattern = "Project Status") 98 | 99 | 100 | if (!quiet) { 101 | ui_done(paste0("Adding {ui_field('Repo Status')} badge to ", 102 | "{ui_value('README.Rmd')}")) 103 | } 104 | 105 | invisible(badge) 106 | } 107 | -------------------------------------------------------------------------------- /R/add_testthat.R: -------------------------------------------------------------------------------- 1 | #' Initialize units tests 2 | #' 3 | #' @description 4 | #' This function initializes units tests settings by running 5 | #' [usethis::use_testthat()] and by adding an example units tests file 6 | #' `tests/testthat/test-demo.R`. The sample file will test a demo function 7 | #' created in `R/fun-demo.R`. 8 | #' 9 | #' @return No return value. 10 | #' 11 | #' @export 12 | #' 13 | #' @family create files 14 | #' 15 | #' @examples 16 | #' \dontrun{ 17 | #' add_testthat() 18 | #' } 19 | 20 | add_testthat <- function() { 21 | 22 | if (!file.exists(file.path(path_proj(), "tests", "testthat.R"))) { 23 | 24 | usethis::use_testthat() 25 | 26 | path <- file.path(path_proj(), "tests", "testthat", "test-demo.R") 27 | 28 | if (!file.exists(path)) { 29 | 30 | invisible( 31 | file.copy(system.file(file.path("templates", "test-demo.R"), 32 | package = "rcompendium"), path, 33 | overwrite = TRUE)) 34 | } 35 | } 36 | 37 | invisible(NULL) 38 | } 39 | -------------------------------------------------------------------------------- /R/add_to_buildignore.R: -------------------------------------------------------------------------------- 1 | #' Add to the .Rbuildignore file 2 | #' 3 | #' @description 4 | #' This function adds files/folders to the `.Rbuildignore` file. If a 5 | #' `.Rbuildignore` is already present, files to be ignored while checking 6 | #' package are just added to this file. Otherwise a new file is created. 7 | #' 8 | #' @param x A character vector. One or several files/folders names to be added 9 | #' to the `.Rbuildignore`. This argument is mandatory. 10 | #' 11 | #' @param open A logical value. If `TRUE` the `.Rbuildignore` file is opened in 12 | #' the editor. Default is `FALSE`. 13 | #' 14 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 15 | #' `FALSE`. 16 | #' 17 | #' @return No return value. 18 | #' 19 | #' @export 20 | #' 21 | #' @family development functions 22 | #' 23 | #' @examples 24 | #' \dontrun{ 25 | #' add_to_buildignore(open = TRUE) 26 | #' add_to_buildignore(".DS_Store") 27 | #' } 28 | 29 | add_to_buildignore <- function(x, open = FALSE, quiet = FALSE) { 30 | 31 | 32 | if (missing(x) && !open) stop("Argument 'x' is missing.") 33 | 34 | stop_if_not_logical(open, quiet) 35 | 36 | 37 | path <- file.path(path_proj(), ".Rbuildignore") 38 | 39 | 40 | ## Create new file (if missing) ---- 41 | 42 | if (!file.exists(path)) { 43 | 44 | invisible(file.create(path)) 45 | 46 | if (!quiet) ui_done("Writing {ui_value('.Rbuildignore')} file") 47 | } 48 | 49 | 50 | ## Add file/folder ---- 51 | 52 | if (!missing(x)) { 53 | 54 | stopifnot(is.character(x)) 55 | 56 | 57 | ## Escape files ---- 58 | 59 | x <- gsub("\\.", "\\\\.", x) 60 | x <- gsub("/$", "", x) 61 | x <- paste0("^", x, "$") 62 | 63 | 64 | ## Add files/folders to .Rbuildignore ---- 65 | 66 | build_ignore <- readLines(path) 67 | 68 | x <- x[!(x %in% build_ignore)] 69 | 70 | if (length(x)) { 71 | 72 | build_ignore <- c(build_ignore, x) 73 | 74 | writeLines(build_ignore, con = path) 75 | 76 | if (!quiet) 77 | ui_done(paste0("Adding {ui_value(paste0(x, collapse = ", "))} to ", 78 | "{ui_value('.Rbuildignore')}")) 79 | } 80 | } 81 | 82 | if (open) edit_file(path) 83 | 84 | invisible(NULL) 85 | } 86 | -------------------------------------------------------------------------------- /R/add_to_gitignore.R: -------------------------------------------------------------------------------- 1 | #' Add to the .gitignore file 2 | #' 3 | #' @description 4 | #' This function creates a `.gitignore` file at the root of the project based on 5 | #' a template (specific to R). If a `.gitignore` is already present, files to 6 | #' be untracked by **git** are just added to this file. 7 | #' 8 | #' @param x A character vector. One or several files/folders names to be added 9 | #' to the `.gitignore`. 10 | #' 11 | #' @param open A logical value. If `TRUE` the `.gitignore` file is opened in 12 | #' the editor. Default is `FALSE`. 13 | #' 14 | #' @param quiet A logical value. If `TRUE` messages are deleted. Default is 15 | #' `FALSE`. 16 | #' 17 | #' @return No return value. 18 | #' 19 | #' @export 20 | #' 21 | #' @family development functions 22 | #' 23 | #' @examples 24 | #' \dontrun{ 25 | #' add_to_gitignore(open = TRUE) 26 | #' add_to_gitignore(".DS_Store") 27 | #' } 28 | 29 | add_to_gitignore <- function(x, open = FALSE, quiet = FALSE) { 30 | 31 | 32 | stop_if_not_logical(open, quiet) 33 | 34 | path <- file.path(path_proj(), ".gitignore") 35 | 36 | 37 | ## Copy Template ---- 38 | 39 | if (!file.exists(path)) { 40 | 41 | invisible( 42 | file.copy(system.file(file.path("templates", "gitignore"), 43 | package = "rcompendium"), path)) 44 | 45 | if (!quiet) ui_done("Writing {ui_value('.gitignore')} file") 46 | } 47 | 48 | 49 | ## Add files/folders to .gitignore ---- 50 | 51 | if (!missing(x)) { 52 | 53 | stopifnot(is.character(x)) 54 | 55 | git_ignore <- readLines(path) 56 | 57 | x <- x[!(x %in% git_ignore)] 58 | 59 | if (length(x)) { 60 | 61 | git_ignore <- c(git_ignore, x) 62 | 63 | writeLines(git_ignore, con = path) 64 | 65 | if (!quiet) 66 | ui_done(paste0("Adding {ui_value(paste0(x, collapse = ", "))} to ", 67 | "{ui_value('.gitignore')}")) 68 | } 69 | } 70 | 71 | if (open) edit_file(path) 72 | 73 | invisible(NULL) 74 | } 75 | -------------------------------------------------------------------------------- /R/get_all_dependencies.R: -------------------------------------------------------------------------------- 1 | #' Get all external dependencies 2 | #' 3 | #' @description 4 | #' This function gets all the external packages that the project needs. It is 5 | #' used the generate the _Dependencies_ badge ([add_dependencies_badge()]). 6 | #' 7 | #' @param pkg A character of length 1. The name of a CRAN package or `NULL` 8 | #' (default). If `NULL` get dependencies of the local (uninstalled) project 9 | #' (package or compendium). 10 | #' 11 | #' @return A list of three vectors: 12 | #' * `base_deps`, a vector of base packages; 13 | #' * `direct_deps`, a vector of direct packages; 14 | #' * `all_deps`, a vector of all dependencies (recursively obtained). 15 | #' 16 | #' @export 17 | #' 18 | #' @family utilities functions 19 | #' 20 | #' @examples 21 | #' \dontrun{ 22 | #' ## Update dependencies ---- 23 | #' add_dependencies() 24 | #' 25 | #' ## Get all dependencies ---- 26 | #' deps <- get_all_dependencies() 27 | #' unlist(lapply(deps, length)) 28 | #' 29 | #' ## Can be used for a CRAN package ---- 30 | #' deps <- get_all_dependencies("usethis") 31 | #' unlist(lapply(deps, length)) 32 | #' } 33 | 34 | get_all_dependencies <- function(pkg = NULL) { 35 | 36 | if (is.null(pkg)) { 37 | 38 | ## Dev package ---- 39 | 40 | direct_deps <- c(get_deps_in_depends(), read_descr()$"Imports", 41 | read_descr()$"LinkingTo") 42 | 43 | if (!is.null(direct_deps)) { 44 | 45 | direct_deps <- unlist(strsplit(direct_deps, "\n\\s+|,|,\\s+")) 46 | direct_deps <- direct_deps[!(direct_deps == "")] 47 | 48 | pkg <- direct_deps 49 | 50 | } else { 51 | 52 | return(list("base_deps" = character(0), 53 | "direct_deps" = character(0), 54 | "all_deps" = character(0))) 55 | } 56 | 57 | } else { 58 | 59 | ## CRAN package ---- 60 | 61 | if (length(pkg) > 1) stop("Argument `pkg` must be of length 1 or `NULL`.") 62 | 63 | deps <- utils::available.packages() 64 | deps <- deps[deps[ , "Package"] %in% pkg, ] 65 | 66 | deps <- deps[c("Depends", "Imports", "LinkingTo")] 67 | 68 | deps_depends <- unlist(strsplit(deps["Depends"], ", ")) 69 | deps_depends <- deps_depends[!grep("^R\\s\\(", deps_depends)] 70 | deps_imports <- unlist(strsplit(deps["Imports"], ", ")) 71 | deps_linkingto <- unlist(strsplit(deps["LinkingTo"], ", ")) 72 | 73 | direct_deps <- c(deps_depends, deps_imports, deps_linkingto) 74 | direct_deps <- direct_deps[!is.na(direct_deps)] 75 | direct_deps <- gsub("\\s\\(.+\\)|\\n", "", direct_deps) 76 | 77 | direct_deps <- unlist(strsplit(direct_deps, ",")) 78 | } 79 | 80 | 81 | ## List of base packages ---- 82 | 83 | base_deps <- c("base", "compiler", "datasets", "graphics", "grDevices", 84 | "grid", "methods", "parallel", "splines", "stats", "stats4", 85 | "tcltk", "tools", "utils") 86 | 87 | 88 | ## List of all dependencies (on which pkg depends) ---- 89 | 90 | all_deps <- gtools::getDependencies(pkg, installed = FALSE, 91 | available = FALSE, base = FALSE) 92 | all_deps <- gsub("\\s\\(.+\\)", "", all_deps) 93 | names(all_deps) <- NULL 94 | 95 | basic_deps <- direct_deps[direct_deps %in% base_deps] 96 | names(basic_deps) <- NULL 97 | 98 | direct_deps <- direct_deps[!(direct_deps %in% base_deps)] 99 | names(direct_deps) <- NULL 100 | 101 | list("base_deps" = sort(unique(basic_deps)), 102 | "direct_deps" = sort(unique(direct_deps)), 103 | "all_deps" = sort(unique(all_deps))) 104 | } 105 | -------------------------------------------------------------------------------- /R/get_all_functions.R: -------------------------------------------------------------------------------- 1 | #' List all functions in the package 2 | #' 3 | #' @description 4 | #' This function returns a list of all the functions (exported and internal) 5 | #' available with the package. As this function scans the `NAMESPACE` and the 6 | #' `R/` folder, it is recommended to run [devtools::document()] before. 7 | #' 8 | #' @return A list of two vectors: 9 | #' * `external`, a vector of exported functions name; 10 | #' * `internal`, a vector of internal functions name. 11 | #' 12 | #' @export 13 | #' 14 | #' @family utilities functions 15 | #' 16 | #' @examples 17 | #' \dontrun{ 18 | #' ## Update NAMESPACE ---- 19 | #' devtools::document() 20 | #' 21 | #' ## List all implemented functions ---- 22 | #' get_all_functions() 23 | #' } 24 | 25 | get_all_functions <- function() { 26 | 27 | if (!dir.exists(file.path(path_proj(), "R"))) { 28 | stop("The directory 'R/' cannot be found.") 29 | } 30 | 31 | 32 | x <- list.files(path = file.path(path_proj(), "R"), pattern = "\\.R$", 33 | full.names = TRUE, ignore.case = TRUE) 34 | 35 | 36 | if (!length(x)) { 37 | 38 | ui_oops("The {ui_value('R/')} folder is empty") 39 | 40 | return(NULL) 41 | 42 | } else { 43 | 44 | 45 | ## Read R files ---- 46 | 47 | x <- lapply(x, function(x) readLines(con = x, warn = FALSE)) 48 | 49 | 50 | ## Extract function names ---- 51 | 52 | x <- lapply(x, function(x) x[grep("\\s{0,}(<-|=)\\s{0,}function\\s{0,}\\(", 53 | x)]) 54 | x <- lapply(x, function(x) gsub("\\s{0,}(<-|=)\\s{0,}function.*", "", x)) 55 | 56 | x <- unlist(x) 57 | x <- gsub("\\s", "", x) 58 | x <- sort(unique(x)) 59 | 60 | 61 | if (length(x)) { 62 | 63 | if (file.exists(file.path(path_proj(), "NAMESPACE"))) { 64 | 65 | namespace <- readLines(con = file.path(path_proj(), "NAMESPACE"), 66 | warn = FALSE) 67 | 68 | exports <- gsub("export\\(|\\)", "", 69 | namespace[grep("^export", namespace)]) 70 | 71 | funs <- list("external" = character(0), "internal" = character(0)) 72 | 73 | if (length(exports)) { 74 | 75 | funs$"external" <- paste0(x[ (x %in% exports)], "()") 76 | funs$"internal" <- paste0(x[!(x %in% exports)], "()") 77 | 78 | } else { 79 | 80 | funs$"internal" <- paste0(x, "()") 81 | } 82 | 83 | } else { 84 | 85 | funs$"internal" <- paste0(x, "()") 86 | } 87 | 88 | return(funs) 89 | 90 | } else { 91 | 92 | return(NULL) 93 | } 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /R/get_licenses.R: -------------------------------------------------------------------------------- 1 | #' List all available licenses 2 | #' 3 | #' @description 4 | #' This function returns a list of all available licenses. This is particularly 5 | #' useful to get the right spelling of the license to be passed to 6 | #' [new_package()], [new_compendium()], or [add_license()]. 7 | #' 8 | #' @return A `data.frame` with the following two variables: 9 | #' * `tag`, the license name to be used with [add_license()]; 10 | #' * `url`, the URL of the license description. 11 | #' 12 | #' @export 13 | #' 14 | #' @family utilities functions 15 | #' 16 | #' @examples 17 | #' get_licenses() 18 | 19 | get_licenses <- function() licenses[ , c("tag", "url")] 20 | -------------------------------------------------------------------------------- /R/get_minimal_r_version.R: -------------------------------------------------------------------------------- 1 | #' Get required minimal R version 2 | #' 3 | #' @description 4 | #' This function detects the minimal required R version for the project based 5 | #' on minimal required R version of its dependencies. It can be used to update 6 | #' the `Depends` field of the `DESCRIPTION` file. 7 | #' 8 | #' @param pkg A character of length 1. The name of a CRAN package or `NULL` 9 | #' (default). If `NULL` get minimal required R version of the local 10 | #' (uninstalled) project (package or compendium). 11 | #' 12 | #' @return A character with the minimal required R version. 13 | #' 14 | #' @export 15 | #' 16 | #' @family utilities functions 17 | #' 18 | #' @examples 19 | #' \dontrun{ 20 | #' ## Update dependencies ---- 21 | #' add_dependencies() 22 | #' 23 | #' ## Minimal R version of a project ---- 24 | #' get_minimal_r_version() 25 | #' 26 | #' ## Minimal R version of a CRAN package ---- 27 | #' get_minimal_r_version("usethis") 28 | #' } 29 | 30 | get_minimal_r_version <- function(pkg = NULL) { 31 | 32 | if (is.null(pkg)) { 33 | 34 | ## Dev package ---- 35 | 36 | direct_deps <- c(get_deps_in_depends(), read_descr()$"Imports", 37 | read_descr()$"LinkingTo") 38 | 39 | direct_deps <- unlist(strsplit(direct_deps, "\n\\s+|,|,\\s+")) 40 | direct_deps <- direct_deps[!(direct_deps == "")] 41 | 42 | pkg <- direct_deps 43 | 44 | } else { 45 | 46 | ## CRAN package ---- 47 | 48 | if (length(pkg) > 1) stop("Argument `pkg` must be of length 1 or `NULL`.") 49 | 50 | } 51 | 52 | deps <- gtools::getDependencies(pkg, installed = FALSE, available = FALSE) 53 | 54 | if (length(deps)) { 55 | 56 | pkgs <- utils::available.packages() 57 | 58 | r_versions <- pkgs[pkgs[ , "Package"] %in% deps, "Depends"] 59 | r_versions <- unlist(stringr::str_extract_all(string = r_versions, 60 | pattern = "^R \\(.[^,]+\\)$")) 61 | r_versions <- gsub("R \\(|\\)|>|=|\\s", "", r_versions) 62 | r_versions <- r_versions[!is.na(r_versions)] 63 | 64 | r_version <- max(numeric_version(r_versions)) 65 | r_version <- strsplit(as.character(r_version), "\\.")[[1]] 66 | 67 | return(paste(r_version[1], r_version[2], sep = ".")) 68 | 69 | } else { 70 | 71 | return(NULL) 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /R/refresh.R: -------------------------------------------------------------------------------- 1 | #' Refresh a package/research compendium 2 | #' 3 | #' @description 4 | #' **This function is about to be removed from `rcompendium`.** 5 | #' 6 | #' This function refreshes a package/research compendium. It will: 7 | #' * Update `.Rd` files and `NAMESPACE` by using [devtools::document()]; 8 | #' * Update external packages (in `DESCRIPTION` file) by using 9 | #' [add_dependencies()]; 10 | #' * Update badges in `README.Rmd` (if already present); 11 | #' * Re-knitr the `README.Rmd` by using [rmarkdown::render()]; 12 | #' * Check package integrity by using [devtools::check()]; 13 | #' * Run analysis by sourcing `make.R` (only for compendium). 14 | #' 15 | #' @param make A logical value. If `TRUE` the Make-like R file `make.R` is 16 | #' sourced. Only for research compendium created with [new_compendium()]. 17 | #' Default is `FALSE`. 18 | #' 19 | #' @param check A logical value. If `TRUE` package integrity is checked using 20 | #' [devtools::check()]. 21 | #' Default is `FALSE`. 22 | #' 23 | #' @param quiet A logical value. If `TRUE` (default) message are deleted. 24 | #' 25 | #' @inheritParams add_dependencies 26 | #' 27 | #' @return No return value. 28 | #' 29 | #' @export 30 | #' 31 | #' @family setup functions 32 | #' 33 | #' @examples 34 | #' \dontrun{ 35 | #' library(rcompendium) 36 | #' 37 | #' ## Create an R package ---- 38 | #' new_package() 39 | #' 40 | #' ## Start developing functions ---- 41 | #' ## ... 42 | #' 43 | #' ## Update package (documentation, dependencies, README) ---- 44 | #' refresh() 45 | #' } 46 | 47 | refresh <- function(compendium = NULL, make = FALSE, check = FALSE, 48 | quiet = FALSE) { 49 | 50 | 51 | .Deprecated(msg = "This function is about to be removed from 'rcompendium'") 52 | 53 | is_package() 54 | 55 | stop_if_not_logical(make, check, quiet) 56 | 57 | 58 | ## Loading Project ---- 59 | 60 | ui_title("Loading Project") 61 | 62 | suppressMessages(devtools::load_all(quiet = TRUE)) 63 | 64 | if (!quiet) { 65 | ui_done("Loading {ui_value(get_package_name())}") 66 | } 67 | 68 | 69 | ## Update Rd files and NAMESPACE ---- 70 | 71 | ui_title("Updating Documentation") 72 | 73 | suppressMessages(devtools::document(quiet = TRUE)) 74 | 75 | if (!quiet) { 76 | ui_done("Updating {ui_value('Rd files')} and {ui_value('NAMESPACE')}") 77 | } 78 | 79 | 80 | ## Update Dependencies ---- 81 | 82 | ui_title("Updating Dependencies") 83 | 84 | add_dependencies(compendium) 85 | 86 | 87 | ## Update Badges ---- 88 | 89 | if (file.exists(file.path(path_proj(), "README.Rmd"))) { 90 | 91 | ui_title("Updating Badges") 92 | 93 | read_me <- readLines(con = file.path(path_proj(), "README.Rmd")) 94 | 95 | if (length(grep(paste0("^\\s{0,}\\[!\\[Dependencies"), read_me))) { 96 | 97 | add_dependencies_badge() 98 | } 99 | 100 | if (length(grep(paste0("^\\s{0,}\\[!\\[License"), read_me))) { 101 | 102 | add_license_badge() 103 | } 104 | } 105 | 106 | 107 | ## Update README.md ---- 108 | 109 | if (file.exists(file.path(path_proj(), "README.Rmd"))) { 110 | 111 | ui_title("Updating README") 112 | 113 | rmarkdown::render(file.path(path_proj(), "README.Rmd"), 114 | output_format = "md_document", quiet = TRUE) 115 | 116 | if (!quiet) 117 | ui_done("Re-kniting {ui_value('README.Rmd')}") 118 | } 119 | 120 | 121 | ## Check package integrity ---- 122 | 123 | if (check) { 124 | 125 | ui_title("Checking Package") 126 | 127 | dev_msg <- suppressMessages(devtools::check(quiet = TRUE)) 128 | 129 | print(dev_msg) 130 | } 131 | 132 | 133 | ## Run project (research compendium) ---- 134 | 135 | if (make) { 136 | 137 | ui_title("Running Analysis") 138 | 139 | if (file.exists(file.path(path_proj(), "make.R"))) { 140 | 141 | if (!quiet) 142 | ui_info("Sourcing 'make.R'}") 143 | 144 | source(file.path(path_proj(), "make.R")) 145 | 146 | if (!quiet) 147 | ui_done("Done!") 148 | 149 | } else { 150 | 151 | ui_oops("Unable to find {ui_value('make.R')}") 152 | } 153 | } 154 | 155 | 156 | invisible(NULL) 157 | } 158 | -------------------------------------------------------------------------------- /R/set_credentials.R: -------------------------------------------------------------------------------- 1 | #' Store credentials to the .Rprofile 2 | #' 3 | #' @description 4 | #' This function is used to store user credentials in the `.Rprofile` file. 5 | #' Accepted credentials are listed below. This function is useful if user 6 | #' creates a lot of packages and/or research compendiums. 7 | #' 8 | #' If the `.Rprofile` file does not exist this function will create it. Users 9 | #' need to paste the content of the clipboard to this file. 10 | #' 11 | #' @param given A character of length 1. The given name of the project 12 | #' maintainer. 13 | #' 14 | #' @param family A character of length 1. The family name of the project 15 | #' maintainer. 16 | #' 17 | #' @param email A character of length 1. The email address of the project 18 | #' maintainer. 19 | #' 20 | #' @param orcid A character of length 1. The ORCID of the project maintainer. 21 | #' 22 | #' @param protocol A character of length 1. The GIT protocol used to 23 | #' communicate with the GitHub remote. One of `'https'` or `'ssh'`. If you 24 | #' don't know, keep the default value (i.e. `NULL`) and the protocol will be 25 | #' `'https'`. 26 | #' 27 | #' @return No return value. 28 | #' 29 | #' @export 30 | #' 31 | #' @family setup functions 32 | #' 33 | #' @examples 34 | #' \dontrun{ 35 | #' library(rcompendium) 36 | #' 37 | #' 38 | #' ## Define **ONCE FOR ALL** your credentials ---- 39 | #' 40 | #' set_credentials("John", "Doe", "john.doe@domain.com", 41 | #' orcid = "9999-9999-9999-9999", protocol = "https") 42 | #' } 43 | 44 | set_credentials <- function(given = NULL, family = NULL, email = NULL, 45 | orcid = NULL, protocol = NULL) { 46 | 47 | 48 | credentials <- as.list(match.call())[-1] 49 | 50 | if (length(credentials)) { 51 | 52 | r_prof <- "## RCompendium Credentials ----" 53 | 54 | 55 | ## Check remote protocol ---- 56 | 57 | protocol <- credentials["protocol"]$protocol 58 | 59 | if (!is.null(protocol)) { 60 | 61 | stop_if_not_string(protocol) 62 | 63 | if (!(protocol %in% c("https", "ssh"))) { 64 | 65 | protocol <- NULL 66 | stop("Argument 'protocol' must one among 'https' and 'ssh'.") 67 | } 68 | 69 | 70 | if (!is.null(protocol)) { 71 | 72 | usethis_protocol <- getOption("usethis.protocol") 73 | 74 | if (!is.null(usethis_protocol)) { 75 | 76 | if (usethis_protocol == protocol) { 77 | 78 | ui_oops("Protocol is already set to {ui_value(protocol)}") 79 | protocol <- NULL 80 | } 81 | } 82 | } 83 | } 84 | 85 | 86 | ## Check user credentials ---- 87 | 88 | credentials <- credentials[!(names(credentials) %in% "protocol")] 89 | 90 | if (!is.null(credentials)) { 91 | 92 | invisible(lapply(credentials, stop_if_not_string)) 93 | 94 | opts <- paste0(names(credentials), " = \"", unlist(credentials), "\"") 95 | opts <- paste0(opts, collapse = ", ") 96 | 97 | r_prof <- c(r_prof, paste0("options(", opts, ")", "")) 98 | } 99 | 100 | if (!is.null(protocol)) { 101 | 102 | opts <- paste0("usethis.protocol = \"", protocol, "\"") 103 | r_prof <- c(r_prof, paste0("options(", opts, ")", "")) 104 | } 105 | 106 | 107 | ## Re-write .Rprofile ---- 108 | 109 | ui_todo("Please paste the following lines to the {ui_value('.Rprofile')}:") 110 | usethis::ui_code_block(r_prof) 111 | } 112 | 113 | usethis::edit_r_profile() 114 | 115 | invisible(NULL) 116 | } 117 | -------------------------------------------------------------------------------- /R/sysdata.rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FRBCesab/rcompendium/c50e80d8a693cef53280d46edbb2e544b5744b22/R/sysdata.rda -------------------------------------------------------------------------------- /R/utils-checks.R: -------------------------------------------------------------------------------- 1 | ## Utilities functions - Inputs Checks ---- 2 | 3 | 4 | 5 | #' **Check if arguments are logical of length 1** 6 | #' 7 | #' @param ... one or several arguments 8 | #' 9 | #' @noRd 10 | 11 | stop_if_not_logical <- function(...) { 12 | 13 | args_values <- list(...) 14 | names(args_values) <- as.list(match.call())[-1] 15 | 16 | if (length(args_values)) { 17 | 18 | is_logical <- unlist(lapply(args_values, length)) 19 | 20 | if (any(is_logical != 1)) { 21 | stop("Argument '", names(is_logical[is_logical != 1])[1], 22 | "' must be a logical of length 1.") 23 | } 24 | 25 | is_logical <- unlist(lapply(args_values, is.logical)) 26 | 27 | if (any(!is_logical)) { 28 | stop("Argument '", names(is_logical[!is_logical])[1], 29 | "' must be a logical of length 1.") 30 | } 31 | } 32 | 33 | invisible(NULL) 34 | } 35 | 36 | 37 | 38 | #' **Check if arguments are character of length 1** 39 | #' 40 | #' @param ... one or several arguments 41 | #' 42 | #' @noRd 43 | 44 | stop_if_not_string <- function(...) { 45 | 46 | args_values <- list(...) 47 | names(args_values) <- as.list(match.call())[-1] 48 | 49 | if (length(args_values)) { 50 | 51 | is_string <- unlist(lapply(args_values, length)) 52 | 53 | if (any(is_string != 1)) { 54 | stop("Argument '", names(is_string[is_string != 1])[1], 55 | "' must be a character of length 1.") 56 | } 57 | 58 | is_string <- unlist(lapply(args_values, is.character)) 59 | 60 | if (any(!is_string)) { 61 | stop("Argument '", names(is_string[!is_string])[1], 62 | "' must be a character of length 1.") 63 | } 64 | } 65 | 66 | invisible(NULL) 67 | } 68 | 69 | 70 | 71 | #' **Check if arguments are numeric of length 1** 72 | #' 73 | #' @param ... one or several arguments 74 | #' 75 | #' @noRd 76 | 77 | stop_if_not_numeric <- function(...) { 78 | 79 | args_values <- list(...) 80 | names(args_values) <- as.list(match.call())[-1] 81 | 82 | if (length(args_values)) { 83 | 84 | is_numeric <- unlist(lapply(args_values, length)) 85 | 86 | if (any(is_numeric != 1)) { 87 | stop("Argument '", names(is_numeric[is_numeric != 1])[1], 88 | "' must be a numeric of length 1.") 89 | } 90 | 91 | is_numeric <- unlist(lapply(args_values, is.numeric)) 92 | 93 | if (any(!is_numeric)) { 94 | stop("Argument '", names(is_numeric[!is_numeric])[1], 95 | "' must be a numeric of length 1.") 96 | } 97 | } 98 | 99 | invisible(NULL) 100 | } 101 | -------------------------------------------------------------------------------- /_pkgdown.yml: -------------------------------------------------------------------------------- 1 | url: https://frbcesab.github.io/rcompendium 2 | 3 | template: 4 | bootstrap: 5 5 | 6 | reference: 7 | - title: Prerequisites 8 | desc: | 9 | High level overview of the package 10 | contents: 11 | - rcompendium 12 | 13 | - title: Setup functions 14 | desc: | 15 | These four functions are usually the only ones user needs to run. The use of 16 | `set_credentials` is strongly recommended to permanently store user 17 | information (name, email, orcid, etc.) in the `.Rprofile`. This function 18 | must be run one time. The function `new_package` must be used to create an 19 | R package structure whereas `new_compendium` creates a new research 20 | compendium structure (i.e. R package structure with some additional 21 | files/folders). After that user can start to develop his/her project and 22 | run `refresh` to frequently update the package/compendium components (`Rd` 23 | files, `NAMESPACE`, dependencies, badges, `README.md`, etc.) 24 | contents: 25 | - set_credentials 26 | - new_package 27 | - new_compendium 28 | - refresh 29 | 30 | - title: Create files 31 | desc: | 32 | These function write files specific to R package and research compendium 33 | (`add_makefile`). They are called by the main functions `new_package`, 34 | `new_compendium`, and `refresh` but they also can be used to overwrite files 35 | (with `overwrite = TRUE`) in case of broken code. When `open = TRUE` and 36 | `overwrite = FALSE` (default) files are open in the editor. 37 | contents: 38 | - add_description 39 | - add_license 40 | - add_package_doc 41 | - add_citation 42 | - add_code_of_conduct 43 | - add_contributing 44 | - add_testthat 45 | - add_vignette 46 | - add_readme_rmd 47 | - add_compendium 48 | - add_makefile 49 | - add_renv 50 | - add_dockerfile 51 | 52 | - title: README badges 53 | desc: | 54 | These functions add badges to the `README.Rmd`. They are called by the main 55 | functions `new_package`, `new_compendium`, and `refresh` but they also can 56 | be used to update badges if license, lifecycle, repository status change or 57 | to update number of dependencies (`add_dependencies_badge`). 58 | contents: 59 | - add_cran_badge 60 | - add_dependencies_badge 61 | - add_license_badge 62 | - add_lifecycle_badge 63 | - add_repostatus_badge 64 | - add_github_actions_check_badge 65 | - add_github_actions_pkgdown_badge 66 | - add_github_actions_codecov_badge 67 | - add_codecov_badge 68 | 69 | - title: Advanced functions 70 | desc: | 71 | These functions update fields in `DESCRIPTION` (`add_dependencies` and 72 | `add_r_depend`), edit files (`add_to_gitignore` and `add_to_buildignore`), 73 | or write configuration files (`add_github_actions_check`, 74 | `add_github_actions_pkgdown`, `add_github_actions_codecov`, and 75 | `add_github_actions_render`). 76 | contents: 77 | - add_dependencies 78 | - add_r_depend 79 | - add_to_gitignore 80 | - add_to_buildignore 81 | - add_github_actions_check 82 | - add_github_actions_pkgdown 83 | - add_github_actions_codecov 84 | - add_github_actions_render 85 | - add_github_actions_citation 86 | - add_github_actions_codemeta 87 | - add_github_actions_document 88 | 89 | - title: Utilities functions 90 | desc: | 91 | These functions return objects but do not edit any file. 92 | contents: 93 | - get_licenses 94 | - get_all_dependencies 95 | - get_all_functions 96 | - get_minimal_r_version 97 | -------------------------------------------------------------------------------- /inst/CITATION: -------------------------------------------------------------------------------- 1 | citHeader("To cite rcompendium in publications use:") 2 | 3 | bibentry( 4 | bibtype = "Manual", 5 | title = "{rcompendium}: {An} {R} package to create a package or research compendium structure", 6 | author = c(person("Casajus N.")), 7 | year = "2023", 8 | note = "R package version 1.3", 9 | url = "https://github.com/FRBCesab/rcompendium" 10 | ) 11 | -------------------------------------------------------------------------------- /inst/hexsticker/hexsticker.R: -------------------------------------------------------------------------------- 1 | #' 2 | #' Create an Hexagonal Sticker for the Package 3 | #' 4 | 5 | hexSticker::sticker( 6 | 7 | subplot = here::here("inst", "hexsticker", "icon.png"), 8 | package = "rcompendium", 9 | filename = here::here("man", "figures", "hexsticker.png"), 10 | dpi = 600, 11 | 12 | p_size = 6.0, # Title 13 | u_size = 1.2, # URL 14 | p_family = "Aller_Rg", 15 | 16 | p_color = "#722F26", # Title 17 | h_fill = "#B0987D", # Background 18 | h_color = "#722F26", # Border 19 | u_color = "#433625", # URL 20 | 21 | p_x = 1.00, # Title 22 | p_y = 0.65, # Title 23 | s_x = 1.00, # Subplot 24 | s_y = 1.25, # Subplot 25 | 26 | s_width = 0.50, # Subplot 27 | 28 | url = "https://frbcesab.github.io/rcompendium" 29 | ) 30 | -------------------------------------------------------------------------------- /inst/hexsticker/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FRBCesab/rcompendium/c50e80d8a693cef53280d46edbb2e544b5744b22/inst/hexsticker/icon.png -------------------------------------------------------------------------------- /inst/licenses/copyright-mit: -------------------------------------------------------------------------------- 1 | YEAR: {{year}} 2 | COPYRIGHT HOLDER: {{given}} {{family}} 3 | -------------------------------------------------------------------------------- /inst/licenses/license-mit: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) {{year}} {{given}} {{family}} 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /inst/templates/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: {{project_name}} 2 | Type: Package 3 | Title: The Title of the Project 4 | Version: 0.0.0.9000 5 | Authors@R: c( 6 | person(given = "{{given}}", 7 | family = "{{family}}", 8 | role = c("aut", "cre", "cph"), 9 | email = "{{email}}", 10 | comment = c(ORCID = "{{orcid}}"))) 11 | Description: A paragraph providing a full description of the project (on 12 | several lines...) 13 | URL: https://github.com/{{github}}/{{project_name}} 14 | BugReports: https://github.com/{{github}}/{{project_name}}/issues 15 | License: {{license}} 16 | Encoding: UTF-8 17 | Roxygen: list(markdown = TRUE) 18 | RoxygenNote: {{roxygen2_version}} 19 | -------------------------------------------------------------------------------- /inst/templates/Dockerfile: -------------------------------------------------------------------------------- 1 | ## Based on the image RStudio with R {{r_version}} ---- 2 | 3 | FROM rocker/rstudio:{{r_version}} 4 | 5 | MAINTAINER {{given}} {{family}} <{{email}}> 6 | 7 | 8 | ## Install system dependencies ---- 9 | 10 | RUN sudo apt update -yq \ 11 | && sudo apt install --no-install-recommends libxml2-dev -yq \ 12 | && sudo apt clean all \ 13 | && sudo apt purge \ 14 | && sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* 15 | 16 | 17 | ## Copy local project ---- 18 | 19 | ENV folder="/home/rstudio/" 20 | 21 | COPY . $folder 22 | RUN chown -R rstudio:rstudio $folder 23 | 24 | 25 | ## Set working directory ---- 26 | 27 | WORKDIR $folder 28 | 29 | 30 | ## Install R packages ---- 31 | 32 | {{install_packages}} 33 | -------------------------------------------------------------------------------- /inst/templates/R-CMD-check.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | 4 | on: 5 | push: 6 | branches: [main, master] 7 | pull_request: 8 | branches: [main, master] 9 | 10 | name: R CMD Check 11 | 12 | jobs: 13 | R-CMD-check: 14 | runs-on: ${{ matrix.config.os }} 15 | 16 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 17 | 18 | strategy: 19 | fail-fast: false 20 | matrix: 21 | config: 22 | - {os: macos-latest, r: 'release'} 23 | - {os: windows-latest, r: 'release'} 24 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 25 | - {os: ubuntu-latest, r: 'release'} 26 | - {os: ubuntu-latest, r: 'oldrel-1'} 27 | 28 | env: 29 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 30 | R_KEEP_PKG_SOURCE: yes 31 | 32 | steps: 33 | - uses: actions/checkout@v4 34 | 35 | - uses: r-lib/actions/setup-pandoc@v2 36 | 37 | - uses: r-lib/actions/setup-r@v2 38 | with: 39 | r-version: ${{ matrix.config.r }} 40 | http-user-agent: ${{ matrix.config.http-user-agent }} 41 | use-public-rspm: true 42 | 43 | - uses: r-lib/actions/setup-r-dependencies@v2 44 | with: 45 | extra-packages: any::rcmdcheck 46 | needs: check 47 | 48 | - uses: r-lib/actions/check-r-package@v2 49 | with: 50 | upload-snapshots: true 51 | build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' 52 | -------------------------------------------------------------------------------- /inst/templates/README-comp.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | 8 | ```{r, include = FALSE} 9 | knitr::opts_chunk$set(collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "figures/readme/", 12 | out.width = "100%") 13 | ``` 14 | 15 | 16 | 17 | {{project_name}} 18 | ========================================================= 19 | 20 | 21 | 22 | 23 | 24 | 25 |

26 | • Overview
27 | • Data sources
28 | • Workflow
29 | • Content
30 | • Installation
31 | • Usage
32 | • Citation
33 | • Contributing
34 | • Acknowledgments
35 | • References 36 |

37 | 38 | 39 | 40 | ## Overview 41 | 42 | This project is dedicated to... **{{ DESCRIBE YOUR PROJECT }}** 43 | 44 | 45 | 46 | ## Data sources 47 | 48 | This project uses the following databases: 49 | 50 | **{{ DESCRIBE THE DATA SOURCES }}** 51 | 52 | 57 | 58 | 59 | ## Workflow 60 | 61 | The analysis pipeline follows these steps: 62 | 63 | **{{ DESCRIBE THE PIPELINE }}** 64 | 65 | 66 | ## Content 67 | 68 | This repository is structured as follow: 69 | 70 | - [`DESCRIPTION`](https://github.com/{{github}}/{{project_name}}/tree/{{branch}}/DESCRIPTION): 71 | contains project metadata (authors, date, dependencies, etc.) 72 | 73 | - [`make.R`](https://github.com/{{github}}/{{project_name}}/tree/{{branch}}/make.R): 74 | main R script to run the entire project 75 | 76 | - [`R/`](https://github.com/{{github}}/{{project_name}}/tree/{{branch}}/R): 77 | contains R functions developed especially for this project 78 | 79 | **{{ LIST ADDITIONAL FILES/FOLDER }}** 80 | 81 | 82 | 83 | ## Installation 84 | 85 | To install this compendium: 86 | 87 | - [Fork](https://docs.github.com/en/get-started/quickstart/contributing-to-projects) 88 | this repository using the GitHub interface. 89 | - [Clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) 90 | your fork using `git clone fork-url` (replace `fork-url` by the URL of your fork). 91 | Alternatively, open [RStudio IDE](https://posit.co/products/open-source/rstudio/) 92 | and create a New Project from Version Control. 93 | 94 | 95 | 96 | ## Usage 97 | 98 | Launch the [`make.R`](https://github.com/{{github}}/{{project_name}}/tree/{{branch}}/make.R) 99 | file with: 100 | 101 | ```{r eval=FALSE} 102 | source("make.R") 103 | ``` 104 | 105 | **Notes** 106 | 107 | - All required packages listed in the `DESCRIPTION` file will be installed (if necessary) 108 | - All required packages and R functions will be loaded 109 | - Some analyses listed in the `make.R` might take time 110 | 111 | 112 | 113 | ## Citation 114 | 115 | Please use the following citation: 116 | 117 | > **{{ ADD A CITATION }}** 118 | 119 | 120 | 121 | ## Contributing 122 | 123 | All types of contributions are encouraged and valued. For more information, 124 | check out our [Contributor Guidelines](https://github.com/{{github}}/{{project_name}}/blob/main/CONTRIBUTING.md). 125 | 126 | Please note that this project is released with a 127 | [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). 128 | By contributing to this project, you agree to abide by its terms. 129 | 130 | 131 | 132 | ## Acknowledgments 133 | 134 | **{{ OPTIONAL SECTION }}** 135 | 136 | 137 | 138 | ## References 139 | 140 | **{{ OPTIONAL SECTION }}** 141 | -------------------------------------------------------------------------------- /inst/templates/README-pkg.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | 6 | 7 | 8 | ```{r, include = FALSE} 9 | knitr::opts_chunk$set(collapse = TRUE, 10 | comment = "#>", 11 | fig.path = "man/figures/", 12 | out.width = "100%") 13 | ``` 14 | 15 | 16 | 17 | {{project_name}} 18 | ========================================================= 19 | 20 | 21 | 22 | 23 | 24 | 25 |

26 | • Overview
27 | • Features
28 | • Installation
29 | • Get started
30 | • Long-form documentations
31 | • Citation
32 | • Contributing
33 | • Acknowledgments
34 | • References 35 |

36 | 37 | 38 | 39 | ## Overview 40 | 41 | 42 | The R package `{{project_name}}`... **{{ DESCRIBE YOUR PACKAGE }}** 43 | 44 | 45 | 46 | ## Features 47 | 48 | The main purpose of `{{project_name}}` is to... **{{ DESCRIBE THE MAIN FEATURES }}** 49 | 50 | 51 | 52 | ## Installation 53 | 54 | You can install the development version from [GitHub](https://github.com/) with: 55 | 56 | ```{r eval=FALSE} 57 | ## Install < remotes > package (if not already installed) ---- 58 | if (!requireNamespace("remotes", quietly = TRUE)) { 59 | install.packages("remotes") 60 | } 61 | 62 | ## Install < {{project_name}} > from GitHub ---- 63 | remotes::install_github("{{github}}/{{project_name}}") 64 | ``` 65 | 66 | Then you can attach the package `{{project_name}}`: 67 | 68 | ```{r eval=FALSE} 69 | library("{{project_name}}") 70 | ``` 71 | 72 | 73 | 74 | ## Get started 75 | 76 | For an overview of the main features of `{{project_name}}`, please read the 77 | [Get started](https://{{github}}.github.io/{{project_name}}/articles/{{project_name}}.html) 78 | vignette. 79 | 80 | 81 | 82 | ## Long-form documentations 83 | 84 | `{{project_name}}` provides **{{ NUMBER OF VIGNETTES }}** vignettes to learn more about the package: 85 | 86 | - the [Get started](https://{{github}}.github.io/{{project_name}}/articles/{{project_name}}.html) 87 | vignette describes the core features of the package 88 | - **{{ LIST ADDITIONAL VIGNETTES }}** 89 | 90 | 91 | 92 | ## Citation 93 | 94 | Please cite `{{project_name}}` as: 95 | 96 | > {{family}} {{given}} (`r format(Sys.Date(), "%Y")`) {{project_name}}: An R 97 | package to **{{ TITLE }}**. R package version {{pkg_version}}. 98 | 99 | 100 | 101 | 102 | ## Contributing 103 | 104 | All types of contributions are encouraged and valued. For more information, 105 | check out our [Contributor Guidelines](https://github.com/{{github}}/{{project_name}}/blob/main/CONTRIBUTING.md). 106 | 107 | Please note that the `{{project_name}}` project is released with a 108 | [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). 109 | By contributing to this project, you agree to abide by its terms. 110 | 111 | 112 | 113 | ## Acknowledgments 114 | 115 | **{{ OPTIONAL SECTION }}** 116 | 117 | 118 | 119 | ## References 120 | 121 | **{{ OPTIONAL SECTION }}** 122 | -------------------------------------------------------------------------------- /inst/templates/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Standard bug report template 4 | title: '' 5 | labels: 'bug' 6 | --- 7 | 8 | **Bug description** 9 | 10 | A clear and concise description of what the bug is. 11 | 12 | 13 | **Reproducible example** 14 | 15 | It is easier for developers to help if they can reproduce the problem. 16 | Could you please provide a minimal reproducible example? 17 | 18 | 19 | **Additional context** 20 | 21 | Add any other context about the problem here. 22 | 23 | 24 |
25 | ```r 26 | # Output of sessionInfo() 27 | ``` 28 |
29 | -------------------------------------------------------------------------------- /inst/templates/citation: -------------------------------------------------------------------------------- 1 | citHeader("To cite {{project_name}} in publications use:") 2 | 3 | bibentry( 4 | bibtype = "Manual", 5 | title = "{{project_name}}: {An} {R} package to ...", 6 | author = c(person("{{family}} {{given}}")), 7 | year = "{{year}}", 8 | note = "R package version {{pkg_version}}", 9 | url = "https://github.com/{{github}}/{{project_name}}" 10 | ) 11 | -------------------------------------------------------------------------------- /inst/templates/compendium-sticker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FRBCesab/rcompendium/c50e80d8a693cef53280d46edbb2e544b5744b22/inst/templates/compendium-sticker.png -------------------------------------------------------------------------------- /inst/templates/dockerignore: -------------------------------------------------------------------------------- 1 | # macOS files ---- 2 | .DS_Store 3 | 4 | # Large files ---- 5 | .git 6 | renv/library 7 | renv/local 8 | 9 | # History files ---- 10 | .Rhistory 11 | .Rapp.history 12 | 13 | # Session Data files ---- 14 | .RData 15 | .Ruserdata 16 | 17 | # RStudio files ---- 18 | *.Rproj 19 | .Rproj.user/ 20 | -------------------------------------------------------------------------------- /inst/templates/document-package.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: 4 | push: 5 | paths: ["R/**"] 6 | 7 | name: Document 8 | 9 | jobs: 10 | document: 11 | runs-on: ubuntu-latest 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - name: Checkout repo 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | 20 | - name: Setup R 21 | uses: r-lib/actions/setup-r@v2 22 | with: 23 | use-public-rspm: true 24 | 25 | - name: Install dependencies 26 | uses: r-lib/actions/setup-r-dependencies@v2 27 | with: 28 | extra-packages: any::roxygen2 29 | needs: roxygen2 30 | 31 | - name: Document 32 | run: roxygen2::roxygenise() 33 | shell: Rscript {0} 34 | 35 | - name: Commit and push changes 36 | run: | 37 | git config --local user.name "$GITHUB_ACTOR" 38 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 39 | git add man/\* NAMESPACE DESCRIPTION 40 | git commit -m "doc: update documentation" || echo "No changes to commit" 41 | git pull --ff-only 42 | git push origin 43 | -------------------------------------------------------------------------------- /inst/templates/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Standard feature request template 4 | title: '' 5 | labels: 'enhancement' 6 | --- 7 | 8 | **Feature description** 9 | 10 | A clear and complete description of what the requested feature is. 11 | -------------------------------------------------------------------------------- /inst/templates/fun-demo.R: -------------------------------------------------------------------------------- 1 | #' Print a message 2 | #' 3 | #' @description 4 | #' This function prints a simple message. This is a demo function to show good 5 | #' practices in writing and documenting R function. If you delete this function 6 | #' do not forget to delete the corresponding test file 7 | #' `tests/testthat/test-demo.R` if you used `new_package(test = TRUE)`. 8 | #' 9 | #' @param x a character of length 1. Default is `'Hello world'`. 10 | #' 11 | #' @return The value of `x` (only if the result is assigned to a variable). 12 | #' 13 | #' @export 14 | #' 15 | #' @examples 16 | #' print_msg() 17 | #' print_msg("Bonjour le monde") 18 | #' 19 | #' x <- print_msg("Bonjour le monde") 20 | #' x 21 | 22 | print_msg <- function(x = "Hello world") { 23 | 24 | if (!is.character(x) || length(x) != 1) 25 | stop("Argument 'x' must be a character of length 1.") 26 | 27 | cat(x, "\n") 28 | 29 | invisible(x) 30 | } 31 | -------------------------------------------------------------------------------- /inst/templates/gitignore: -------------------------------------------------------------------------------- 1 | # macOS files ---- 2 | .DS_Store 3 | 4 | # History files ---- 5 | .Rhistory 6 | .Rapp.history 7 | 8 | # Session Data files ---- 9 | .RData 10 | .Ruserdata 11 | 12 | # RStudio files ---- 13 | *.Rproj 14 | .Rproj.user/ 15 | 16 | # R Environment Variables ---- 17 | .Renviron 18 | 19 | # User-specific files ---- 20 | README.html 21 | inst/doc 22 | -------------------------------------------------------------------------------- /inst/templates/make.R: -------------------------------------------------------------------------------- 1 | #' {{project_name}}: A Research Compendium 2 | #' 3 | #' @description 4 | #' A paragraph providing a full description of the project and describing each 5 | #' step of the workflow. 6 | #' 7 | #' @author {{given}} {{family}} \email{{{email}}} 8 | #' 9 | #' @date {{date}} 10 | 11 | 12 | 13 | ## Install Dependencies (listed in DESCRIPTION) ---- 14 | 15 | devtools::install_deps(upgrade = "never") 16 | 17 | 18 | ## Load Project Addins (R Functions and Packages) ---- 19 | 20 | devtools::load_all(here::here()) 21 | 22 | 23 | ## Global Variables ---- 24 | 25 | # You can list global variables here (or in a separate R script) 26 | 27 | 28 | ## Run Project ---- 29 | 30 | # List all R scripts in a sequential order and using the following form: 31 | # source(here::here("analyses", "script_X.R")) 32 | -------------------------------------------------------------------------------- /inst/templates/other_issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Other issue 3 | about: Template for other issue types 4 | title: '' 5 | labels: '' 6 | --- 7 | -------------------------------------------------------------------------------- /inst/templates/package-package.R: -------------------------------------------------------------------------------- 1 | #' @keywords internal 2 | "_PACKAGE" 3 | 4 | # Imports: start ---- 5 | # Imports: end ---- 6 | 7 | NULL 8 | -------------------------------------------------------------------------------- /inst/templates/package-sticker.R: -------------------------------------------------------------------------------- 1 | #' 2 | #' Create an Hexagonal Sticker for the Package 3 | #' 4 | 5 | 6 | # install.packages(c("png", "ggplot2", "hexSticker", "grid", "ggpubr")) 7 | 8 | 9 | rlogo <- png::readPNG(here::here("inst", "package-sticker", "r_logo.png")) 10 | rlogo <- grid::rasterGrob(rlogo, interpolate = TRUE) 11 | 12 | p <- ggplot2::ggplot() + 13 | ggplot2::annotation_custom(rlogo, xmin = -Inf, xmax = Inf, ymin = -Inf, 14 | ymax = Inf) + 15 | ggplot2::theme_void() + 16 | ggpubr::theme_transparent() 17 | 18 | hexSticker::sticker( 19 | 20 | subplot = p, 21 | package = "R Package", 22 | filename = here::here("man", "figures", "package-sticker.png"), 23 | dpi = 600, 24 | 25 | p_size = 28.0, # Title 26 | u_size = 5.0, # URL 27 | p_family = "Aller_Rg", 28 | 29 | p_color = "#32436F", # Title 30 | h_fill = "#FFFFFF", # Background 31 | h_color = "#1064B2", # Border 32 | u_color = "#32436F", # URL 33 | 34 | p_x = 1.00, # Title 35 | p_y = 0.60, # Title 36 | s_x = 1.00, # Subplot 37 | s_y = 1.25, # Subplot 38 | 39 | s_width = 1.25, # Subplot 40 | s_height = 1.25, # Subplot 41 | 42 | url = "https://github.com/", 43 | 44 | spotlight = TRUE, 45 | l_alpha = 0.10, 46 | l_width = 4, 47 | l_height = 4 48 | ) 49 | -------------------------------------------------------------------------------- /inst/templates/package-sticker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FRBCesab/rcompendium/c50e80d8a693cef53280d46edbb2e544b5744b22/inst/templates/package-sticker.png -------------------------------------------------------------------------------- /inst/templates/package-vignette.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "{{title}}" 3 | output: rmarkdown::html_vignette 4 | vignette: > 5 | %\VignetteIndexEntry{{{title}}} 6 | %\VignetteEngine{knitr::rmarkdown} 7 | %\VignetteEncoding{UTF-8} 8 | --- 9 | 10 | ```{r, include = FALSE} 11 | knitr::opts_chunk$set(collapse = TRUE, 12 | comment = "#>") 13 | ``` 14 | 15 | 16 | ```{r setup} 17 | library({{project_name}}) 18 | ``` 19 | 20 | -------------------------------------------------------------------------------- /inst/templates/pkgdown.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | 4 | on: 5 | push: 6 | branches: [main, master] 7 | pull_request: 8 | branches: [main, master] 9 | release: 10 | types: [published] 11 | workflow_dispatch: 12 | 13 | name: Website 14 | 15 | jobs: 16 | pkgdown: 17 | runs-on: ubuntu-latest 18 | # Only restrict concurrency for non-PR jobs 19 | concurrency: 20 | group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} 21 | env: 22 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 23 | permissions: 24 | contents: write 25 | steps: 26 | - uses: actions/checkout@v4 27 | 28 | - uses: r-lib/actions/setup-pandoc@v2 29 | 30 | - uses: r-lib/actions/setup-r@v2 31 | with: 32 | use-public-rspm: true 33 | 34 | - uses: r-lib/actions/setup-r-dependencies@v2 35 | with: 36 | extra-packages: any::pkgdown, local::. 37 | needs: website 38 | 39 | - name: Build site 40 | run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) 41 | shell: Rscript {0} 42 | 43 | - name: Deploy to GitHub pages 44 | if: github.event_name != 'pull_request' 45 | uses: JamesIves/github-pages-deploy-action@v4.4.1 46 | with: 47 | clean: false 48 | branch: gh-pages 49 | folder: docs 50 | -------------------------------------------------------------------------------- /inst/templates/r_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FRBCesab/rcompendium/c50e80d8a693cef53280d46edbb2e544b5744b22/inst/templates/r_logo.png -------------------------------------------------------------------------------- /inst/templates/render-README.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/blob/v2-branch/examples/render-rmarkdown.yaml 2 | 3 | on: 4 | push: 5 | paths: 'README.Rmd' 6 | 7 | name: Render README 8 | 9 | jobs: 10 | render-readme: 11 | runs-on: ubuntu-latest 12 | env: 13 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 14 | steps: 15 | - name: Checkout repo 16 | uses: actions/checkout@v4 17 | with: 18 | fetch-depth: 0 19 | 20 | - uses: r-lib/actions/setup-pandoc@v2 21 | - uses: r-lib/actions/setup-r@v2 22 | 23 | - name: Install Rmarkdown 24 | run: Rscript -e 'install.packages("rmarkdown")' 25 | 26 | - name: Render README 27 | run: | 28 | RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '^README.Rmd$')) 29 | Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]} 30 | 31 | - name: Commit results 32 | run: | 33 | git config --local user.name "$GITHUB_ACTOR" 34 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 35 | git commit README.md -m 'doc: render README' || echo "No changes to commit" 36 | git push origin || echo "No changes to commit" 37 | -------------------------------------------------------------------------------- /inst/templates/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | 4 | on: 5 | push: 6 | branches: [main, master] 7 | pull_request: 8 | branches: [main, master] 9 | 10 | name: Test coverage 11 | 12 | jobs: 13 | test-coverage: 14 | runs-on: ubuntu-latest 15 | env: 16 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 17 | 18 | steps: 19 | - uses: actions/checkout@v4 20 | 21 | - uses: r-lib/actions/setup-r@v2 22 | with: 23 | use-public-rspm: true 24 | 25 | - uses: r-lib/actions/setup-r-dependencies@v2 26 | with: 27 | extra-packages: any::covr 28 | needs: coverage 29 | 30 | - name: Test coverage 31 | run: | 32 | covr::codecov( 33 | quiet = FALSE, 34 | clean = FALSE, 35 | install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") 36 | ) 37 | shell: Rscript {0} 38 | 39 | - name: Show testthat output 40 | if: always() 41 | run: | 42 | ## -------------------------------------------------------------------- 43 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 44 | shell: bash 45 | 46 | - name: Upload test results 47 | if: failure() 48 | uses: actions/upload-artifact@v4 49 | with: 50 | name: coverage-test-failures 51 | path: ${{ runner.temp }}/package 52 | -------------------------------------------------------------------------------- /inst/templates/test-demo.R: -------------------------------------------------------------------------------- 1 | ## Test demo ---- 2 | 3 | test_that("Test demo", { 4 | expect_invisible(print_msg()) 5 | 6 | x <- print_msg() 7 | expect_equal(x, "Hello world") 8 | 9 | x <- print_msg("Bonjour le monde") 10 | expect_equal(x, "Bonjour le monde") 11 | 12 | expect_error(print_msg(c("Hello", "world"))) 13 | expect_error(print_msg(1), "Argument 'x' must be a character of length 1.") 14 | }) 15 | -------------------------------------------------------------------------------- /inst/templates/update-citation-cff.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/master/examples 2 | 3 | on: 4 | release: 5 | types: [published] 6 | push: 7 | branches: [master, main] 8 | paths: 9 | - DESCRIPTION 10 | - inst/CITATION 11 | workflow_dispatch: 12 | 13 | name: Update CITATION.cff 14 | 15 | jobs: 16 | update-citation-cff: 17 | runs-on: macos-latest 18 | env: 19 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 20 | steps: 21 | - uses: actions/checkout@v4 22 | - uses: r-lib/actions/setup-r@v2 23 | - uses: r-lib/actions/setup-r-dependencies@v2 24 | with: 25 | extra-packages: | 26 | any::cffr 27 | any::V8 28 | 29 | - name: Update CITATION.cff 30 | run: | 31 | # Update CITATION.cff file 32 | cffr::cff_write(keys = list()) 33 | shell: Rscript {0} 34 | 35 | - name: Commit results 36 | run: | 37 | git config --local user.name "$GITHUB_ACTOR" 38 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 39 | git add CITATION.cff 40 | git commit -m 'doc: update CITATION.cff' || echo "No changes to commit" 41 | git push origin || echo "No changes to commit" 42 | -------------------------------------------------------------------------------- /inst/templates/update-codemeta.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | release: 3 | types: [published] 4 | push: 5 | branches: [master, main] 6 | paths: 7 | - DESCRIPTION 8 | - inst/CITATION 9 | - README.md 10 | workflow_dispatch: 11 | 12 | name: Update codemeta.json 13 | 14 | jobs: 15 | update-codemeta: 16 | runs-on: macos-latest 17 | env: 18 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: r-lib/actions/setup-r@v2 22 | - uses: r-lib/actions/setup-r-dependencies@v2 23 | with: 24 | extra-packages: | 25 | any::codemetar 26 | 27 | - name: Update codemeta.json 28 | run: codemetar::write_codemeta() 29 | shell: Rscript {0} 30 | 31 | - name: Commit results 32 | run: | 33 | git config --local user.name "$GITHUB_ACTOR" 34 | git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com" 35 | git add codemeta.json 36 | git commit -m 'Update codemeta.json' || echo "No changes to commit" 37 | git push origin || echo "No changes to commit" 38 | -------------------------------------------------------------------------------- /man/add_citation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_citation.R 3 | \name{add_citation} 4 | \alias{add_citation} 5 | \title{Create a CITATION file} 6 | \usage{ 7 | add_citation( 8 | given = NULL, 9 | family = NULL, 10 | organisation = NULL, 11 | open = TRUE, 12 | overwrite = FALSE, 13 | quiet = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{given}{A character of length 1. The given name of the project 18 | maintainer.} 19 | 20 | \item{family}{A character of length 1. The family name of the project 21 | maintainer.} 22 | 23 | \item{organisation}{A character of length 1. The name of the GitHub 24 | organisation to host the package. If \code{NULL} (default) the GitHub account 25 | will be used. This argument is used to set the URL of the package 26 | (hosted on GitHub).} 27 | 28 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 29 | editor.} 30 | 31 | \item{overwrite}{A logical value. If this file is already present and 32 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 33 | 34 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 35 | \code{FALSE}.} 36 | } 37 | \value{ 38 | No return value. 39 | } 40 | \description{ 41 | This function creates a \code{CITATION} file in the folder \verb{inst/}. This file 42 | contains a BiBTeX entry to cite the package as a manual. User will need to 43 | edit by hand some information (title, version, etc.). 44 | } 45 | \examples{ 46 | \dontrun{ 47 | add_citation() 48 | readCitationFile("inst/CITATION") 49 | citation("pkg") # If you have installed your package 50 | } 51 | } 52 | \seealso{ 53 | Other create files: 54 | \code{\link{add_code_of_conduct}()}, 55 | \code{\link{add_compendium}()}, 56 | \code{\link{add_contributing}()}, 57 | \code{\link{add_description}()}, 58 | \code{\link{add_dockerfile}()}, 59 | \code{\link{add_license}()}, 60 | \code{\link{add_makefile}()}, 61 | \code{\link{add_package_doc}()}, 62 | \code{\link{add_readme_rmd}()}, 63 | \code{\link{add_renv}()}, 64 | \code{\link{add_testthat}()}, 65 | \code{\link{add_vignette}()} 66 | } 67 | \concept{create files} 68 | -------------------------------------------------------------------------------- /man/add_code_of_conduct.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_code_of_conduct.R 3 | \name{add_code_of_conduct} 4 | \alias{add_code_of_conduct} 5 | \title{Add code of conduct} 6 | \usage{ 7 | add_code_of_conduct( 8 | email = NULL, 9 | open = TRUE, 10 | overwrite = FALSE, 11 | quiet = FALSE 12 | ) 13 | } 14 | \arguments{ 15 | \item{email}{A character of length 1. The email address of the project 16 | maintainer.} 17 | 18 | \item{open}{A logical value. If \code{TRUE} (default) the \code{CONTRIBUTING.md} file 19 | is opened in the editor.} 20 | 21 | \item{overwrite}{A logical value. If files are already present and 22 | \code{overwrite = TRUE}, they will be erased and replaced. Default is \code{FALSE}.} 23 | 24 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 25 | \code{FALSE}.} 26 | } 27 | \value{ 28 | No return value. 29 | } 30 | \description{ 31 | This function creates a \code{CODE_OF_CONDUCT.md} file adapted from the 32 | Contributor Covenant, version 2.1 available at 33 | \url{https://www.contributor-covenant.org/version/2/1/code_of_conduct.html}. 34 | } 35 | \examples{ 36 | \dontrun{ 37 | add_code_of_conduct() 38 | } 39 | } 40 | \seealso{ 41 | Other create files: 42 | \code{\link{add_citation}()}, 43 | \code{\link{add_compendium}()}, 44 | \code{\link{add_contributing}()}, 45 | \code{\link{add_description}()}, 46 | \code{\link{add_dockerfile}()}, 47 | \code{\link{add_license}()}, 48 | \code{\link{add_makefile}()}, 49 | \code{\link{add_package_doc}()}, 50 | \code{\link{add_readme_rmd}()}, 51 | \code{\link{add_renv}()}, 52 | \code{\link{add_testthat}()}, 53 | \code{\link{add_vignette}()} 54 | } 55 | \concept{create files} 56 | -------------------------------------------------------------------------------- /man/add_codecov_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_codecov_badge.R 3 | \name{add_codecov_badge} 4 | \alias{add_codecov_badge} 5 | \title{Add a Codecov badge} 6 | \usage{ 7 | add_codecov_badge(organisation = NULL, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{organisation}{A character of length 1. The name of the GitHub 11 | organisation to host the package. If \code{NULL} (default) the GitHub account 12 | will be used.} 13 | 14 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 15 | \code{FALSE}.} 16 | } 17 | \value{ 18 | A badge as a markdown expression. 19 | } 20 | \description{ 21 | This function adds a \strong{Code coverage} badge to the \code{README.Rmd}, i.e. the 22 | percentage of code cover by units tests. This percentage is computed by 23 | the codecov.io service. 24 | 25 | \strong{Note:} this service must be manually activated for the package by visiting 26 | \url{https://about.codecov.io/}. 27 | 28 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 29 | contains a block starting with the line \verb{} and ending 30 | with the line \verb{}. 31 | 32 | Don't forget to re-render the \code{README.md}. 33 | } 34 | \examples{ 35 | \dontrun{ 36 | add_codecov_badge() 37 | } 38 | } 39 | \seealso{ 40 | Other adding badges: 41 | \code{\link{add_cran_badge}()}, 42 | \code{\link{add_dependencies_badge}()}, 43 | \code{\link{add_github_actions_check_badge}()}, 44 | \code{\link{add_github_actions_codecov_badge}()}, 45 | \code{\link{add_github_actions_pkgdown_badge}()}, 46 | \code{\link{add_license_badge}()}, 47 | \code{\link{add_lifecycle_badge}()}, 48 | \code{\link{add_repostatus_badge}()} 49 | } 50 | \concept{adding badges} 51 | -------------------------------------------------------------------------------- /man/add_compendium.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_compendium.R 3 | \name{add_compendium} 4 | \alias{add_compendium} 5 | \title{Create additional folders} 6 | \usage{ 7 | add_compendium(compendium = NULL, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{compendium}{A character vector specifying the folders to be created.} 11 | 12 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 13 | \code{FALSE}.} 14 | } 15 | \value{ 16 | No return value. 17 | } 18 | \description{ 19 | This function creates a compendium, i.e. additional folders to a package 20 | structure. By default, the following directories are created: 21 | \code{data}, \verb{analyses/}, \verb{outputs/}, and \verb{figures/}. A \code{README.md} is added to 22 | each folder and must be edited. The argument \code{compendium} allows user to 23 | hoose its own compendium structure. All theses folders are added to the 24 | \code{.Rbuildignore} file. 25 | } 26 | \examples{ 27 | \dontrun{ 28 | add_compendium() 29 | add_compendium(compendium = "paper") 30 | add_compendium(compendium = c("data", "outputs", "code", "manuscript")) 31 | } 32 | } 33 | \seealso{ 34 | Other create files: 35 | \code{\link{add_citation}()}, 36 | \code{\link{add_code_of_conduct}()}, 37 | \code{\link{add_contributing}()}, 38 | \code{\link{add_description}()}, 39 | \code{\link{add_dockerfile}()}, 40 | \code{\link{add_license}()}, 41 | \code{\link{add_makefile}()}, 42 | \code{\link{add_package_doc}()}, 43 | \code{\link{add_readme_rmd}()}, 44 | \code{\link{add_renv}()}, 45 | \code{\link{add_testthat}()}, 46 | \code{\link{add_vignette}()} 47 | } 48 | \concept{create files} 49 | -------------------------------------------------------------------------------- /man/add_contributing.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_contributing.R 3 | \name{add_contributing} 4 | \alias{add_contributing} 5 | \title{Add contribution guidelines} 6 | \usage{ 7 | add_contributing( 8 | email = NULL, 9 | organisation = NULL, 10 | open = TRUE, 11 | overwrite = FALSE, 12 | quiet = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{email}{A character of length 1. The email address of the project 17 | maintainer.} 18 | 19 | \item{organisation}{A character of length 1. The name of the GitHub 20 | organisation to host the package. If \code{NULL} (default) the GitHub account 21 | will be used. This argument is used to set the URL of the package 22 | (hosted on GitHub).} 23 | 24 | \item{open}{A logical value. If \code{TRUE} (default) the \code{CONTRIBUTING.md} file 25 | is opened in the editor.} 26 | 27 | \item{overwrite}{A logical value. If files are already present and 28 | \code{overwrite = TRUE}, they will be erased and replaced. Default is \code{FALSE}.} 29 | 30 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 31 | \code{FALSE}.} 32 | } 33 | \value{ 34 | No return value. 35 | } 36 | \description{ 37 | This function creates several files to help the user to learn how to 38 | contribute to the project: 39 | \itemize{ 40 | \item \code{CONTRIBUTING.md}: general guidelines outlining the best way to contribute 41 | to the project (can be modified); 42 | \item \code{.github/ISSUE_TEMPLATE/bug_report.md}: an issue template to report a bug 43 | (can be modified); 44 | \item \code{.github/ISSUE_TEMPLATE/feature_request.md}: an issue template to suggest 45 | a new feature (can be modified); 46 | \item \code{.github/ISSUE_TEMPLATE/other_issue.md}: an issue template for all other 47 | types of issue (can be modified). 48 | } 49 | } 50 | \examples{ 51 | \dontrun{ 52 | add_contributing() 53 | } 54 | } 55 | \seealso{ 56 | Other create files: 57 | \code{\link{add_citation}()}, 58 | \code{\link{add_code_of_conduct}()}, 59 | \code{\link{add_compendium}()}, 60 | \code{\link{add_description}()}, 61 | \code{\link{add_dockerfile}()}, 62 | \code{\link{add_license}()}, 63 | \code{\link{add_makefile}()}, 64 | \code{\link{add_package_doc}()}, 65 | \code{\link{add_readme_rmd}()}, 66 | \code{\link{add_renv}()}, 67 | \code{\link{add_testthat}()}, 68 | \code{\link{add_vignette}()} 69 | } 70 | \concept{create files} 71 | -------------------------------------------------------------------------------- /man/add_cran_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_cran_badge.R 3 | \name{add_cran_badge} 4 | \alias{add_cran_badge} 5 | \title{Add a CRAN Status badge} 6 | \usage{ 7 | add_cran_badge(quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 11 | \code{FALSE}.} 12 | } 13 | \value{ 14 | A badge as a markdown expression. 15 | } 16 | \description{ 17 | This function adds a \strong{CRAN Status} badge to the \code{README.Rmd}. If the 18 | package is not hosted on the CRAN the badge will indicate 19 | \emph{not published on the CRAN}. 20 | 21 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 22 | contains a block starting with the line \verb{} and ending 23 | with the line \verb{}. 24 | 25 | Don't forget to re-render the \code{README.md}. 26 | } 27 | \examples{ 28 | \dontrun{ 29 | add_cran_badge() 30 | } 31 | } 32 | \seealso{ 33 | Other adding badges: 34 | \code{\link{add_codecov_badge}()}, 35 | \code{\link{add_dependencies_badge}()}, 36 | \code{\link{add_github_actions_check_badge}()}, 37 | \code{\link{add_github_actions_codecov_badge}()}, 38 | \code{\link{add_github_actions_pkgdown_badge}()}, 39 | \code{\link{add_license_badge}()}, 40 | \code{\link{add_lifecycle_badge}()}, 41 | \code{\link{add_repostatus_badge}()} 42 | } 43 | \concept{adding badges} 44 | -------------------------------------------------------------------------------- /man/add_dependencies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_dependencies.R 3 | \name{add_dependencies} 4 | \alias{add_dependencies} 5 | \title{Add dependencies in DESCRIPTION} 6 | \usage{ 7 | add_dependencies(compendium = NULL) 8 | } 9 | \arguments{ 10 | \item{compendium}{A character of length 1. The name of the folder to 11 | recursively detect dependencies to be added to the \code{Imports} field of 12 | \code{DESCRIPTION} file. It can be \code{'analysis/'} (if additional folders, i.e. 13 | \verb{data/}, \verb{outputs/}, \verb{figures/}, etc. have been created in this folder), 14 | \code{'.'} (if folders \verb{data/}, \verb{outputs/}, \verb{figures/}, etc. have been created 15 | at the root of the project), etc. 16 | See \code{\link[=new_compendium]{new_compendium()}} for further information. 17 | 18 | Default is \code{compendium = NULL} (i.e. no additional folder are inspected 19 | but \verb{R/}, \code{NAMESPACE}, \verb{vignettes/}, and \verb{tests/} are still inspected).} 20 | } 21 | \value{ 22 | No return value. 23 | } 24 | \description{ 25 | This function detects external dependencies used in \verb{R/}, \code{NAMESPACE}, and 26 | \verb{@examples} sections of \code{roxygen2} headers and automatically adds these 27 | dependencies in the \code{Imports} section of the \code{DESCRIPTION} file. 28 | 29 | In the \code{NAMESPACE} this function detects dependencies mentioned as 30 | \code{import(pkg)} and \code{importFrom(pkg,fun)}. 31 | 32 | In the \verb{R/} folder it detects functions called as \code{pkg::fun()} in the code 33 | of each R files. In \verb{@examples} sections it also detects packages attached 34 | by \code{library()} or \code{require()}. 35 | 36 | The \verb{vignettes/} folder is also inspected and detected dependencies 37 | (\code{pkg::fun()}, \code{library()} or \code{require()}) are added to the \code{Suggests} 38 | field of the \code{DESCRIPTION} file (in addition to the packages 39 | \href{https://yihui.org/knitr/}{\code{knitr}} and 40 | \href{https://rmarkdown.rstudio.com/}{\code{rmarkdown}}). 41 | 42 | If the project is a research compendium user can also inspect additional 43 | folder(s) with the argument \code{compendium} to add dependencies to the 44 | \code{Imports} section of the \code{DESCRIPTION} file. The detection process is the 45 | same as the one used for \verb{vignettes/}. 46 | 47 | The \verb{tests/} folder is also inspected and detected dependencies 48 | (\code{pkg::fun()}, \code{library()} or \code{require()}) are added to the \code{Suggests} 49 | field of the \code{DESCRIPTION} file (in addition to the package 50 | \href{https://testthat.r-lib.org}{\code{testthat}}). 51 | } 52 | \examples{ 53 | \dontrun{ 54 | add_dependencies() 55 | } 56 | } 57 | \seealso{ 58 | Other development functions: 59 | \code{\link{add_github_actions_check}()}, 60 | \code{\link{add_github_actions_citation}()}, 61 | \code{\link{add_github_actions_codecov}()}, 62 | \code{\link{add_github_actions_codemeta}()}, 63 | \code{\link{add_github_actions_document}()}, 64 | \code{\link{add_github_actions_pkgdown}()}, 65 | \code{\link{add_github_actions_render}()}, 66 | \code{\link{add_r_depend}()}, 67 | \code{\link{add_to_buildignore}()}, 68 | \code{\link{add_to_gitignore}()} 69 | } 70 | \concept{development functions} 71 | -------------------------------------------------------------------------------- /man/add_dependencies_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_dependencies_badge.R 3 | \name{add_dependencies_badge} 4 | \alias{add_dependencies_badge} 5 | \title{Add a Dependencies badge} 6 | \usage{ 7 | add_dependencies_badge(quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 11 | \code{FALSE}.} 12 | } 13 | \value{ 14 | A badge as a markdown expression. 15 | } 16 | \description{ 17 | This function adds or updates the \strong{Dependencies} badge to the \code{README.Rmd}. 18 | The first number corresponds to the direct dependencies and the second to the 19 | recursive dependencies. 20 | 21 | \strong{Note:} this function can work with packages not published on the CRAN 22 | and is based on the function \code{\link[gtools:getDependencies]{gtools::getDependencies()}}. See also the 23 | function \code{\link[=get_all_dependencies]{get_all_dependencies()}}. 24 | 25 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 26 | contains a block starting with the line \verb{} and ending 27 | with the line \verb{}. 28 | 29 | Don't forget to re-render the \code{README.md}. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_dependencies_badge() 34 | } 35 | } 36 | \seealso{ 37 | Other adding badges: 38 | \code{\link{add_codecov_badge}()}, 39 | \code{\link{add_cran_badge}()}, 40 | \code{\link{add_github_actions_check_badge}()}, 41 | \code{\link{add_github_actions_codecov_badge}()}, 42 | \code{\link{add_github_actions_pkgdown_badge}()}, 43 | \code{\link{add_license_badge}()}, 44 | \code{\link{add_lifecycle_badge}()}, 45 | \code{\link{add_repostatus_badge}()} 46 | } 47 | \concept{adding badges} 48 | -------------------------------------------------------------------------------- /man/add_description.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_description.R 3 | \name{add_description} 4 | \alias{add_description} 5 | \title{Create a DESCRIPTION file} 6 | \usage{ 7 | add_description( 8 | given = NULL, 9 | family = NULL, 10 | email = NULL, 11 | orcid = NULL, 12 | organisation = NULL, 13 | open = TRUE, 14 | overwrite = FALSE, 15 | quiet = FALSE 16 | ) 17 | } 18 | \arguments{ 19 | \item{given}{A character of length 1. The given name of the project 20 | maintainer.} 21 | 22 | \item{family}{A character of length 1. The family name of the project 23 | maintainer.} 24 | 25 | \item{email}{A character of length 1. The email address of the project 26 | maintainer.} 27 | 28 | \item{orcid}{A character of length 1. The ORCID of the project maintainer.} 29 | 30 | \item{organisation}{A character of length 1. The name of the GitHub 31 | organisation to host the package. If \code{NULL} (default) the GitHub account 32 | will be used.} 33 | 34 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 35 | editor.} 36 | 37 | \item{overwrite}{A logical value. If a \code{DESCRIPTION} is already present and 38 | \code{overwrite = TRUE}, this file will be erased and replaced. Default is 39 | \code{FALSE}.} 40 | 41 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 42 | \code{FALSE}.} 43 | } 44 | \value{ 45 | No return value. 46 | } 47 | \description{ 48 | This function creates a \code{DESCRIPTION} file at the root of the project. This 49 | file contains metadata of the project. Some information (title, description, 50 | version, etc.) must be edited by hand. For more information: 51 | \url{https://r-pkgs.org/description.html}. 52 | User credentials can be passed as arguments but it is recommended to store 53 | them in the \code{.Rprofile} file with \code{\link[=set_credentials]{set_credentials()}}. 54 | } 55 | \examples{ 56 | \dontrun{ 57 | add_description(organisation = "MySociety") 58 | } 59 | } 60 | \seealso{ 61 | Other create files: 62 | \code{\link{add_citation}()}, 63 | \code{\link{add_code_of_conduct}()}, 64 | \code{\link{add_compendium}()}, 65 | \code{\link{add_contributing}()}, 66 | \code{\link{add_dockerfile}()}, 67 | \code{\link{add_license}()}, 68 | \code{\link{add_makefile}()}, 69 | \code{\link{add_package_doc}()}, 70 | \code{\link{add_readme_rmd}()}, 71 | \code{\link{add_renv}()}, 72 | \code{\link{add_testthat}()}, 73 | \code{\link{add_vignette}()} 74 | } 75 | \concept{create files} 76 | -------------------------------------------------------------------------------- /man/add_dockerfile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_dockerfile.R 3 | \name{add_dockerfile} 4 | \alias{add_dockerfile} 5 | \title{Create a Dockerfile} 6 | \usage{ 7 | add_dockerfile( 8 | given = NULL, 9 | family = NULL, 10 | email = NULL, 11 | open = TRUE, 12 | overwrite = FALSE, 13 | quiet = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{given}{A character of length 1. The given name of the project 18 | maintainer.} 19 | 20 | \item{family}{A character of length 1. The family name of the project 21 | maintainer.} 22 | 23 | \item{email}{A character of length 1. The email address of the project 24 | maintainer.} 25 | 26 | \item{open}{A logical value. If \code{TRUE} (default) the \code{Dockerfile} is opened 27 | in the editor.} 28 | 29 | \item{overwrite}{A logical value. If this file is already present and 30 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 31 | 32 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 33 | \code{FALSE}.} 34 | } 35 | \value{ 36 | No return value. 37 | } 38 | \description{ 39 | This function creates a \code{Dockerfile} at the root of the project based on a 40 | template. The Docker image is based on 41 | \href{https://hub.docker.com/r/rocker/rstudio}{rocker/rstudio}. The whole project 42 | will be copied in the image and R packages will be installed (using 43 | \code{\link[renv:restore]{renv::restore()}} or \code{\link[remotes:install_deps]{remotes::install_deps()}}). 44 | 45 | In addition a \code{.dockerignore} file is added to ignore some files/folders 46 | while building the image. 47 | 48 | User can customize this \code{Dockerfile} (e.g. system dependencies). He/she 49 | can also use a different default Docker image (i.e. \code{tidyverse}, \code{verse}, 50 | \code{geospatial}, etc.). For more information: 51 | https://github.com/rocker-org/rocker-versioned2 52 | 53 | By default the versions of R and \code{renv} (if applicable) specified in the 54 | \code{Dockerfile} are the same as the local system. 55 | 56 | Once the project is ready to be released, user must build the Docker image by 57 | running: \verb{docker build -t "image_name" .} 58 | 59 | Then to run a container, user must run: 60 | \verb{docker run --rm -p 127.0.0.1:8787:8787 -e DISABLE_AUTH=true image_name} 61 | 62 | A new instance of RStudio Server is available on the Web browser at the URL: 63 | \verb{127.0.0.1:8787}. 64 | } 65 | \examples{ 66 | \dontrun{ 67 | add_dockerfile() 68 | } 69 | } 70 | \seealso{ 71 | Other create files: 72 | \code{\link{add_citation}()}, 73 | \code{\link{add_code_of_conduct}()}, 74 | \code{\link{add_compendium}()}, 75 | \code{\link{add_contributing}()}, 76 | \code{\link{add_description}()}, 77 | \code{\link{add_license}()}, 78 | \code{\link{add_makefile}()}, 79 | \code{\link{add_package_doc}()}, 80 | \code{\link{add_readme_rmd}()}, 81 | \code{\link{add_renv}()}, 82 | \code{\link{add_testthat}()}, 83 | \code{\link{add_vignette}()} 84 | } 85 | \concept{create files} 86 | -------------------------------------------------------------------------------- /man/add_github_actions_check.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_check.R 3 | \name{add_github_actions_check} 4 | \alias{add_github_actions_check} 5 | \title{Setup GitHub Actions to check package} 6 | \usage{ 7 | add_github_actions_check(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to check the package. 25 | This workflow is derived 26 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 27 | This file will be written as \code{.github/workflows/R-CMD-check.yaml}. 28 | } 29 | \details{ 30 | This workflow runs \verb{R CMD check} on the three major operating systems 31 | (Ubuntu, macOS, and Windows) using the latest release of R. The package is 32 | also checked on Ubuntu (latest version) using the development and previous 33 | versions of R. 34 | } 35 | \examples{ 36 | \dontrun{ 37 | add_github_actions_check() 38 | } 39 | } 40 | \seealso{ 41 | Other development functions: 42 | \code{\link{add_dependencies}()}, 43 | \code{\link{add_github_actions_citation}()}, 44 | \code{\link{add_github_actions_codecov}()}, 45 | \code{\link{add_github_actions_codemeta}()}, 46 | \code{\link{add_github_actions_document}()}, 47 | \code{\link{add_github_actions_pkgdown}()}, 48 | \code{\link{add_github_actions_render}()}, 49 | \code{\link{add_r_depend}()}, 50 | \code{\link{add_to_buildignore}()}, 51 | \code{\link{add_to_gitignore}()} 52 | } 53 | \concept{development functions} 54 | -------------------------------------------------------------------------------- /man/add_github_actions_check_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_check_badge.R 3 | \name{add_github_actions_check_badge} 4 | \alias{add_github_actions_check_badge} 5 | \title{Add a R CMD Check badge} 6 | \usage{ 7 | add_github_actions_check_badge(organisation = NULL, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{organisation}{A character of length 1. The name of the GitHub 11 | organisation to host the package. If \code{NULL} (default) the GitHub account 12 | will be used.} 13 | 14 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 15 | \code{FALSE}.} 16 | } 17 | \value{ 18 | A badge as a markdown expression. 19 | } 20 | \description{ 21 | This function adds a \strong{R CMD Check} badge to the \code{README.Rmd}. This function 22 | must be run after \code{\link[=add_github_actions_check]{add_github_actions_check()}} which will setup GitHub 23 | Actions to check and test the package. 24 | 25 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 26 | contains a block starting with the line \verb{} and ending 27 | with the line \verb{}. 28 | 29 | Don't forget to re-render the \code{README.md}. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_github_actions_check_badge() 34 | } 35 | } 36 | \seealso{ 37 | Other adding badges: 38 | \code{\link{add_codecov_badge}()}, 39 | \code{\link{add_cran_badge}()}, 40 | \code{\link{add_dependencies_badge}()}, 41 | \code{\link{add_github_actions_codecov_badge}()}, 42 | \code{\link{add_github_actions_pkgdown_badge}()}, 43 | \code{\link{add_license_badge}()}, 44 | \code{\link{add_lifecycle_badge}()}, 45 | \code{\link{add_repostatus_badge}()} 46 | } 47 | \concept{adding badges} 48 | -------------------------------------------------------------------------------- /man/add_github_actions_citation.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_citation.R 3 | \name{add_github_actions_citation} 4 | \alias{add_github_actions_citation} 5 | \title{Setup GitHub Actions to update CITATION.cff} 6 | \usage{ 7 | add_github_actions_citation(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to update the \code{CITATION.cff}. 25 | This workflow is derived 26 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 27 | This file will be written as \code{.github/workflows/update-citation-cff.yaml}. 28 | 29 | This function also create the \code{CITATION.cff} using the package \link{cffr}. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_github_actions_citation() 34 | } 35 | } 36 | \seealso{ 37 | Other development functions: 38 | \code{\link{add_dependencies}()}, 39 | \code{\link{add_github_actions_check}()}, 40 | \code{\link{add_github_actions_codecov}()}, 41 | \code{\link{add_github_actions_codemeta}()}, 42 | \code{\link{add_github_actions_document}()}, 43 | \code{\link{add_github_actions_pkgdown}()}, 44 | \code{\link{add_github_actions_render}()}, 45 | \code{\link{add_r_depend}()}, 46 | \code{\link{add_to_buildignore}()}, 47 | \code{\link{add_to_gitignore}()} 48 | } 49 | \concept{development functions} 50 | -------------------------------------------------------------------------------- /man/add_github_actions_codecov.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_codecov.R 3 | \name{add_github_actions_codecov} 4 | \alias{add_github_actions_codecov} 5 | \title{Setup GitHub Actions to report code coverage} 6 | \usage{ 7 | add_github_actions_codecov(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to report code coverage when testing the package. 25 | This workflow is derived 26 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 27 | This file will be written as \code{.github/workflows/test-coverage.yaml}. 28 | } 29 | \examples{ 30 | \dontrun{ 31 | add_github_actions_codecov() 32 | } 33 | } 34 | \seealso{ 35 | Other development functions: 36 | \code{\link{add_dependencies}()}, 37 | \code{\link{add_github_actions_check}()}, 38 | \code{\link{add_github_actions_citation}()}, 39 | \code{\link{add_github_actions_codemeta}()}, 40 | \code{\link{add_github_actions_document}()}, 41 | \code{\link{add_github_actions_pkgdown}()}, 42 | \code{\link{add_github_actions_render}()}, 43 | \code{\link{add_r_depend}()}, 44 | \code{\link{add_to_buildignore}()}, 45 | \code{\link{add_to_gitignore}()} 46 | } 47 | \concept{development functions} 48 | -------------------------------------------------------------------------------- /man/add_github_actions_codecov_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_codecov_badge.R 3 | \name{add_github_actions_codecov_badge} 4 | \alias{add_github_actions_codecov_badge} 5 | \title{Add a Test coverage badge} 6 | \usage{ 7 | add_github_actions_codecov_badge(organisation = NULL, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{organisation}{A character of length 1. The name of the GitHub 11 | organisation to host the package. If \code{NULL} (default) the GitHub account 12 | will be used.} 13 | 14 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 15 | \code{FALSE}.} 16 | } 17 | \value{ 18 | A badge as a markdown expression. 19 | } 20 | \description{ 21 | This function adds a \strong{Test coverage} badge to the \code{README.Rmd}. This 22 | function must be run after \code{\link[=add_github_actions_codecov]{add_github_actions_codecov()}} which will setup 23 | GitHub Actions to report the percentage of code cover by units tests. 24 | 25 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 26 | contains a block starting with the line \verb{} and ending 27 | with the line \verb{}. 28 | 29 | Don't forget to re-render the \code{README.md}. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_github_actions_codecov_badge() 34 | } 35 | } 36 | \seealso{ 37 | Other adding badges: 38 | \code{\link{add_codecov_badge}()}, 39 | \code{\link{add_cran_badge}()}, 40 | \code{\link{add_dependencies_badge}()}, 41 | \code{\link{add_github_actions_check_badge}()}, 42 | \code{\link{add_github_actions_pkgdown_badge}()}, 43 | \code{\link{add_license_badge}()}, 44 | \code{\link{add_lifecycle_badge}()}, 45 | \code{\link{add_repostatus_badge}()} 46 | } 47 | \concept{adding badges} 48 | -------------------------------------------------------------------------------- /man/add_github_actions_codemeta.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_codemeta.R 3 | \name{add_github_actions_codemeta} 4 | \alias{add_github_actions_codemeta} 5 | \title{Setup GitHub Actions to update codemeta.json} 6 | \usage{ 7 | add_github_actions_codemeta(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to update the \code{codemeta.json}. 25 | This workflow is derived 26 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 27 | This file will be written as \code{.github/workflows/update-citation-cff.yaml}. 28 | 29 | This function also create the \code{codemeta.json} using the package \link{codemetar}. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_github_actions_codemeta() 34 | } 35 | } 36 | \seealso{ 37 | Other development functions: 38 | \code{\link{add_dependencies}()}, 39 | \code{\link{add_github_actions_check}()}, 40 | \code{\link{add_github_actions_citation}()}, 41 | \code{\link{add_github_actions_codecov}()}, 42 | \code{\link{add_github_actions_document}()}, 43 | \code{\link{add_github_actions_pkgdown}()}, 44 | \code{\link{add_github_actions_render}()}, 45 | \code{\link{add_r_depend}()}, 46 | \code{\link{add_to_buildignore}()}, 47 | \code{\link{add_to_gitignore}()} 48 | } 49 | \concept{development functions} 50 | -------------------------------------------------------------------------------- /man/add_github_actions_document.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_document.R 3 | \name{add_github_actions_document} 4 | \alias{add_github_actions_document} 5 | \title{Setup GitHub Actions to document package} 6 | \usage{ 7 | add_github_actions_document(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to document the package and update the \code{Rd} files in the \verb{man/}, the 25 | \code{NAMESPACE} and \code{DESCRIPTION} files. 26 | This workflow is derived 27 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 28 | This file will be written as \code{.github/workflows/document-package.yaml}. 29 | } 30 | \examples{ 31 | \dontrun{ 32 | add_github_actions_document() 33 | } 34 | } 35 | \seealso{ 36 | Other development functions: 37 | \code{\link{add_dependencies}()}, 38 | \code{\link{add_github_actions_check}()}, 39 | \code{\link{add_github_actions_citation}()}, 40 | \code{\link{add_github_actions_codecov}()}, 41 | \code{\link{add_github_actions_codemeta}()}, 42 | \code{\link{add_github_actions_pkgdown}()}, 43 | \code{\link{add_github_actions_render}()}, 44 | \code{\link{add_r_depend}()}, 45 | \code{\link{add_to_buildignore}()}, 46 | \code{\link{add_to_gitignore}()} 47 | } 48 | \concept{development functions} 49 | -------------------------------------------------------------------------------- /man/add_github_actions_pkgdown.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_pkgdown.R 3 | \name{add_github_actions_pkgdown} 4 | \alias{add_github_actions_pkgdown} 5 | \title{Setup GitHub Actions to build and deploy package website} 6 | \usage{ 7 | add_github_actions_pkgdown(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to automatically build and deploy the website using 25 | \href{https://pkgdown.r-lib.org/index.html}{\code{pkgdown}}. This workflow is derived 26 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 27 | This file will be written as \code{.github/workflows/pkgdown.yaml}. 28 | An additional empty file (\verb{_pkgdown.yaml}) will also be written: it can be 29 | used to customize the website. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_github_actions_pkgdown() 34 | } 35 | } 36 | \seealso{ 37 | Other development functions: 38 | \code{\link{add_dependencies}()}, 39 | \code{\link{add_github_actions_check}()}, 40 | \code{\link{add_github_actions_citation}()}, 41 | \code{\link{add_github_actions_codecov}()}, 42 | \code{\link{add_github_actions_codemeta}()}, 43 | \code{\link{add_github_actions_document}()}, 44 | \code{\link{add_github_actions_render}()}, 45 | \code{\link{add_r_depend}()}, 46 | \code{\link{add_to_buildignore}()}, 47 | \code{\link{add_to_gitignore}()} 48 | } 49 | \concept{development functions} 50 | -------------------------------------------------------------------------------- /man/add_github_actions_pkgdown_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_pkgdown_badge.R 3 | \name{add_github_actions_pkgdown_badge} 4 | \alias{add_github_actions_pkgdown_badge} 5 | \title{Add a Website badge} 6 | \usage{ 7 | add_github_actions_pkgdown_badge(organisation = NULL, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{organisation}{A character of length 1. The name of the GitHub 11 | organisation to host the package. If \code{NULL} (default) the GitHub account 12 | will be used.} 13 | 14 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 15 | \code{FALSE}.} 16 | } 17 | \value{ 18 | A badge as a markdown expression. 19 | } 20 | \description{ 21 | This function adds a \strong{Website} badge to the \code{README.Rmd}. This function 22 | must be run after \code{\link[=add_github_actions_pkgdown]{add_github_actions_pkgdown()}} which will setup 23 | GitHub Actions to build and deploy the package website. 24 | 25 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 26 | contains a block starting with the line \verb{} and ending 27 | with the line \verb{}. 28 | 29 | Don't forget to re-render the \code{README.md}. 30 | } 31 | \examples{ 32 | \dontrun{ 33 | add_github_actions_pkgdown_badge() 34 | } 35 | } 36 | \seealso{ 37 | Other adding badges: 38 | \code{\link{add_codecov_badge}()}, 39 | \code{\link{add_cran_badge}()}, 40 | \code{\link{add_dependencies_badge}()}, 41 | \code{\link{add_github_actions_check_badge}()}, 42 | \code{\link{add_github_actions_codecov_badge}()}, 43 | \code{\link{add_license_badge}()}, 44 | \code{\link{add_lifecycle_badge}()}, 45 | \code{\link{add_repostatus_badge}()} 46 | } 47 | \concept{adding badges} 48 | -------------------------------------------------------------------------------- /man/add_github_actions_render.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_github_actions_render.R 3 | \name{add_github_actions_render} 4 | \alias{add_github_actions_render} 5 | \title{Setup GitHub Actions to render README} 6 | \usage{ 7 | add_github_actions_render(open = FALSE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a configuration file (\code{.yaml}) to setup GitHub Actions 24 | to automatically knit the \code{README.Rmd} after a push. This workflow will be 25 | triggered only if the \code{README.Rmd} has been modified since the last commit. 26 | This workflow is derived 27 | from \url{https://github.com/r-lib/actions/tree/v2-branch/examples}. 28 | This file will be written as \code{.github/workflows/render-README.yaml}. 29 | } 30 | \examples{ 31 | \dontrun{ 32 | add_github_actions_render() 33 | } 34 | } 35 | \seealso{ 36 | Other development functions: 37 | \code{\link{add_dependencies}()}, 38 | \code{\link{add_github_actions_check}()}, 39 | \code{\link{add_github_actions_citation}()}, 40 | \code{\link{add_github_actions_codecov}()}, 41 | \code{\link{add_github_actions_codemeta}()}, 42 | \code{\link{add_github_actions_document}()}, 43 | \code{\link{add_github_actions_pkgdown}()}, 44 | \code{\link{add_r_depend}()}, 45 | \code{\link{add_to_buildignore}()}, 46 | \code{\link{add_to_gitignore}()} 47 | } 48 | \concept{development functions} 49 | -------------------------------------------------------------------------------- /man/add_license.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_license.R 3 | \name{add_license} 4 | \alias{add_license} 5 | \title{Add a LICENSE} 6 | \usage{ 7 | add_license(license = NULL, given = NULL, family = NULL, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{license}{A character of length 1. The chosen license. 11 | Run \code{\link[=get_licenses]{get_licenses()}}) to select an appropriate one.} 12 | 13 | \item{given}{A character of length 1. The given name of the copyright holder. 14 | Only required if \code{license = 'MIT'}. If is \code{NULL} (default) and 15 | \code{license = 'MIT'}, this function will try to retrieve the value of this 16 | parameter from the \code{.Rprofile} file (edited with \code{\link[=set_credentials]{set_credentials()}}).} 17 | 18 | \item{family}{A character of length 1. The family name of the copyright 19 | holder. Only required if \code{license = 'MIT'}. If is \code{NULL} (default) and 20 | \code{license = 'MIT'}, this function will try to retrieve the value of this 21 | parameter from the \code{.Rprofile} file (edited with \code{\link[=set_credentials]{set_credentials()}}).} 22 | 23 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 24 | \code{FALSE}.} 25 | } 26 | \value{ 27 | No return value. 28 | } 29 | \description{ 30 | This function adds a license to the project. It will add the license name 31 | in the \code{License} field of the \code{DESCRIPTION} file and write the content of 32 | the license in the \code{License.md} file. 33 | } 34 | \examples{ 35 | \dontrun{ 36 | add_license(license = "MIT") 37 | add_license(license = "GPL (>= 2)") 38 | } 39 | } 40 | \seealso{ 41 | Other create files: 42 | \code{\link{add_citation}()}, 43 | \code{\link{add_code_of_conduct}()}, 44 | \code{\link{add_compendium}()}, 45 | \code{\link{add_contributing}()}, 46 | \code{\link{add_description}()}, 47 | \code{\link{add_dockerfile}()}, 48 | \code{\link{add_makefile}()}, 49 | \code{\link{add_package_doc}()}, 50 | \code{\link{add_readme_rmd}()}, 51 | \code{\link{add_renv}()}, 52 | \code{\link{add_testthat}()}, 53 | \code{\link{add_vignette}()} 54 | } 55 | \concept{create files} 56 | -------------------------------------------------------------------------------- /man/add_license_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_license_badge.R 3 | \name{add_license_badge} 4 | \alias{add_license_badge} 5 | \title{Add a License badge} 6 | \usage{ 7 | add_license_badge(quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 11 | \code{FALSE}.} 12 | } 13 | \value{ 14 | A badge as a markdown expression. 15 | } 16 | \description{ 17 | This function adds or updates the \strong{License} badge to the \code{README.Rmd}. 18 | This function reads the \code{License} field of the \code{DESCRIPTION} file. Ensure 19 | that this field is correctly defined. See \code{\link[=add_license]{add_license()}} for further detail. 20 | 21 | This function requires the presence of a \code{DESCRIPTION} file at the project 22 | root. See \code{\link[=add_description]{add_description()}} for further detail. 23 | 24 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 25 | contains a block starting with the line \verb{} and ending 26 | with the line \verb{}. 27 | 28 | Don't forget to re-render the \code{README.md}. 29 | } 30 | \examples{ 31 | \dontrun{ 32 | add_license_badge() 33 | } 34 | } 35 | \seealso{ 36 | Other adding badges: 37 | \code{\link{add_codecov_badge}()}, 38 | \code{\link{add_cran_badge}()}, 39 | \code{\link{add_dependencies_badge}()}, 40 | \code{\link{add_github_actions_check_badge}()}, 41 | \code{\link{add_github_actions_codecov_badge}()}, 42 | \code{\link{add_github_actions_pkgdown_badge}()}, 43 | \code{\link{add_lifecycle_badge}()}, 44 | \code{\link{add_repostatus_badge}()} 45 | } 46 | \concept{adding badges} 47 | -------------------------------------------------------------------------------- /man/add_lifecycle_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_lifecycle_badge.R 3 | \name{add_lifecycle_badge} 4 | \alias{add_lifecycle_badge} 5 | \title{Add a Life Cycle badge} 6 | \usage{ 7 | add_lifecycle_badge(lifecycle = "experimental", quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{lifecycle}{A character of length 1. Accepted stages are: 11 | \code{'experimental'} (default), \code{'stable'}, \code{'deprecated'}, or \code{'superseded'}.} 12 | 13 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 14 | \code{FALSE}.} 15 | } 16 | \value{ 17 | A badge as a markdown expression. 18 | } 19 | \description{ 20 | This function adds or updates the \strong{Life Cycle} badge to the \code{README.Rmd}. 21 | It is based on the standard defined at 22 | \url{https://lifecycle.r-lib.org/articles/stages.html}. 23 | 24 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 25 | contains a block starting with the line \verb{} and ending 26 | with the line \verb{}. 27 | 28 | Don't forget to re-render the \code{README.md}. 29 | } 30 | \details{ 31 | The project can have the following life cycle stage: 32 | \itemize{ 33 | \item \strong{Experimental} - An experimental project is made available so user 34 | can try it out and provide feedback, but come with no promises for long 35 | term stability. 36 | \item \strong{Stable} - A project is considered stable when the author is happy 37 | with its interface, does not see major issues, and is happy to share it 38 | with the world. 39 | \item \strong{Superseded} - A superseded project has a known better 40 | alternative, and it is not going away. Superseded project will not receive 41 | new features, but will receive any critical bug fixes needed to keep it 42 | working. 43 | \item \strong{Deprecated} - A deprecated project has a better alternative 44 | available and is scheduled for removal. 45 | } 46 | } 47 | \examples{ 48 | \dontrun{ 49 | add_lifecycle_badge() 50 | add_lifecycle_badge(lifecycle = "stable") 51 | } 52 | } 53 | \seealso{ 54 | Other adding badges: 55 | \code{\link{add_codecov_badge}()}, 56 | \code{\link{add_cran_badge}()}, 57 | \code{\link{add_dependencies_badge}()}, 58 | \code{\link{add_github_actions_check_badge}()}, 59 | \code{\link{add_github_actions_codecov_badge}()}, 60 | \code{\link{add_github_actions_pkgdown_badge}()}, 61 | \code{\link{add_license_badge}()}, 62 | \code{\link{add_repostatus_badge}()} 63 | } 64 | \concept{adding badges} 65 | -------------------------------------------------------------------------------- /man/add_makefile.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_makefile.R 3 | \name{add_makefile} 4 | \alias{add_makefile} 5 | \title{Create a Make-like R file} 6 | \usage{ 7 | add_makefile( 8 | given = NULL, 9 | family = NULL, 10 | email = NULL, 11 | open = TRUE, 12 | overwrite = FALSE, 13 | quiet = FALSE 14 | ) 15 | } 16 | \arguments{ 17 | \item{given}{A character of length 1. The given name of the project 18 | maintainer.} 19 | 20 | \item{family}{A character of length 1. The family name of the project 21 | maintainer.} 22 | 23 | \item{email}{A character of length 1. The email address of the project 24 | maintainer.} 25 | 26 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 27 | editor.} 28 | 29 | \item{overwrite}{A logical value. If this file is already present and 30 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 31 | 32 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 33 | \code{FALSE}.} 34 | } 35 | \value{ 36 | No return value. 37 | } 38 | \description{ 39 | This function creates a Make-like R file (\code{make.R}) at the root of the 40 | project based on a template. To be used only if the project is a research 41 | compendium. The content of this file provides some guidelines. See also 42 | \code{\link[=new_compendium]{new_compendium()}} for further information. 43 | } 44 | \examples{ 45 | \dontrun{ 46 | add_makefile() 47 | } 48 | } 49 | \seealso{ 50 | Other create files: 51 | \code{\link{add_citation}()}, 52 | \code{\link{add_code_of_conduct}()}, 53 | \code{\link{add_compendium}()}, 54 | \code{\link{add_contributing}()}, 55 | \code{\link{add_description}()}, 56 | \code{\link{add_dockerfile}()}, 57 | \code{\link{add_license}()}, 58 | \code{\link{add_package_doc}()}, 59 | \code{\link{add_readme_rmd}()}, 60 | \code{\link{add_renv}()}, 61 | \code{\link{add_testthat}()}, 62 | \code{\link{add_vignette}()} 63 | } 64 | \concept{create files} 65 | -------------------------------------------------------------------------------- /man/add_package_doc.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_package_doc.R 3 | \name{add_package_doc} 4 | \alias{add_package_doc} 5 | \title{Create a package-level documentation file} 6 | \usage{ 7 | add_package_doc(open = TRUE, overwrite = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 11 | editor.} 12 | 13 | \item{overwrite}{A logical value. If this file is already present and 14 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function adds a package-level documentation file (\code{pkg-package.R}) in 24 | the \verb{R/} folder. This file will make help available to the user via \code{?pkg} 25 | (where \code{pkg} is the name of the package). It a good place to put general 26 | directives like \verb{@import} and \verb{@importFrom}. 27 | } 28 | \examples{ 29 | \dontrun{ 30 | add_package_doc() 31 | } 32 | } 33 | \seealso{ 34 | Other create files: 35 | \code{\link{add_citation}()}, 36 | \code{\link{add_code_of_conduct}()}, 37 | \code{\link{add_compendium}()}, 38 | \code{\link{add_contributing}()}, 39 | \code{\link{add_description}()}, 40 | \code{\link{add_dockerfile}()}, 41 | \code{\link{add_license}()}, 42 | \code{\link{add_makefile}()}, 43 | \code{\link{add_readme_rmd}()}, 44 | \code{\link{add_renv}()}, 45 | \code{\link{add_testthat}()}, 46 | \code{\link{add_vignette}()} 47 | } 48 | \concept{create files} 49 | -------------------------------------------------------------------------------- /man/add_r_depend.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_r_depend.R 3 | \name{add_r_depend} 4 | \alias{add_r_depend} 5 | \title{Add minimal R version to DESCRIPTION} 6 | \usage{ 7 | add_r_depend() 8 | } 9 | \value{ 10 | No return value. 11 | } 12 | \description{ 13 | This function adds the minimal R version to the \code{Depends} field of the 14 | \code{DESCRIPTION} file. This version corresponds to the higher version of R 15 | among all dependencies. If no dependencies mentions minimal R version, the 16 | \code{DESCRIPTION} is not modified. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | add_r_depend() 21 | } 22 | } 23 | \seealso{ 24 | Other development functions: 25 | \code{\link{add_dependencies}()}, 26 | \code{\link{add_github_actions_check}()}, 27 | \code{\link{add_github_actions_citation}()}, 28 | \code{\link{add_github_actions_codecov}()}, 29 | \code{\link{add_github_actions_codemeta}()}, 30 | \code{\link{add_github_actions_document}()}, 31 | \code{\link{add_github_actions_pkgdown}()}, 32 | \code{\link{add_github_actions_render}()}, 33 | \code{\link{add_to_buildignore}()}, 34 | \code{\link{add_to_gitignore}()} 35 | } 36 | \concept{development functions} 37 | -------------------------------------------------------------------------------- /man/add_readme_rmd.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_readme_rmd.R 3 | \name{add_readme_rmd} 4 | \alias{add_readme_rmd} 5 | \title{Create a README file} 6 | \usage{ 7 | add_readme_rmd( 8 | type = "package", 9 | given = NULL, 10 | family = NULL, 11 | organisation = NULL, 12 | open = TRUE, 13 | overwrite = FALSE, 14 | quiet = FALSE 15 | ) 16 | } 17 | \arguments{ 18 | \item{type}{A character of length 1. If \code{package} (default) a GitHub 19 | \code{README.Rmd} specific to an R package will be created. If \code{compendium} a 20 | GitHub \code{README.Rmd} specific to a research compendium will be created.} 21 | 22 | \item{given}{A character of length 1. The given name of the project 23 | maintainer.} 24 | 25 | \item{family}{A character of length 1. The family name of the project 26 | maintainer.} 27 | 28 | \item{organisation}{A character of length 1. The name of the GitHub 29 | organisation to host the package. If \code{NULL} (default) the GitHub account 30 | will be used. This argument is used to set the URL of the package 31 | (hosted on GitHub).} 32 | 33 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 34 | editor.} 35 | 36 | \item{overwrite}{A logical value. If this file is already present and 37 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 38 | 39 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 40 | \code{FALSE}.} 41 | } 42 | \value{ 43 | No return value. 44 | } 45 | \description{ 46 | This function creates a \code{README.Rmd} file at the root of the project based 47 | on a template. Once edited user needs to knit it into a \code{README.md} 48 | (or use the function \code{\link[=refresh]{refresh()}}). 49 | } 50 | \examples{ 51 | \dontrun{ 52 | add_readme_rmd(type = "package") 53 | } 54 | } 55 | \seealso{ 56 | Other create files: 57 | \code{\link{add_citation}()}, 58 | \code{\link{add_code_of_conduct}()}, 59 | \code{\link{add_compendium}()}, 60 | \code{\link{add_contributing}()}, 61 | \code{\link{add_description}()}, 62 | \code{\link{add_dockerfile}()}, 63 | \code{\link{add_license}()}, 64 | \code{\link{add_makefile}()}, 65 | \code{\link{add_package_doc}()}, 66 | \code{\link{add_renv}()}, 67 | \code{\link{add_testthat}()}, 68 | \code{\link{add_vignette}()} 69 | } 70 | \concept{create files} 71 | -------------------------------------------------------------------------------- /man/add_renv.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_renv.R 3 | \name{add_renv} 4 | \alias{add_renv} 5 | \title{Initialize renv} 6 | \usage{ 7 | add_renv(quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 11 | \code{FALSE}.} 12 | } 13 | \value{ 14 | No return value. 15 | } 16 | \description{ 17 | This function initializes an \code{renv} environment for the project by running 18 | \code{\link[renv:init]{renv::init()}}. See \url{https://rstudio.github.io/renv/} for further detail. 19 | } 20 | \examples{ 21 | \dontrun{ 22 | add_renv() 23 | } 24 | } 25 | \seealso{ 26 | Other create files: 27 | \code{\link{add_citation}()}, 28 | \code{\link{add_code_of_conduct}()}, 29 | \code{\link{add_compendium}()}, 30 | \code{\link{add_contributing}()}, 31 | \code{\link{add_description}()}, 32 | \code{\link{add_dockerfile}()}, 33 | \code{\link{add_license}()}, 34 | \code{\link{add_makefile}()}, 35 | \code{\link{add_package_doc}()}, 36 | \code{\link{add_readme_rmd}()}, 37 | \code{\link{add_testthat}()}, 38 | \code{\link{add_vignette}()} 39 | } 40 | \concept{create files} 41 | -------------------------------------------------------------------------------- /man/add_repostatus_badge.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_repostatus_badge.R 3 | \name{add_repostatus_badge} 4 | \alias{add_repostatus_badge} 5 | \title{Add a Repository Status badge} 6 | \usage{ 7 | add_repostatus_badge(status = "concept", quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{status}{A character of length 1. Accepted status are: \code{'concept'} 11 | (default), \code{'wip'}, \code{'suspended'}, \code{'abandoned'}, \code{'active'}, 12 | \code{'inactive'}, or \code{'unsupported'}.} 13 | 14 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 15 | \code{FALSE}.} 16 | } 17 | \value{ 18 | A badge as a markdown expression. 19 | } 20 | \description{ 21 | This function adds or updates the \strong{Repository Status} badge of the project 22 | to the \code{README.Rmd}. It is based on the standard defined by the 23 | \url{https://www.repostatus.org} project. 24 | 25 | Make sure that 1) a \code{README.Rmd} file exists at the project root and 2) it 26 | contains a block starting with the line \verb{} and ending 27 | with the line \verb{}. 28 | 29 | Don't forget to re-render the \code{README.md}. 30 | } 31 | \details{ 32 | The project can have the following status: 33 | \itemize{ 34 | \item \strong{Concept} - Minimal or no implementation has been done yet, or the 35 | repository is only intended to be a limited example, demo, or 36 | proof-of-concept. 37 | \item \strong{WIP} - Initial development is in progress, but there has not yet 38 | been a stable, usable release suitable for the public. 39 | \item \strong{Suspended} - Initial development has started, but there has not 40 | yet been a stable, usable release; work has been stopped for the time 41 | being but the author(s) intend on resuming work. 42 | \item \strong{Abandoned} - Initial development has started, but there has not 43 | yet been a stable, usable release; the project has been abandoned and the 44 | author(s) do not intend on continuing development. 45 | \item \strong{Active} - The project has reached a stable, usable state and is 46 | being actively developed. 47 | \item \strong{Inactive} - The project has reached a stable, usable state but is 48 | no longer being actively developed; support/maintenance will be provided 49 | as time allows. 50 | \item \strong{Unsupported} - The project has reached a stable, usable state but 51 | the author(s) have ceased all work on it. A new maintainer may be desired. 52 | } 53 | } 54 | \examples{ 55 | \dontrun{ 56 | add_repostatus_badge() 57 | add_repostatus_badge(status = "active") 58 | } 59 | } 60 | \seealso{ 61 | Other adding badges: 62 | \code{\link{add_codecov_badge}()}, 63 | \code{\link{add_cran_badge}()}, 64 | \code{\link{add_dependencies_badge}()}, 65 | \code{\link{add_github_actions_check_badge}()}, 66 | \code{\link{add_github_actions_codecov_badge}()}, 67 | \code{\link{add_github_actions_pkgdown_badge}()}, 68 | \code{\link{add_license_badge}()}, 69 | \code{\link{add_lifecycle_badge}()} 70 | } 71 | \concept{adding badges} 72 | -------------------------------------------------------------------------------- /man/add_testthat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_testthat.R 3 | \name{add_testthat} 4 | \alias{add_testthat} 5 | \title{Initialize units tests} 6 | \usage{ 7 | add_testthat() 8 | } 9 | \value{ 10 | No return value. 11 | } 12 | \description{ 13 | This function initializes units tests settings by running 14 | \code{\link[usethis:use_testthat]{usethis::use_testthat()}} and by adding an example units tests file 15 | \code{tests/testthat/test-demo.R}. The sample file will test a demo function 16 | created in \code{R/fun-demo.R}. 17 | } 18 | \examples{ 19 | \dontrun{ 20 | add_testthat() 21 | } 22 | } 23 | \seealso{ 24 | Other create files: 25 | \code{\link{add_citation}()}, 26 | \code{\link{add_code_of_conduct}()}, 27 | \code{\link{add_compendium}()}, 28 | \code{\link{add_contributing}()}, 29 | \code{\link{add_description}()}, 30 | \code{\link{add_dockerfile}()}, 31 | \code{\link{add_license}()}, 32 | \code{\link{add_makefile}()}, 33 | \code{\link{add_package_doc}()}, 34 | \code{\link{add_readme_rmd}()}, 35 | \code{\link{add_renv}()}, 36 | \code{\link{add_vignette}()} 37 | } 38 | \concept{create files} 39 | -------------------------------------------------------------------------------- /man/add_to_buildignore.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_to_buildignore.R 3 | \name{add_to_buildignore} 4 | \alias{add_to_buildignore} 5 | \title{Add to the .Rbuildignore file} 6 | \usage{ 7 | add_to_buildignore(x, open = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{A character vector. One or several files/folders names to be added 11 | to the \code{.Rbuildignore}. This argument is mandatory.} 12 | 13 | \item{open}{A logical value. If \code{TRUE} the \code{.Rbuildignore} file is opened in 14 | the editor. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function adds files/folders to the \code{.Rbuildignore} file. If a 24 | \code{.Rbuildignore} is already present, files to be ignored while checking 25 | package are just added to this file. Otherwise a new file is created. 26 | } 27 | \examples{ 28 | \dontrun{ 29 | add_to_buildignore(open = TRUE) 30 | add_to_buildignore(".DS_Store") 31 | } 32 | } 33 | \seealso{ 34 | Other development functions: 35 | \code{\link{add_dependencies}()}, 36 | \code{\link{add_github_actions_check}()}, 37 | \code{\link{add_github_actions_citation}()}, 38 | \code{\link{add_github_actions_codecov}()}, 39 | \code{\link{add_github_actions_codemeta}()}, 40 | \code{\link{add_github_actions_document}()}, 41 | \code{\link{add_github_actions_pkgdown}()}, 42 | \code{\link{add_github_actions_render}()}, 43 | \code{\link{add_r_depend}()}, 44 | \code{\link{add_to_gitignore}()} 45 | } 46 | \concept{development functions} 47 | -------------------------------------------------------------------------------- /man/add_to_gitignore.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_to_gitignore.R 3 | \name{add_to_gitignore} 4 | \alias{add_to_gitignore} 5 | \title{Add to the .gitignore file} 6 | \usage{ 7 | add_to_gitignore(x, open = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{A character vector. One or several files/folders names to be added 11 | to the \code{.gitignore}.} 12 | 13 | \item{open}{A logical value. If \code{TRUE} the \code{.gitignore} file is opened in 14 | the editor. Default is \code{FALSE}.} 15 | 16 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 17 | \code{FALSE}.} 18 | } 19 | \value{ 20 | No return value. 21 | } 22 | \description{ 23 | This function creates a \code{.gitignore} file at the root of the project based on 24 | a template (specific to R). If a \code{.gitignore} is already present, files to 25 | be untracked by \strong{git} are just added to this file. 26 | } 27 | \examples{ 28 | \dontrun{ 29 | add_to_gitignore(open = TRUE) 30 | add_to_gitignore(".DS_Store") 31 | } 32 | } 33 | \seealso{ 34 | Other development functions: 35 | \code{\link{add_dependencies}()}, 36 | \code{\link{add_github_actions_check}()}, 37 | \code{\link{add_github_actions_citation}()}, 38 | \code{\link{add_github_actions_codecov}()}, 39 | \code{\link{add_github_actions_codemeta}()}, 40 | \code{\link{add_github_actions_document}()}, 41 | \code{\link{add_github_actions_pkgdown}()}, 42 | \code{\link{add_github_actions_render}()}, 43 | \code{\link{add_r_depend}()}, 44 | \code{\link{add_to_buildignore}()} 45 | } 46 | \concept{development functions} 47 | -------------------------------------------------------------------------------- /man/add_vignette.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_vignette.R 3 | \name{add_vignette} 4 | \alias{add_vignette} 5 | \title{Create a vignette document} 6 | \usage{ 7 | add_vignette( 8 | filename = NULL, 9 | title = NULL, 10 | open = TRUE, 11 | overwrite = FALSE, 12 | quiet = FALSE 13 | ) 14 | } 15 | \arguments{ 16 | \item{filename}{A character of length 1. The name of the \code{.Rmd} file to be 17 | created. If \code{NULL} (default ) the \code{.Rmd} file will be named \code{pkg.Rmd} 18 | where \code{pkg} is your package name.} 19 | 20 | \item{title}{A character of length 1. The title of the vignette. If \code{NULL} 21 | (default) the title will be \verb{Get started}.} 22 | 23 | \item{open}{A logical value. If \code{TRUE} (default) the file is opened in the 24 | editor.} 25 | 26 | \item{overwrite}{A logical value. If this file is already present and 27 | \code{overwrite = TRUE}, it will be erased and replaced. Default is \code{FALSE}.} 28 | 29 | \item{quiet}{A logical value. If \code{TRUE} messages are deleted. Default is 30 | \code{FALSE}.} 31 | } 32 | \value{ 33 | No return value. 34 | } 35 | \description{ 36 | This function adds a vignette in the folder \verb{vignettes/}. It also adds 37 | dependencies \href{https://yihui.org/knitr/}{\code{knitr}} and 38 | \href{https://rmarkdown.rstudio.com/}{\code{rmarkdown}} in the 39 | field \code{Suggests} of the \code{DESCRIPTION} file (if not already present in 40 | fields \code{Imports}). 41 | } 42 | \examples{ 43 | \dontrun{ 44 | ## Default vignette ---- 45 | add_vignette() 46 | 47 | ## Default vignette ---- 48 | add_vignette(filename = "pkg", title = "Get started") 49 | } 50 | } 51 | \seealso{ 52 | Other create files: 53 | \code{\link{add_citation}()}, 54 | \code{\link{add_code_of_conduct}()}, 55 | \code{\link{add_compendium}()}, 56 | \code{\link{add_contributing}()}, 57 | \code{\link{add_description}()}, 58 | \code{\link{add_dockerfile}()}, 59 | \code{\link{add_license}()}, 60 | \code{\link{add_makefile}()}, 61 | \code{\link{add_package_doc}()}, 62 | \code{\link{add_readme_rmd}()}, 63 | \code{\link{add_renv}()}, 64 | \code{\link{add_testthat}()} 65 | } 66 | \concept{create files} 67 | -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FRBCesab/rcompendium/c50e80d8a693cef53280d46edbb2e544b5744b22/man/figures/logo.png -------------------------------------------------------------------------------- /man/get_all_dependencies.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_all_dependencies.R 3 | \name{get_all_dependencies} 4 | \alias{get_all_dependencies} 5 | \title{Get all external dependencies} 6 | \usage{ 7 | get_all_dependencies(pkg = NULL) 8 | } 9 | \arguments{ 10 | \item{pkg}{A character of length 1. The name of a CRAN package or \code{NULL} 11 | (default). If \code{NULL} get dependencies of the local (uninstalled) project 12 | (package or compendium).} 13 | } 14 | \value{ 15 | A list of three vectors: 16 | \itemize{ 17 | \item \code{base_deps}, a vector of base packages; 18 | \item \code{direct_deps}, a vector of direct packages; 19 | \item \code{all_deps}, a vector of all dependencies (recursively obtained). 20 | } 21 | } 22 | \description{ 23 | This function gets all the external packages that the project needs. It is 24 | used the generate the \emph{Dependencies} badge (\code{\link[=add_dependencies_badge]{add_dependencies_badge()}}). 25 | } 26 | \examples{ 27 | \dontrun{ 28 | ## Update dependencies ---- 29 | add_dependencies() 30 | 31 | ## Get all dependencies ---- 32 | deps <- get_all_dependencies() 33 | unlist(lapply(deps, length)) 34 | 35 | ## Can be used for a CRAN package ---- 36 | deps <- get_all_dependencies("usethis") 37 | unlist(lapply(deps, length)) 38 | } 39 | } 40 | \seealso{ 41 | Other utilities functions: 42 | \code{\link{get_all_functions}()}, 43 | \code{\link{get_licenses}()}, 44 | \code{\link{get_minimal_r_version}()} 45 | } 46 | \concept{utilities functions} 47 | -------------------------------------------------------------------------------- /man/get_all_functions.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_all_functions.R 3 | \name{get_all_functions} 4 | \alias{get_all_functions} 5 | \title{List all functions in the package} 6 | \usage{ 7 | get_all_functions() 8 | } 9 | \value{ 10 | A list of two vectors: 11 | \itemize{ 12 | \item \code{external}, a vector of exported functions name; 13 | \item \code{internal}, a vector of internal functions name. 14 | } 15 | } 16 | \description{ 17 | This function returns a list of all the functions (exported and internal) 18 | available with the package. As this function scans the \code{NAMESPACE} and the 19 | \verb{R/} folder, it is recommended to run \code{\link[devtools:document]{devtools::document()}} before. 20 | } 21 | \examples{ 22 | \dontrun{ 23 | ## Update NAMESPACE ---- 24 | devtools::document() 25 | 26 | ## List all implemented functions ---- 27 | get_all_functions() 28 | } 29 | } 30 | \seealso{ 31 | Other utilities functions: 32 | \code{\link{get_all_dependencies}()}, 33 | \code{\link{get_licenses}()}, 34 | \code{\link{get_minimal_r_version}()} 35 | } 36 | \concept{utilities functions} 37 | -------------------------------------------------------------------------------- /man/get_licenses.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_licenses.R 3 | \name{get_licenses} 4 | \alias{get_licenses} 5 | \title{List all available licenses} 6 | \usage{ 7 | get_licenses() 8 | } 9 | \value{ 10 | A \code{data.frame} with the following two variables: 11 | \itemize{ 12 | \item \code{tag}, the license name to be used with \code{\link[=add_license]{add_license()}}; 13 | \item \code{url}, the URL of the license description. 14 | } 15 | } 16 | \description{ 17 | This function returns a list of all available licenses. This is particularly 18 | useful to get the right spelling of the license to be passed to 19 | \code{\link[=new_package]{new_package()}}, \code{\link[=new_compendium]{new_compendium()}}, or \code{\link[=add_license]{add_license()}}. 20 | } 21 | \examples{ 22 | get_licenses() 23 | } 24 | \seealso{ 25 | Other utilities functions: 26 | \code{\link{get_all_dependencies}()}, 27 | \code{\link{get_all_functions}()}, 28 | \code{\link{get_minimal_r_version}()} 29 | } 30 | \concept{utilities functions} 31 | -------------------------------------------------------------------------------- /man/get_minimal_r_version.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/get_minimal_r_version.R 3 | \name{get_minimal_r_version} 4 | \alias{get_minimal_r_version} 5 | \title{Get required minimal R version} 6 | \usage{ 7 | get_minimal_r_version(pkg = NULL) 8 | } 9 | \arguments{ 10 | \item{pkg}{A character of length 1. The name of a CRAN package or \code{NULL} 11 | (default). If \code{NULL} get minimal required R version of the local 12 | (uninstalled) project (package or compendium).} 13 | } 14 | \value{ 15 | A character with the minimal required R version. 16 | } 17 | \description{ 18 | This function detects the minimal required R version for the project based 19 | on minimal required R version of its dependencies. It can be used to update 20 | the \code{Depends} field of the \code{DESCRIPTION} file. 21 | } 22 | \examples{ 23 | \dontrun{ 24 | ## Update dependencies ---- 25 | add_dependencies() 26 | 27 | ## Minimal R version of a project ---- 28 | get_minimal_r_version() 29 | 30 | ## Minimal R version of a CRAN package ---- 31 | get_minimal_r_version("usethis") 32 | } 33 | } 34 | \seealso{ 35 | Other utilities functions: 36 | \code{\link{get_all_dependencies}()}, 37 | \code{\link{get_all_functions}()}, 38 | \code{\link{get_licenses}()} 39 | } 40 | \concept{utilities functions} 41 | -------------------------------------------------------------------------------- /man/refresh.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/refresh.R 3 | \name{refresh} 4 | \alias{refresh} 5 | \title{Refresh a package/research compendium} 6 | \usage{ 7 | refresh(compendium = NULL, make = FALSE, check = FALSE, quiet = FALSE) 8 | } 9 | \arguments{ 10 | \item{compendium}{A character of length 1. The name of the folder to 11 | recursively detect dependencies to be added to the \code{Imports} field of 12 | \code{DESCRIPTION} file. It can be \code{'analysis/'} (if additional folders, i.e. 13 | \verb{data/}, \verb{outputs/}, \verb{figures/}, etc. have been created in this folder), 14 | \code{'.'} (if folders \verb{data/}, \verb{outputs/}, \verb{figures/}, etc. have been created 15 | at the root of the project), etc. 16 | See \code{\link[=new_compendium]{new_compendium()}} for further information. 17 | 18 | Default is \code{compendium = NULL} (i.e. no additional folder are inspected 19 | but \verb{R/}, \code{NAMESPACE}, \verb{vignettes/}, and \verb{tests/} are still inspected).} 20 | 21 | \item{make}{A logical value. If \code{TRUE} the Make-like R file \code{make.R} is 22 | sourced. Only for research compendium created with \code{\link[=new_compendium]{new_compendium()}}. 23 | Default is \code{FALSE}.} 24 | 25 | \item{check}{A logical value. If \code{TRUE} package integrity is checked using 26 | \code{\link[devtools:check]{devtools::check()}}. 27 | Default is \code{FALSE}.} 28 | 29 | \item{quiet}{A logical value. If \code{TRUE} (default) message are deleted.} 30 | } 31 | \value{ 32 | No return value. 33 | } 34 | \description{ 35 | \strong{This function is about to be removed from \code{rcompendium}.} 36 | 37 | This function refreshes a package/research compendium. It will: 38 | \itemize{ 39 | \item Update \code{.Rd} files and \code{NAMESPACE} by using \code{\link[devtools:document]{devtools::document()}}; 40 | \item Update external packages (in \code{DESCRIPTION} file) by using 41 | \code{\link[=add_dependencies]{add_dependencies()}}; 42 | \item Update badges in \code{README.Rmd} (if already present); 43 | \item Re-knitr the \code{README.Rmd} by using \code{\link[rmarkdown:render]{rmarkdown::render()}}; 44 | \item Check package integrity by using \code{\link[devtools:check]{devtools::check()}}; 45 | \item Run analysis by sourcing \code{make.R} (only for compendium). 46 | } 47 | } 48 | \examples{ 49 | \dontrun{ 50 | library(rcompendium) 51 | 52 | ## Create an R package ---- 53 | new_package() 54 | 55 | ## Start developing functions ---- 56 | ## ... 57 | 58 | ## Update package (documentation, dependencies, README) ---- 59 | refresh() 60 | } 61 | } 62 | \seealso{ 63 | Other setup functions: 64 | \code{\link{new_compendium}()}, 65 | \code{\link{new_package}()}, 66 | \code{\link{set_credentials}()} 67 | } 68 | \concept{setup functions} 69 | -------------------------------------------------------------------------------- /man/set_credentials.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/set_credentials.R 3 | \name{set_credentials} 4 | \alias{set_credentials} 5 | \title{Store credentials to the .Rprofile} 6 | \usage{ 7 | set_credentials( 8 | given = NULL, 9 | family = NULL, 10 | email = NULL, 11 | orcid = NULL, 12 | protocol = NULL 13 | ) 14 | } 15 | \arguments{ 16 | \item{given}{A character of length 1. The given name of the project 17 | maintainer.} 18 | 19 | \item{family}{A character of length 1. The family name of the project 20 | maintainer.} 21 | 22 | \item{email}{A character of length 1. The email address of the project 23 | maintainer.} 24 | 25 | \item{orcid}{A character of length 1. The ORCID of the project maintainer.} 26 | 27 | \item{protocol}{A character of length 1. The GIT protocol used to 28 | communicate with the GitHub remote. One of \code{'https'} or \code{'ssh'}. If you 29 | don't know, keep the default value (i.e. \code{NULL}) and the protocol will be 30 | \code{'https'}.} 31 | } 32 | \value{ 33 | No return value. 34 | } 35 | \description{ 36 | This function is used to store user credentials in the \code{.Rprofile} file. 37 | Accepted credentials are listed below. This function is useful if user 38 | creates a lot of packages and/or research compendiums. 39 | 40 | If the \code{.Rprofile} file does not exist this function will create it. Users 41 | need to paste the content of the clipboard to this file. 42 | } 43 | \examples{ 44 | \dontrun{ 45 | library(rcompendium) 46 | 47 | 48 | ## Define **ONCE FOR ALL** your credentials ---- 49 | 50 | set_credentials("John", "Doe", "john.doe@domain.com", 51 | orcid = "9999-9999-9999-9999", protocol = "https") 52 | } 53 | } 54 | \seealso{ 55 | Other setup functions: 56 | \code{\link{new_compendium}()}, 57 | \code{\link{new_package}()}, 58 | \code{\link{refresh}()} 59 | } 60 | \concept{setup functions} 61 | -------------------------------------------------------------------------------- /tests/testthat.R: -------------------------------------------------------------------------------- 1 | library(testthat) 2 | library(rcompendium) 3 | 4 | test_check("rcompendium") 5 | -------------------------------------------------------------------------------- /tests/testthat/setup-tests.R: -------------------------------------------------------------------------------- 1 | #' Setup Tests Infrastructure 2 | #' 3 | 4 | ## Temporary Directory ---- 5 | 6 | create_temp_compendium <- function(pkg = file.path(tempdir(), "pkgtest")) { 7 | 8 | old_wd <- getwd() 9 | 10 | withr::defer(fs::dir_delete(pkg), envir = parent.frame()) 11 | 12 | dir.create(pkg) 13 | 14 | setwd(pkg) 15 | invisible(file.create(".here")) 16 | 17 | withr::defer(setwd(old_wd), envir = parent.frame()) 18 | 19 | invisible(pkg) 20 | } 21 | -------------------------------------------------------------------------------- /tests/testthat/test-01-proj.R: -------------------------------------------------------------------------------- 1 | ## PROJECT --- 2 | 3 | test_that("Check Project Found", { 4 | 5 | create_temp_compendium() 6 | 7 | expect_equal(get_package_name(), "pkgtest") 8 | }) 9 | -------------------------------------------------------------------------------- /tests/testthat/test-03-license.R: -------------------------------------------------------------------------------- 1 | ## LICENSE FILE ---- 2 | 3 | test_that("Check Inputs", { 4 | 5 | # Simulation of no Rprofile... 6 | withr::local_options(list("given" = NULL, "family" = NULL, "email" = NULL, 7 | "orcid" = NULL, "github" = NULL)) 8 | 9 | expect_error(add_license(quiet = TRUE), "No 'DESCRIPTION' file found.") 10 | 11 | create_temp_compendium() 12 | add_description("John", "Doe", "john.doe@gmail.com", "9999-9999-9999-9999", 13 | organisation = "society", open = FALSE, overwrite = FALSE, 14 | quiet = TRUE) 15 | 16 | expect_error(add_license(quiet = TRUE)) 17 | expect_error(add_license(license = NA, quiet = TRUE)) 18 | expect_error(add_license(license = numeric(0), quiet = TRUE)) 19 | expect_error(add_license(license = c("MIT", "GPL-2"), quiet = TRUE)) 20 | expect_error(add_license(license = "GPL2", quiet = TRUE)) 21 | expect_error(add_license(license = "GPL 2", quiet = TRUE)) 22 | 23 | expect_error(add_license(quiet = 0)) 24 | expect_error(add_license(quiet = NULL)) 25 | expect_error(add_license(quiet = "false")) 26 | 27 | expect_error(add_license(license = "MIT", quiet = TRUE)) 28 | expect_error(add_license(license = "MIT", "John", quiet = TRUE)) 29 | expect_error(add_license(license = "MIT", "John Doe", quiet = TRUE)) 30 | expect_error(add_license(license = "MIT", c("John", "Doe"), quiet = TRUE)) 31 | expect_error(add_license(license = "MIT", family = "Doe", quiet = TRUE)) 32 | 33 | expect_invisible(add_license(license = "MIT", "John", "Doe", quiet = TRUE)) 34 | }) 35 | 36 | 37 | test_that("Check Credentials", { 38 | 39 | withr::local_options(list("given" = "john", "family" = "doe", 40 | "email" = "john.doe@gmail.com", 41 | "orcid" = "9999-9999-9999-9999")) 42 | 43 | create_temp_compendium() 44 | add_description(organisation = "society", open = FALSE, overwrite = FALSE, 45 | quiet = TRUE) 46 | 47 | expect_invisible(add_license(license = "MIT", quiet = TRUE)) 48 | }) 49 | 50 | 51 | test_that("Check Files and Overwrite", { 52 | 53 | withr::local_options(list("given" = "john", "family" = "doe", 54 | "email" = "john.doe@gmail.com", 55 | "orcid" = "9999-9999-9999-9999")) 56 | 57 | create_temp_compendium() 58 | add_description(organisation = "society", open = FALSE, overwrite = FALSE, 59 | quiet = TRUE) 60 | 61 | add_license(license = "MIT", quiet = TRUE) 62 | 63 | expect_true("LICENSE" %in% list.files(getwd())) 64 | expect_true("LICENSE.md" %in% list.files(getwd())) 65 | 66 | content <- readLines("LICENSE.md") 67 | expect_length(grep("MIT License", content[1]), n = 1) 68 | 69 | 70 | add_license(license = "GPL-2", quiet = TRUE) 71 | 72 | expect_false("LICENSE" %in% list.files(getwd())) 73 | 74 | content <- readLines("LICENSE.md") 75 | expect_length(grep("GNU General Public License", content[1]), n = 1) 76 | }) 77 | 78 | test_that("Check DESCRIPTION Fields", { 79 | 80 | withr::local_options(list("given" = "john", "family" = "doe", 81 | "email" = "john.doe@gmail.com", 82 | "orcid" = "9999-9999-9999-9999")) 83 | 84 | create_temp_compendium() 85 | add_description(organisation = "society", open = FALSE, overwrite = FALSE, 86 | quiet = TRUE) 87 | 88 | add_license(license = "MIT", quiet = TRUE) 89 | expect_equal(read_descr()$"License", "MIT + file LICENSE") 90 | 91 | add_license(license = "LGPL (>= 3)", quiet = TRUE) 92 | expect_equal(read_descr()$"License", "LGPL (>= 3)") 93 | }) 94 | -------------------------------------------------------------------------------- /vignettes/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | *.R 3 | --------------------------------------------------------------------------------