diff --git a/.github/workflows/check_on_branch.yml b/.github/workflows/check_on_branch.yml deleted file mode 100644 index 9fa91f4..0000000 --- a/.github/workflows/check_on_branch.yml +++ /dev/null @@ -1,20 +0,0 @@ -on: - push: - branches-ignore: - - main - - master - - ghpages - -name: "check package with checklist" - -jobs: - check-package: - runs-on: ubuntu-latest - name: "check package" - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - permissions: - contents: read - steps: - - uses: inbo/actions/check_pkg@devel diff --git a/.github/workflows/check_on_main.yml b/.github/workflows/check_on_main.yml deleted file mode 100644 index ac20dc8..0000000 --- a/.github/workflows/check_on_main.yml +++ /dev/null @@ -1,19 +0,0 @@ -on: - push: - branches: - - main - - master -permissions: - contents: write - -name: "check package on main with checklist" - -jobs: - check-package: - runs-on: ubuntu-latest - name: "check package" - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - steps: - - uses: inbo/actions/check_pkg@devel diff --git a/.github/workflows/check_package.yml b/.github/workflows/check_package.yml index df97d5e..47f52c7 100644 --- a/.github/workflows/check_package.yml +++ b/.github/workflows/check_package.yml @@ -7,119 +7,23 @@ name: checklist jobs: check-package: - name: check package - runs-on: ubuntu-24.04 - - permissions: - contents: read - + name: check-package env: - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - _R_CHECK_SYSTEM_CLOCK_: false - RSPM: "https://packagemanager.rstudio.com/cran/__linux__/noble/latest" - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} - + RSPM: "https://packagemanager.posit.co/cran/__linux__/noble/latest" + permissions: + contents: read steps: - - name: Check out code - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 - with: - fetch-depth: 0 - - - name: Set up R - uses: r-lib/actions/setup-r@ff9d3a3fd8acec17e91f1d0a1876d95ad60cb519 - with: - r-version: release - extra-repositories: - https://cranhaven.r-universe.dev - https://inbo.r-universe.dev - - - name: Set up Pandoc - uses: r-lib/actions/setup-pandoc@f50f115c574d8cb2ddc24934af6bed478382b0e7 - - - name: Set up R dependencies - uses: r-lib/actions/setup-r-dependencies@2e3959d284a9ed60162f28a0f9891d1150f47f72 - with: - extra-packages: - any::checklist - any::covr - any::curl - any::cyclocomp - any::renv - any::roxygen2 - - - name: main branch - run: | - cd $GITHUB_WORKSPACE - CURRENT_COMMIT="$(git rev-parse HEAD)" - if git ls-remote --exit-code --heads origin main >/dev/null 2>&1; then - git fetch origin main:main --force - elif git ls-remote --exit-code --heads origin master >/dev/null 2>&1; then - git fetch origin master:master --force - else - echo "Neither main nor master branch found on origin." >&2 - exit 1 - fi - git checkout --force "$CURRENT_COMMIT" - shell: bash - - - name: Check R package - run: | - pak::local_install(dependencies = TRUE, upgrade = TRUE, ask = FALSE) - citeme::get_default_org_list() - pak::pkg_install("inbo/checklist@0.5.4") - checklist::check_package() - covr::codecov(quiet = FALSE, commit="'$GITHUB_SHA'") - pkgdown::build_site(preview = FALSE) - shell: Rscript {0} - + - name: "Check package with checklist" + uses: inbo/actions/check_pkg@composite deploy-pages: - name: deploy to gh-pages + name: deploy-gh-pages + runs-on: ubuntu-24.04 needs: check-package if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' - - runs-on: ubuntu-24.04 - permissions: contents: write - steps: - - - name: Check out code - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 - with: - fetch-depth: 0 - - - name: Check R package - run: checklist::set_tag() - shell: Rscript {0} - - - name: Deploy docs to gh-pages - run: | - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - - # Stash the built docs from the current workspace - DOCS_DIR="$GITHUB_WORKSPACE/docs" - - if git ls-remote --exit-code --heads origin gh-pages >/dev/null 2>&1; then - # Branch exists: check it out and amend - git fetch origin gh-pages - git checkout gh-pages - # Remove existing site content, preserve .git - git rm -rf --ignore-unmatch . - cp -r "$DOCS_DIR/." . - git add -A - git commit --amend --no-edit --allow-empty - git push --force origin gh-pages - else - # Branch does not exist: create orphan branch - git checkout --orphan gh-pages - git rm -rf . - cp -r "$DOCS_DIR/." . - git add -A - git commit -m "Deploy pkgdown site to gh-pages" - git push origin gh-pages - fi - shell: bash + - name: "Tag and deploy gh-pages" + uses: inbo/actions/check_deploy@composite diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 9b10b9f..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,30 +0,0 @@ -name: Releases - -on: - push: - tags: - - v* - workflow_run: - workflows: ["check package on main with checklist"] - types: - - completed - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v3 - - name: Get tag - run: | - git fetch --tags --force - TAG=$(git tag --contains $(git rev-parse HEAD)) - TAG_BODY=$(git tag --contains $(git rev-parse HEAD) --format='%(contents)') - echo "tag=$TAG" >> $GITHUB_ENV - echo "$TAG_BODY" > body.md - - uses: ncipollo/release-action@v1 - with: - name: Release ${{ env.tag }} - tag: ${{ env.tag }} - bodyFile: body.md diff --git a/.zenodo.json b/.zenodo.json index 9d763c4..c0b4e3c 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "citeme: Manage Person and Organisation Information", - "version": "0.1.2", + "version": "0.1.3", "license": "GPL-3.0", "upload_type": "software", "description": "
Manage person and organisation information with validation and formatting capabilities. Provides R6 classes for managing organisations and their members, with support for multiple languages, ORCID identifiers, ROR identifiers, licensing requirements, publisher information, and integration with citation management systems.<\/p>", diff --git a/CITATION.cff b/CITATION.cff index 7dd661c..f9b5b15 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -27,4 +27,4 @@ abstract: "Manage person and organisation information with validation and format identifiers: - type: url value: https://inbo.github.io/citeme/ -version: 0.1.2 +version: 0.1.3 diff --git a/DESCRIPTION b/DESCRIPTION index ca143e0..9eb1a3e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: citeme Title: Manage Person and Organisation Information -Version: 0.1.2 +Version: 0.1.3 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)")), @@ -30,6 +30,7 @@ Imports: Suggests: mockery, quarto, + rmarkdown, testthat (>= 3.0.0) VignetteBuilder: quarto diff --git a/NEWS.md b/NEWS.md index fbfefec..1dea1f8 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# citeme 0.1.3 + +* Handle `README` without language badge. + # citeme 0.1.2 * `ask_language()` now requires a vector of languages instead of an `org_list`. diff --git a/R/citation_meta_class.R b/R/citation_meta_class.R index 8d37cdd..503c269 100644 --- a/R/citation_meta_class.R +++ b/R/citation_meta_class.R @@ -45,7 +45,11 @@ citation_meta <- R6Class( }, stop("`path` type is not supported") ) - private$person <- meta$person + if (is.null(meta$person)) { + private$person <- person() + } else { + private$person <- meta$person + } private$meta <- meta$meta private$errors <- meta$errors private$notes <- meta$notes diff --git a/R/citation_quarto.R b/R/citation_quarto.R index eaf4c33..0b4afeb 100644 --- a/R/citation_quarto.R +++ b/R/citation_quarto.R @@ -4,17 +4,16 @@ citation_quarto <- function(meta) { assert_that(inherits(meta, "citation_meta")) assert_that(meta$get_type == "quarto") - index_file <- file.path(meta$get_path, "_quarto.yml", fsep = "/") - if (!file_test("-f", index_file)) { + if (!file_test("-f", meta$get_path)) { return( list( - errors = paste(index_file, "not found"), + errors = paste(meta$get_path, "not found"), warnings = character(0), notes = character(0) ) ) } - yaml <- read_yaml(index_file) + yaml <- quarto_yaml(meta$get_path) language <- yaml$lang if (has_name(yaml, "flandersqmd")) { yaml <- yaml$flandersqmd @@ -24,7 +23,8 @@ citation_quarto <- function(meta) { yaml$lang <- coalesce(yaml$lang, language) cit_meta <- yaml_individual(yaml = yaml) cit_meta$warnings <- cit_meta$notes <- character(0) - description <- quarto_description(meta$get_path) + dirname(meta$get_path) |> + quarto_description() -> description cit_meta$meta$description <- description$description cit_meta$errors <- c(cit_meta$errors, description$errors) cit_meta$meta$title <- paste0( diff --git a/R/quarto_description.R b/R/quarto_description.R index a3246e7..1f18777 100644 --- a/R/quarto_description.R +++ b/R/quarto_description.R @@ -9,7 +9,7 @@ quarto_description <- function(path) { list() |> setNames("text") |> extract_description() -> description - if (has_name(description, "meta") || length(description$errors) > 0) { + if (length(description$errors) == 0) { break } } diff --git a/R/quarto_yaml.R b/R/quarto_yaml.R new file mode 100644 index 0000000..11a98ef --- /dev/null +++ b/R/quarto_yaml.R @@ -0,0 +1,15 @@ +#' @importFrom utils file_test +#' @importFrom yaml read_yaml +quarto_yaml <- function(path) { + stopifnot("`path` is not an existing file" = file_test("-f", path)) + if (basename(path) == "_quarto.yml") { + return(read_yaml(path)) + } + stopifnot( + "please install the 'rmarkdown' package" = requireNamespace( + "rmarkdown", + quietly = TRUE + ) + ) + rmarkdown::yaml_front_matter(path) +} diff --git a/R/readme_badges.R b/R/readme_badges.R index b1c5af3..c940508 100644 --- a/R/readme_badges.R +++ b/R/readme_badges.R @@ -126,11 +126,14 @@ readme_badges <- function(text) { language_line <- grep(language_regexp, badges) errors <- c( errors, - "multiple language badges found in README.md"[length(language_line) > 1] - ) - notes <- c( - notes, - "no language badge found in README.md"[length(language_line) == 0] + "multiple language badges found in README.md"[length(language_line) > 1], + paste( + "No language badge found in README.md.", + "Fix this first as it is required to properly handle individuals and", + "organisations.", + "Use `citeme::add_badges(language = \"en-GB\")` to add a language badge", + "to your `README.md`." + )[length(language_line) == 0] ) if (length(language_line) == 1) { meta$language <- gsub(language_regexp, "\\1", badges[language_line]) diff --git a/inst/CITATION b/inst/CITATION index b9c8e5b..17a4a1f 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -2,12 +2,12 @@ citHeader("To cite `citeme` in publications please use:") # begin citeme entry bibentry( bibtype = "Manual", - title = "citeme: Manage Person and Organisation Information. Version 0.1.2", + title = "citeme: Manage Person and Organisation Information. Version 0.1.3", author = c(person(given = "Thierry", family = "Onkelinx")), year = 2026, url = "https://inbo.github.io/citeme/", abstract = "Manage person and organisation information with validation and formatting capabilities. Provides R6 classes for managing organisations and their members, with support for multiple languages, ORCID identifiers, ROR identifiers, licensing requirements, publisher information, and integration with citation management systems.", - textVersion = "Onkelinx, Thierry (2026) citeme: Manage Person and Organisation Information. Version 0.1.2. https://inbo.github.io/citeme/", + textVersion = "Onkelinx, Thierry (2026) citeme: Manage Person and Organisation Information. Version 0.1.3. https://inbo.github.io/citeme/", keywords = "organisation; author; standardisation; inbo_version", ) # end citeme entry diff --git a/tests/testthat/test-03-citation_quarto.R b/tests/testthat/test-03-citation_quarto.R index 80014c4..be790b0 100644 --- a/tests/testthat/test-03-citation_quarto.R +++ b/tests/testthat/test-03-citation_quarto.R @@ -120,7 +120,10 @@ test_that("citation_quarto returns error when _quarto.yml missing", { # Create mock citation_meta object meta <- structure( - list(get_type = "quarto", get_path = temp_dir), + list( + get_type = "quarto", + get_path = file.path(temp_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -134,7 +137,10 @@ test_that("citation_quarto processes valid quarto project", { # Create mock citation_meta object meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -156,7 +162,10 @@ test_that("citation_quarto extracts title with subtitle", { ) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -168,7 +177,10 @@ test_that("citation_quarto extracts title without subtitle", { quarto_dir <- create_temp_quarto(title = "Simple Title") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -183,7 +195,10 @@ test_that("citation_quarto extracts shorttitle", { ) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -195,7 +210,10 @@ test_that("citation_quarto extracts license", { quarto_dir <- create_temp_quarto(license = "GPL-3.0") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -222,7 +240,10 @@ test_that("citation_quarto returns error when license missing", { ) meta <- structure( - list(get_type = "quarto", get_path = temp_dir), + list( + get_type = "quarto", + get_path = file.path(temp_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -234,7 +255,10 @@ test_that("citation_quarto extracts publication_date", { quarto_dir <- create_temp_quarto(publication_date = "2024-01-15") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -246,7 +270,10 @@ test_that("citation_quarto handles embargo date", { quarto_dir <- create_temp_quarto(embargo = "2025-06-01") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -261,7 +288,10 @@ test_that("citation_quarto sets open access when no embargo", { quarto_dir <- create_temp_quarto() meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -273,7 +303,10 @@ test_that("citation_quarto extracts language", { quarto_dir <- create_temp_quarto(lang = "nl-BE") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -285,7 +318,10 @@ test_that("citation_quarto extracts keywords", { quarto_dir <- create_temp_quarto(keywords = c("keyword1", "keyword2")) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -303,7 +339,10 @@ test_that("citation_quarto notes missing keywords", { yaml::write_yaml(yaml_content, yaml_file) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -321,7 +360,10 @@ test_that("citation_quarto notes missing publisher", { yaml::write_yaml(yaml_content, yaml_file) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -333,7 +375,10 @@ test_that("citation_quarto validates publication_type", { quarto_dir <- create_temp_quarto(publication_type = "invalid-type") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -351,7 +396,10 @@ test_that("citation_quarto notes missing publication_type", { yaml::write_yaml(yaml_content, yaml_file) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -363,7 +411,10 @@ test_that("citation_quarto processes flandersqmd structure", { quarto_dir <- create_temp_quarto(use_flandersqmd = TRUE) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -376,7 +427,10 @@ test_that("citation_quarto processes book structure", { quarto_dir <- create_temp_quarto(use_book = TRUE) meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -389,7 +443,10 @@ test_that("citation_quarto extracts doi", { quarto_dir <- create_temp_quarto(doi = "10.5281/zenodo.1234567") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -401,7 +458,10 @@ test_that("citation_quarto sets upload_type to publication", { quarto_dir <- create_temp_quarto() meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" ) @@ -413,7 +473,10 @@ test_that("citation_quarto extracts community", { quarto_dir <- create_temp_quarto(community = "test-community") meta <- structure( - list(get_type = "quarto", get_path = quarto_dir), + list( + get_type = "quarto", + get_path = file.path(quarto_dir, "_quarto.yml", fsep = "/") + ), class = "citation_meta" )