diff --git a/.zenodo.json b/.zenodo.json index bea93658..a831572a 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code", - "version": "0.3.6", + "version": "0.4.0", "license": "GPL-3.0", "upload_type": "software", "description": "

An opinionated set of rules for R packages and R source code projects.<\/p>", diff --git a/CITATION.cff b/CITATION.cff index 04a46b08..3f49ab67 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -25,4 +25,4 @@ identifiers: value: 10.5281/zenodo.4028303 - type: url value: https://inbo.github.io/checklist/ -version: 0.3.6 +version: 0.4.0 diff --git a/DESCRIPTION b/DESCRIPTION index cdcb61c2..91db0be1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: checklist Title: A Thorough and Strict Set of Checks for R Packages and Source Code -Version: 0.3.6 +Version: 0.4.0 Authors@R: c( person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")), @@ -59,5 +59,5 @@ Config/checklist/keywords: quality control; documentation; publication Encoding: UTF-8 Language: en-GB Roxygen: list(markdown = TRUE) -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 SystemRequirements: Pandoc (>= 1.17.2) diff --git a/Dockerfile b/Dockerfile index 327b7c56..26f23e87 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,8 +13,8 @@ LABEL org.label-schema.build-date=$BUILD_DATE \ maintainer="Thierry Onkelinx " ## for apt to be noninteractive -ENV DEBIAN_FRONTEND noninteractive -ENV DEBCONF_NONINTERACTIVE_SEEN true +ENV DEBIAN_FRONTEND=noninteractive +ENV DEBCONF_NONINTERACTIVE_SEEN=true ## Install nano RUN apt-get update \ diff --git a/LICENSE.md b/LICENSE.md index 2fb2e74d..379c1b2d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,4 @@ -### GNU GENERAL PUBLIC LICENSE +# GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/NAMESPACE b/NAMESPACE index 596822b0..1de845fd 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -37,6 +37,7 @@ export(organisation) export(prepare_ghpages) export(read_checklist) export(read_organisation) +export(set_license) export(set_tag) export(setup_package) export(setup_project) diff --git a/NEWS.md b/NEWS.md index b56cd011..99eec2b2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,13 @@ +# checklist 0.4.0 + +* Updated `README.md`. +* Improved support for `organisation`. +* Add `set_license()`. +* `check_filename()` allows a `CODEOWNERS` file. +* The checklist summary displays the unstaged git changes. +* The GitHub Action on packages installs the `roxygen2` version listed in the + `DESCRIPTION` of the package it checks. + # checklist 0.3.6 * Add an `organisation` class to store organisation rules different from those diff --git a/R/check_description.R b/R/check_description.R index daa4f304..2301a779 100644 --- a/R/check_description.R +++ b/R/check_description.R @@ -273,12 +273,12 @@ Please send a pull request if you need support for this license.", official <- official[-3] current <- current[-3] } - problems <- c( - problems, - "LICENSE.md doesn't match the version in the checklist package"[ - (length(current) != length(official)) || any(current != official) - ] + if ((length(current) != length(official)) || any(current != official)) { + problems <- c( + problems, "LICENSE.md doesn't match the version in the checklist package" ) + set_license(x) + } x$add_error( errors = problems, item = "license", keep = FALSE @@ -291,19 +291,46 @@ Please send a pull request if you need support for this license.", check_authors <- function(this_desc, org) { assert_that(inherits(org, "organisation")) authors <- this_desc$get_authors() - stopifnot( - "TO DO: handle funder not equal to rightsholder" = - (is.na(org$get_rightsholder) && is.na(org$get_funder)) || - (org$get_rightsholder == org$get_funder) - ) - rightsholder <- person( - given = org$get_rightsholder, role = c("cph", "fnd"), email = org$get_email + email <- c(NULL, org$get_email[!is.na(org$get_email)]) + if (!is.na(org$get_rightsholder)) { + if (!is.na(org$get_funder)) { + if (org$get_rightsholder == org$get_funder) { + rightsholder <- person( + given = org$get_rightsholder, role = c("cph", "fnd"), email = email + ) + funder <- NULL + } else { + rightsholder <- person( + given = org$get_rightsholder, role = "cph", email = email + ) + funder <- person(given = org$get_funder, role = "fnd") + } + } else { + rightsholder <- person( + given = org$get_rightsholder, role = "cph", email = email + ) + funder <- NULL + } + } else if (!is.na(org$get_funder)) { + rightsholder <- NULL + funder <- person(given = org$get_funder, role = "fnd") + } + + problems <- c( + sprintf( + "`%s` must be listed as copyright holder and use `%s` as email.", + org$get_rightsholder, org$get_email + )[ + !is.null(rightsholder) && !is.na(org$get_rightsholder) && + !rightsholder %in% authors + ], + sprintf( + "`%s` must be listed as funder without email.", + org$get_funder + )[!is.null(funder) && !is.na(org$get_funder) && !funder %in% authors] ) - problems <- sprintf( - "`%s` must be listed as copyright holder and funder and use `%s` as email.", - org$get_rightsholder, org$get_email - )[!is.na(org$get_rightsholder) && !rightsholder %in% authors] authors <- authors[!authors %in% rightsholder] + authors <- authors[!authors %in% funder] vapply( authors, FUN.VALUE = vector(mode = "list", length = 1L), FUN = function(author) { diff --git a/R/check_filename.R b/R/check_filename.R index b2c90d8d..abed14e1 100644 --- a/R/check_filename.R +++ b/R/check_filename.R @@ -98,7 +98,7 @@ check_filename <- function(x = ".") { paste( c( "\\.[a-zA-Z]+ignore", "\\.Rprofile", "\\.[a-zA-Z]+\\.(json|yml)", - "CITATION", "DESCRIPTION", "NAMESPACE", "CITATION\\.cff", + "CITATION", "CODEOWNERS", "DESCRIPTION", "NAMESPACE", "CITATION\\.cff", "README\\.R?md", "NEWS\\.md", "CODE_OF_CONDUCT\\.md", "CONTRIBUTING\\.md", "LICENSE(\\.md)?", "SUPPORT\\.md", "SECURITY\\.md", "FUNDING\\.yml", diff --git a/R/check_spelling.R b/R/check_spelling.R index 5ec14ec5..662a7725 100644 --- a/R/check_spelling.R +++ b/R/check_spelling.R @@ -243,7 +243,7 @@ rstudio_source_markers <- function(issues) { # nocov start "`%s` not found in the dictionary or wordlist for %s.", issues$message, issues$language ) - issues <- issues[order(issues$file, issues$line, issues$column), ] + issues <- unique(issues[order(issues$file, issues$line, issues$column), ]) issues$file <- as.character(issues$file) # request source markers rstudioapi::callFun( diff --git a/R/citation_description.R b/R/citation_description.R index 21a06404..025014f8 100644 --- a/R/citation_description.R +++ b/R/citation_description.R @@ -173,6 +173,7 @@ description_communities <- function(communities, org) { ) } list( - meta = list(community = communities), warnings = character(0) + meta = list(community = split_community(communities)), + warnings = character(0) ) } diff --git a/R/citation_meta_class.R b/R/citation_meta_class.R index 6ff32c58..4f4145ac 100644 --- a/R/citation_meta_class.R +++ b/R/citation_meta_class.R @@ -173,13 +173,20 @@ validate_citation <- function(meta) { rightsholder_id <- roles$contributor[roles$role == "copyright holder"] funder_id <- roles$contributor[roles$role == "funder"] notes <- c( + "no rightsholder listed"[ + !is.na(org$get_rightsholder) && length(rightsholder_id) == 0 + ], + "no funder listed"[!is.na(org$get_funder) && length(funder_id) == 0], sprintf("rightsholder differs from `%s`", org$get_rightsholder)[ - !is.na(org$get_rightsholder) && - authors$given[authors$id == rightsholder_id] != org$get_rightsholder + !is.na(org$get_rightsholder) && length(rightsholder_id) >= 1 && + !any( + authors$given[authors$id %in% rightsholder_id] %in% + org$get_rightsholder + ) ], sprintf("funder differs from `%s`", org$get_funder)[ - !is.na(org$get_funder) && - authors$given[authors$id == funder_id] != org$get_funder + !is.na(org$get_funder) && length(funder_id) >= 1 && + !any(org$get_funder %in% authors$given[authors$id == funder_id]) ] ) errors <- c( diff --git a/R/create_package.R b/R/create_package.R index 806b792d..02f49ed8 100644 --- a/R/create_package.R +++ b/R/create_package.R @@ -185,23 +185,7 @@ create_package <- function( git_add("README.Rmd", repo = repo) # add LICENSE.md - license_file <- path(path, "LICENSE.md") - switch( - license, "GPL-3" = path("generic_template", "gplv3.md"), - "MIT" = path("generic_template", "mit.md") - ) |> - system.file(package = "checklist") |> - file_copy(license_file) - if (license == "MIT") { - paste0("YEAR: ", format(Sys.Date(), "%Y")) |> - c(sprintf("COPYRIGHT HOLDER: %s", org$get_rightsholder)) |> - writeLines(path(path, "LICENSE")) - git_add("LICENSE", repo = repo) - mit <- readLines(license_file) - mit[3] <- gsub("", format(Sys.Date(), "%Y"), mit[3]) - mit[3] <- gsub("", org$get_rightsholder, mit[3]) - writeLines(mit, license_file) - } + set_license(x) git_add("LICENSE.md", repo = repo) # Add code of conduct diff --git a/R/default_organisation.R b/R/default_organisation.R index dc53ead2..437ef6fc 100644 --- a/R/default_organisation.R +++ b/R/default_organisation.R @@ -13,7 +13,9 @@ #' @family both default_organisation <- function(org = organisation$new()) { assert_that(inherits(org, "organisation")) - R_user_dir("checklist", which = "config") |> + target <- R_user_dir("checklist", which = "config") + dir_create(target) + target |> path("organisation.yml") |> write_yaml(x = org$template) return(invisible(NULL)) diff --git a/R/organisation_class.R b/R/organisation_class.R index f9ee83ab..62407c73 100644 --- a/R/organisation_class.R +++ b/R/organisation_class.R @@ -25,10 +25,11 @@ organisation <- R6Class( #' - `rightsholder`: the rightsholder. #' Defaults to `"Research Institute for Nature and Forest (INBO)"`. #' Set to `NA_character_` in case you don't want to set a rightsholder. - #' - `organisation`: a named list with one or more organisation defaults. + #' - `organisation`: a named list with one or more organisation default + #' rules. #' The names of the element must match the e-mail domain name of the #' organisation. - #' Every element should be a named list containing ´affiliation` and + #' Every element should be a named list containing `affiliation` and #' `orcid`. #' `affiliation` is a character vector with the approved organisation #' names in one or more languages. diff --git a/R/read_checklist.R b/R/read_checklist.R index 4ae9f859..f881f270 100644 --- a/R/read_checklist.R +++ b/R/read_checklist.R @@ -32,7 +32,12 @@ read_checklist <- function(x = ".") { } assert_that( is_file(checklist_file), - msg = sprintf("no checklist.yml found `%s` or its parents", x) + msg = paste( + "No checklist.yml found at `%1$s` or its parents.", + "\nRun `checklist::setup_package(\"%1$s\")` or", + "`checklist::setup_project(\"%1$s\")`." + ) |> + sprintf(path_real(x)) ) # read existing check list file diff --git a/R/set_license.R b/R/set_license.R new file mode 100644 index 00000000..335d419f --- /dev/null +++ b/R/set_license.R @@ -0,0 +1,51 @@ +#' Set the proper license +#' @inheritParams read_checklist +#' @family setup +#' @export +#' @importFrom assertthat assert_that +#' @importFrom desc description +#' @importFrom fs file_copy file_exists path +set_license <- function(x = ".") { + x <- read_checklist(x = x) + license_file <- path(x$get_path, "LICENSE.md") + if (x$package) { + assert_that( + file_exists(path(x$get_path, "DESCRIPTION")), + msg = sprintf("No `DESCRIPTION` file found at %s", x$get_path) + ) + this_desc <- description$new(file = path(x$get_path, "DESCRIPTION")) + assert_that( + this_desc$has_fields("License"), + msg = "`DESCRIPTION` has no `License`field." + ) + switch( + this_desc$get_field("License"), + "GPL-3" = path("generic_template", "gplv3.md"), + "MIT" = path("generic_template", "mit.md"), + "MIT + file LICENSE" = path("generic_template", "mit.md"), + stop( + sprintf("`%s` license is not available", this_desc$get_field("License")) + ) + ) |> + system.file(package = "checklist") |> + file_copy(license_file, overwrite = TRUE) + if (!grepl("^MIT", this_desc$get_field("License"))) { + return(invisible(NULL)) + } + this_desc$get_author(role = "cph") |> + format(include = c("given", "family")) |> + paste(collapse = ", ") -> cph + paste0("YEAR: ", format(Sys.Date(), "%Y")) |> + c(sprintf("COPYRIGHT HOLDER: %s", cph)) |> + writeLines(path(x$get_path, "LICENSE")) + mit <- readLines(license_file) + mit[3] <- gsub("", format(Sys.Date(), "%Y"), mit[3]) + mit[3] <- gsub("", cph, mit[3]) + writeLines(mit, license_file) + return(invisible(NULL)) + } + path("generic_template", "cc_by_4_0.md") |> + system.file(package = "checklist") |> + file_copy(license_file, overwrite = TRUE) + return(invisible(NULL)) +} diff --git a/R/setup_package.R b/R/setup_package.R index d1141b03..571690ab 100644 --- a/R/setup_package.R +++ b/R/setup_package.R @@ -35,7 +35,16 @@ setup_package <- function(path = ".", license = c("GPL-3", "MIT")) { # add checklist.yml if (!file_exists(path(path, "checklist.yml"))) { - x <- checklist$new(x = path, language = "en-GB", package = TRUE) + if (descript$has_fields("Language")) { + x <- checklist$new( + x = path, language = descript$get_field("Language"), package = TRUE + ) + } else { + x <- checklist$new(x = path, language = "en-GB", package = TRUE) + descript$set("Language", "en-GB") + path(x$get_path, "DESCRIPTION") |> + descript$write() + } x$set_required() x$set_ignore(c(".github", "LICENSE.md")) write_checklist(x) diff --git a/R/setup_project.R b/R/setup_project.R index 9e448fdc..1a7e08ff 100644 --- a/R/setup_project.R +++ b/R/setup_project.R @@ -54,10 +54,7 @@ setup_project <- function(path = ".") { x$set_default(c("en-GB", "nl-BE", "fr-FR")[answer]) if ("license" %in% checks && !file_exists(path(path, "LICENSE.md"))) { - insert_file( - repo = repo, filename = "cc_by_4_0.md", template = "generic_template", - target = path, new_name = "LICENSE.md" - ) + set_license(x) } x$set_required(checks = checks) diff --git a/R/utils.R b/R/utils.R index 331f4f36..6fcec25b 100644 --- a/R/utils.R +++ b/R/utils.R @@ -331,17 +331,11 @@ checklist_diff <- function(root) { if (inherits(try(git_info(repo = root), silent = TRUE), "try-error")) { return(invisible(NULL)) } - branch_info <- git_branch_list(repo = root) - branch_info$ref[ - grep("/main$", branch_info$ref) |> - c(grep("/master$", branch_info$ref)) |> - head(1) - ] |> - git_diff(repo = root) -> changes + changes <- git_diff(repo = root) if (length(changes) == 0) { return(invisible(NULL)) } - cli_h1("git diff") + cli_h1("unstaged changes") changes$patch |> gsub(pattern = "^.*?index.*?\n.*?\n", replacement = "") |> strsplit(split = "\n") |> diff --git a/README.Rmd b/README.Rmd index 599038c8..41fd4e1f 100644 --- a/README.Rmd +++ b/README.Rmd @@ -32,7 +32,7 @@ The goal of `checklist` is to provide an elaborate and strict set of checks for ## Installation -You can install the package from the [INBO universe](https://inbo.r-universe.dev/ui/#builds) via +You can install the package from the [INBO universe](https://inbo.r-universe.dev/builds) via ```{r universe} # Enable the INBO universe @@ -52,34 +52,94 @@ If that doesn't work, you can install the version from [GitHub](https://github.c remotes::install_github("inbo/checklist") ``` -## Examples +## Setting a default organisation -You can run the full list of checks +We created `checklist` with the Research Institute for Nature and Forest (INBO) in mind. +When you don't specify the organisation, `checklist` assumes the code was written by INBO personnel. +INBO has specific requirements which are not relevant for external users of `checklist`. -```{r example-full} +When you are not writing code for INBO, we recommend that you set a default `organisation`. +Below we specify the defaults for INBO. +More details in `vignette("organisation", package = "checklist")`. + +```{r organisation} library(checklist) -check_package() # for packages -check_source() # for a project with R and Rmd files +org <- organisation$new( + github = "inbo", community = "inbo", email = "info@inbo.be", + rightsholder = "Research Institute for Nature and Forest (INBO)", + funder = "Research Institute for Nature and Forest (INBO)", + organisation = list( + "inbo.be" = list( + affiliation = c( + en = "Research Institute for Nature and Forest (INBO)", + nl = "Instituut voor Natuur en Bosonderzoek (INBO)" + ), + orcid = TRUE + ) + ) +) +default_organisation(org = org) +``` + +## Using `checklist` on a package. + +Before you can run the checks, you must initialise `checklist` on the package. +Either use `create_package()` to create a new package from scratch. +Or use `setup_package()` on an existing package. +More details in `vignette("getting_started", package = "checklist")`. + +```{r package-initialise} +create_package() ``` -Or run the individual checks +Once initialised, you can run all the checks with `check_package()`. +Or run the individual checks. -```{r example-detail} +```{r package-checks} check_cran() check_description() check_documentation() check_lintr() check_filename() +check_folder() +update_citation() ``` -Create a `checklist.yml` to allow some of warnings or notes. +To allow some of the warnings or notes, first run the checks and store them in an object. +Update `checklist.yml` by writing that object. -```{r example-checklist} -write_checklist() +```{r package-allow-warnings} +x <- check_package() +write_checklist(x) ``` -Start a package from scratch with everything set-up +## Using `checklist` on a project. -```{r example-create} -create_package() +Before you can run the checks, you must initialise `checklist` on the project. +Either use `create_project()` to create a new package from scratch. +Or use `setup_project()` on an existing package. +More details in `vignette("getting_started_project", package = "checklist")`. + +```{r project-initialise} +library(checklist) +create_project() +``` + +Once initialised, you can run all the checks with `check_project()`. +Or run the individual checks. + +```{r project-checks} +check_lintr() +check_filename() +check_folder() +update_citation() +``` + +To allow some of the warnings or notes, first run the checks and store them in an object. +Update `checklist.yml` by writing that object. + + +```{r project-allow-warnings} +x <- check_project() +write_checklist(x) ``` diff --git a/README.md b/README.md index d22bd6fc..1d663d47 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ checks for R packages and R code. ## Installation You can install the package from the [INBO -universe](https://inbo.r-universe.dev/ui/#builds) via +universe](https://inbo.r-universe.dev/builds) via ``` r # Enable the INBO universe @@ -52,17 +52,49 @@ If that doesn’t work, you can install the version from remotes::install_github("inbo/checklist") ``` -## Examples +## Setting a default organisation -You can run the full list of checks +We created `checklist` with the Research Institute for Nature and Forest +(INBO) in mind. When you don’t specify the organisation, `checklist` +assumes the code was written by INBO personnel. INBO has specific +requirements which are not relevant for external users of `checklist`. + +When you are not writing code for INBO, we recommend that you set a +default `organisation`. Below we specify the defaults for INBO. More +details in `vignette("organisation", package = "checklist")`. ``` r library(checklist) -check_package() # for packages -check_source() # for a project with R and Rmd files +org <- organisation$new( + github = "inbo", community = "inbo", email = "info@inbo.be", + rightsholder = "Research Institute for Nature and Forest (INBO)", + funder = "Research Institute for Nature and Forest (INBO)", + organisation = list( + "inbo.be" = list( + affiliation = c( + en = "Research Institute for Nature and Forest (INBO)", + nl = "Instituut voor Natuur en Bosonderzoek (INBO)" + ), + orcid = TRUE + ) + ) +) +default_organisation(org = org) ``` -Or run the individual checks +## Using `checklist` on a package. + +Before you can run the checks, you must initialise `checklist` on the +package. Either use `create_package()` to create a new package from +scratch. Or use `setup_package()` on an existing package. More details +in `vignette("getting_started", package = "checklist")`. + +``` r +create_package() +``` + +Once initialised, you can run all the checks with `check_package()`. Or +run the individual checks. ``` r check_cran() @@ -70,16 +102,44 @@ check_description() check_documentation() check_lintr() check_filename() +check_folder() +update_citation() ``` -Create a `checklist.yml` to allow some of warnings or notes. +To allow some of the warnings or notes, first run the checks and store +them in an object. Update `checklist.yml` by writing that object. ``` r -write_checklist() +x <- check_package() +write_checklist(x) ``` -Start a package from scratch with everything set-up +## Using `checklist` on a project. + +Before you can run the checks, you must initialise `checklist` on the +project. Either use `create_project()` to create a new package from +scratch. Or use `setup_project()` on an existing package. More details +in `vignette("getting_started_project", package = "checklist")`. ``` r -create_package() +library(checklist) +create_project() +``` + +Once initialised, you can run all the checks with `check_project()`. Or +run the individual checks. + +``` r +check_lintr() +check_filename() +check_folder() +update_citation() +``` + +To allow some of the warnings or notes, first run the checks and store +them in an object. Update `checklist.yml` by writing that object. + +``` r +x <- check_project() +write_checklist(x) ``` diff --git a/_pkgdown.yml b/_pkgdown.yml index 28062222..2f101d22 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -1,4 +1,6 @@ template: + bootstrap: 5 + light-switch: false opengraph: image: src: man/figures/hexsticker.png @@ -9,22 +11,33 @@ template: navbar: title: ~ type: default - left: - - text: NEWS - href: news/index.html - - text: Tutorials - href: articles/index.html - - text: Functions - href: reference/index.html - - text: Contributing - href: CONTRIBUTING.html - right: - - icon: "fa fa-github" - href: https://github.com/inbo/checklist - - icon: "fa fa-twitter" - href: https://twitter.com/INBOVlaanderen - - icon: "fa fa-facebook" - href: https://www.facebook.com/pg/INBOVlaanderen + structure: + left: [intro, reference, news, tutorials, contributing] + right: [search, github] + components: + tutorials: + text: Tutorials + href: articles/index.html + menu: + - text: Philosophy of the checklist package + href: articles/philosophy.html + - text: Setting up checklist for a package + href: articles/getting_started.html + - text: Setting up checklist for a project + href: articles/getting_started_project.html + - text: Organisations + href: articles/organisation.html + - text: Spell checking with checklist + href: articles/spelling.html + - text: Recommended folder structure + href: articles/folder.html + - text: File paths in code + href: articles/path.html + - text: Setting up the integration between GitHub, Zenodo and ORCID + href: articles/zenodo.html + contributing: + text: Contributing + href: CONTRIBUTING.html reference: - title: Functions relevant for checking packages @@ -47,23 +60,11 @@ reference: contents: - has_concept("utils") -articles: -- title: Getting started - contents: - - philosophy - - folder - - path - - getting_started - - getting_started_project - - spelling - - zenodo - - organisation - authors: Thierry Onkelinx: href: "https://www.muscardinus.be" Research Institute for Nature and Forest (INBO): href: "https://www.vlaanderen.be/inbo/en-gb" - html: "" + html: "logo of the Research Institute for Nature and Forest (INBO)" url: https://inbo.github.io/checklist diff --git a/docker/entrypoint_package.sh b/docker/entrypoint_package.sh index 0c84b48b..cc270e5f 100755 --- a/docker/entrypoint_package.sh +++ b/docker/entrypoint_package.sh @@ -26,6 +26,11 @@ if [ $? -ne 0 ]; then exit 1 fi +# install the roxygen2 version mentions in the DESCRIPTION +ROXYGEN_LINE=$(cat DESCRIPTION | grep "^RoxygenNote:") +RO_VERSION=${ROXYGEN_LINE#*: } +Rscript -e "remotes::install_version('roxygen2', version = '$RO_VERSION')" + echo '\nChecking the package...\n' Rscript --no-save --no-restore -e 'checklist::check_package()' if [ $? -ne 0 ]; then diff --git a/inst/CITATION b/inst/CITATION index 01945119..6fb60003 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -2,12 +2,12 @@ citHeader("To cite `checklist` in publications please use:") # begin checklist entry bibentry( bibtype = "Manual", - title = "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.6", + title = "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.4.0", author = c( author = c(person(given = "Thierry", family = "Onkelinx"))), year = 2024, url = "https://inbo.github.io/checklist/", abstract = "An opinionated set of rules for R packages and R source code projects.", - textVersion = "Onkelinx, Thierry (2024) checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.6. https://inbo.github.io/checklist/", + textVersion = "Onkelinx, Thierry (2024) checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.4.0. https://inbo.github.io/checklist/", keywords = "quality control; documentation; publication", doi = "10.5281/zenodo.4028303", ) diff --git a/inst/generic_template/cc_by_4_0.md b/inst/generic_template/cc_by_4_0.md index 7e5a52a5..bed44e07 100644 --- a/inst/generic_template/cc_by_4_0.md +++ b/inst/generic_template/cc_by_4_0.md @@ -1,6 +1,4 @@ -## creative commons - -# Attribution 4.0 International +# Creative Commons Attribution 4.0 International Creative Commons Corporation (“Creative Commons”) is not a law firm and does not provide legal services or legal advice. Distribution of Creative Commons public licenses does not create a lawyer-client or other relationship. Creative Commons makes its licenses and related information available on an “as-is” basis. Creative Commons gives no warranties regarding its licenses, any material licensed under their terms and conditions, or any related information. Creative Commons disclaims all liability for damages resulting from their use to the fullest extent possible. diff --git a/inst/generic_template/gplv3.md b/inst/generic_template/gplv3.md index 2fb2e74d..379c1b2d 100644 --- a/inst/generic_template/gplv3.md +++ b/inst/generic_template/gplv3.md @@ -1,4 +1,4 @@ -### GNU GENERAL PUBLIC LICENSE +# GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 diff --git a/inst/package_template/_pkgdown.yml b/inst/package_template/_pkgdown.yml index 3ee201d3..f2fe7df2 100644 --- a/inst/package_template/_pkgdown.yml +++ b/inst/package_template/_pkgdown.yml @@ -1,22 +1,14 @@ +template: + bootstrap: 5 + light-switch: false navbar: title: ~ type: default - left: - - text: NEWS - href: news/index.html - - text: Functions - href: reference/index.html - - text: Contributing - href: CONTRIBUTING.html - right: - - icon: "fa fa-github" - href: https://github.com/inbo/{{{ Package }}} - - icon: "fa fa-twitter" - href: https://twitter.com/INBOVlaanderen - - icon: "fa fa-facebook" - href: https://www.facebook.com/pg/INBOVlaanderen + structure: + left: [intro, reference, news, tutorials, contributing] + right: [search, github] authors: Research Institute for Nature and Forest (INBO): href: "https://www.vlaanderen.be/inbo/en-gb" - html: "" + html: "logo of the Research Institute for Nature and Forest (INBO)" diff --git a/inst/package_template/pkgdown.css b/inst/package_template/pkgdown.css index 00938dd1..ba8bfe49 100644 --- a/inst/package_template/pkgdown.css +++ b/inst/package_template/pkgdown.css @@ -19,12 +19,14 @@ a:hover { .navbar, .label-default, .navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:hover, .navbar-default .navbar-nav>.active>a:focus { - background-color: #356196; + background-color: #356196 !important; } -.navbar-default .navbar-link, -.navbar-default .navbar-nav>li>a { - color: #ffffff; +.navbar, +.navbar-brand, +.nav-link, +.nav-text.text-muted { + color: #ffffff !important; } .nav-pills li.active>a, .nav-pills li>a:hover { diff --git a/man/create_package.Rd b/man/create_package.Rd index 809f5b0c..f1a6d988 100644 --- a/man/create_package.Rd +++ b/man/create_package.Rd @@ -86,6 +86,7 @@ create_package( Other setup: \code{\link{create_project}()}, \code{\link{prepare_ghpages}()}, +\code{\link{set_license}()}, \code{\link{setup_package}()}, \code{\link{setup_project}()}, \code{\link{setup_source}()} diff --git a/man/create_project.Rd b/man/create_project.Rd index bc594862..43857297 100644 --- a/man/create_project.Rd +++ b/man/create_project.Rd @@ -18,6 +18,7 @@ This function creates a new RStudio project with \code{checklist} functionality. Other setup: \code{\link{create_package}()}, \code{\link{prepare_ghpages}()}, +\code{\link{set_license}()}, \code{\link{setup_package}()}, \code{\link{setup_project}()}, \code{\link{setup_source}()} diff --git a/man/organisation.Rd b/man/organisation.Rd index a76835a4..aa2ca14f 100644 --- a/man/organisation.Rd +++ b/man/organisation.Rd @@ -76,10 +76,15 @@ Set to \code{NA_character_} in case you don't want to set a funder. \item \code{rightsholder}: the rightsholder. Defaults to \code{"Research Institute for Nature and Forest (INBO)"}. Set to \code{NA_character_} in case you don't want to set a rightsholder. -\item \code{organisation}: a named list with one or more organisation defaults. +\item \code{organisation}: a named list with one or more organisation default +rules. The names of the element must match the e-mail domain name of the organisation. -Every element should be a named list containing ´affiliation\code{and}orcid\code{. }affiliation\verb{is a character vector with the approved organisation names in one or more languages.}orcid = TRUE` indicated a mandatory ORCiD for every member. +Every element should be a named list containing \code{affiliation} and +\code{orcid}. +\code{affiliation} is a character vector with the approved organisation +names in one or more languages. +\code{orcid = TRUE} indicated a mandatory ORCiD for every member. Use an empty list in case you don't want to set this. } } diff --git a/man/prepare_ghpages.Rd b/man/prepare_ghpages.Rd index 2feaefe9..c5404c75 100644 --- a/man/prepare_ghpages.Rd +++ b/man/prepare_ghpages.Rd @@ -19,6 +19,7 @@ Prepare a \code{gh-pages} branch with a place holder page Other setup: \code{\link{create_package}()}, \code{\link{create_project}()}, +\code{\link{set_license}()}, \code{\link{setup_package}()}, \code{\link{setup_project}()}, \code{\link{setup_source}()} diff --git a/man/set_license.Rd b/man/set_license.Rd new file mode 100644 index 00000000..4d57ef6d --- /dev/null +++ b/man/set_license.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/set_license.R +\name{set_license} +\alias{set_license} +\title{Set the proper license} +\usage{ +set_license(x = ".") +} +\arguments{ +\item{x}{Either a \code{checklist} object or a path to the source code. +Defaults to \code{.}.} +} +\description{ +Set the proper license +} +\seealso{ +Other setup: +\code{\link{create_package}()}, +\code{\link{create_project}()}, +\code{\link{prepare_ghpages}()}, +\code{\link{setup_package}()}, +\code{\link{setup_project}()}, +\code{\link{setup_source}()} +} +\concept{setup} diff --git a/man/setup_package.Rd b/man/setup_package.Rd index fb1dd23f..40bc326a 100644 --- a/man/setup_package.Rd +++ b/man/setup_package.Rd @@ -41,6 +41,7 @@ Other setup: \code{\link{create_package}()}, \code{\link{create_project}()}, \code{\link{prepare_ghpages}()}, +\code{\link{set_license}()}, \code{\link{setup_project}()}, \code{\link{setup_source}()} } diff --git a/man/setup_project.Rd b/man/setup_project.Rd index b48fa57d..9a81262c 100644 --- a/man/setup_project.Rd +++ b/man/setup_project.Rd @@ -19,6 +19,7 @@ Other setup: \code{\link{create_package}()}, \code{\link{create_project}()}, \code{\link{prepare_ghpages}()}, +\code{\link{set_license}()}, \code{\link{setup_package}()}, \code{\link{setup_source}()} } diff --git a/man/setup_source.Rd b/man/setup_source.Rd index 000346f1..4d5b2d73 100644 --- a/man/setup_source.Rd +++ b/man/setup_source.Rd @@ -30,6 +30,7 @@ Other setup: \code{\link{create_package}()}, \code{\link{create_project}()}, \code{\link{prepare_ghpages}()}, +\code{\link{set_license}()}, \code{\link{setup_package}()}, \code{\link{setup_project}()} } diff --git a/pkgdown/extra.css b/pkgdown/extra.css index 00938dd1..ba8bfe49 100644 --- a/pkgdown/extra.css +++ b/pkgdown/extra.css @@ -19,12 +19,14 @@ a:hover { .navbar, .label-default, .navbar-default .navbar-nav>.active>a, .navbar-default .navbar-nav>.active>a:hover, .navbar-default .navbar-nav>.active>a:focus { - background-color: #356196; + background-color: #356196 !important; } -.navbar-default .navbar-link, -.navbar-default .navbar-nav>li>a { - color: #ffffff; +.navbar, +.navbar-brand, +.nav-link, +.nav-text.text-muted { + color: #ffffff !important; } .nav-pills li.active>a, .nav-pills li>a:hover { diff --git a/tests/testthat/test_d_update_citation.R b/tests/testthat/test_d_update_citation.R index 24962a85..753ee733 100644 --- a/tests/testthat/test_d_update_citation.R +++ b/tests/testthat/test_d_update_citation.R @@ -47,13 +47,41 @@ test_that("update_citation() works", { ) writeLines(old_citation, path(path, package, "inst", "CITATION")) + org <- organisation$new() + this_description <- desc(path(path, package)) this_description$add_urls("https://doi.org/10.5281/zenodo.4028303") - org <- organisation$new() - this_description$del_author(org$get_rightsholder) + gsub("([\\(\\)])", "\\\\\\1", org$get_rightsholder) |> + this_description$del_author() + expect_equal(length(this_description$get_authors()), 1) + this_description$write(path(path, package)) + expect_is( + z <- update_citation(path(path, package), quiet = TRUE), "checklist" + ) + expect_equal( + z$.__enclos_env__$private$notes, + c("no rightsholder listed", "no funder listed") + ) this_description$add_author(given = "unit", family = "test", role = "ctb") this_description$add_author(given = "test", family = "unit", role = "cph") this_description$write(path(path, package)) file_delete(path(path, package, ".Rbuildignore")) - expect_is(update_citation(path(path, package), quiet = TRUE), "checklist") + expect_is( + z <- update_citation(path(path, package), quiet = TRUE), "checklist" + ) + expect_equal( + z$.__enclos_env__$private$notes, + c( + "no funder listed", + sprintf("rightsholder differs from `%s`", org$get_rightsholder) + ) + ) + new_org <- organisation$new( + email = NA_character_, funder = NA_character_, rightsholder = "test" + ) + write_organisation(new_org, path(path, package)) + expect_is( + z <- update_citation(path(path, package), quiet = TRUE), "checklist" + ) + expect_length(z$.__enclos_env__$private$notes, 0) })