Skip to content

Commit

Permalink
Update docs and lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dieghernan committed Aug 2, 2023
1 parent 98314f3 commit 50930ce
Show file tree
Hide file tree
Showing 41 changed files with 475 additions and 357 deletions.
2 changes: 1 addition & 1 deletion R/assertions.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ is.cff <- function(x) {
#' Check if a object is cff file
#' @param x object to be evaluated
#' @noRd
is.cff.file <- function(x) {
is.cff_file <- function(x) {
if (!inherits(x, "character")) {
return(FALSE)
}
Expand Down
6 changes: 3 additions & 3 deletions R/cff_create.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @return A [`cff`] list object.
#'
#' @family core functions
#' @family Core functions
#'
#' @export
#'
Expand Down Expand Up @@ -60,8 +60,8 @@
#' for additional details.
#'
#' If `x` is a path to a DESCRIPTION file or `inst/CITATION`, is not present on
#' your package, **cffr** would auto-generate a `preferred-citation` key using
#' the information provided on that file.
#' your package, \CRANpkg{cffr} would auto-generate a `preferred-citation` key
#' using the information provided on that file.
#'
#' By default, only persons whose role in the DESCRIPTION file of the package
#' is author (`"aut"`) or maintainer (`"cre"`) are considered to be authors
Expand Down
6 changes: 3 additions & 3 deletions R/cff_from_bibtex.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
#' @param encoding Encoding to be assumed for `x`. See [readLines()].
#' @param ... Other arguments passed to [bibtex::read.bib()].
#'
#' @family bibtex
#' @family BibTeX helpers
#'
#' @return A [`cff`] object ready to be used on [cff_create()].
#'
#' @export
#'
#' @details
#'
#' This function requires the package **bibtex** (>= 0.5.0), that is listed
#' as `Suggested` by **cffr**.
#' This function requires the package \CRANpkg{bibtex} (>= 0.5.0), that is
#' listed as `Suggested` by \CRANpkg{cffr}.
#'
#' @seealso
#'
Expand Down
2 changes: 1 addition & 1 deletion R/cff_gha_update.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#' }
#' @export
#'
#' @family git
#' @family Git helpers
cff_gha_update <- function(path = ".",
overwrite = FALSE) {
destdir <- file.path(path, ".github", "workflows")
Expand Down
6 changes: 4 additions & 2 deletions R/cff_git_hook.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#'
#' @name cff_git_hook
#'
#' @family git
#' @family Git helpers
#'
#' @export
#'
Expand Down Expand Up @@ -85,7 +85,9 @@ cff_git_hook_remove <- function() {
hookfile <- file.path(".git", "hooks", "pre-commit")

if (file.exists(hookfile)) {
cli::cli_alert_info("Removing git pre-commit hook (was on {.path {hookfile}})")
cli::cli_alert_info(
"Removing git pre-commit hook (was on {.path {hookfile}})"
)
unlink(hookfile, force = TRUE)
}

Expand Down
5 changes: 2 additions & 3 deletions R/cff_parse_citation.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#'
#' @export
#'
#' @family parsers
#' @family Parsers
#'
#' @param bib A `bibentry` object, either created with [bibentry()]
#' (preferred) or [citEntry()].
Expand Down Expand Up @@ -188,8 +188,7 @@ cff_parse_citation <- function(bib) {

# Remove non-valid names
validnames <- cff_schema_definitions_refs()
parse_cit <- parse_cit[names(parse_cit) %in%
c(validnames)]
parse_cit <- parse_cit[names(parse_cit) %in% validnames]

parse_cit <- drop_null(parse_cit)
parse_cit_result <- as.cff(parse_cit)
Expand Down
11 changes: 6 additions & 5 deletions R/cff_parse_person.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#'
#' @export
#'
#' @family parsers
#' @family Parsers
#'
#' @param person A `person` object created with [person()] or a
#' character string. See **Details**.
Expand Down Expand Up @@ -83,8 +83,10 @@ cff_parse_person <- function(person) {
# Special case for R Core Team


if (is.substring(clean_str(person$given), "R Core") &&
is.substring(person$family, "Team")) {
if (all(
is.substring(clean_str(person$given), "R Core"),
is.substring(person$family, "Team")
)) {
person <- person(
given = paste(
clean_str(person$given),
Expand Down Expand Up @@ -157,8 +159,7 @@ cff_parse_person <- function(person) {
} else {
cff_schema_definitions_person()
}
parsed_person <- parsed_person[names(parsed_person) %in%
definition]
parsed_person <- parsed_person[names(parsed_person) %in% definition]

parsed_person <- as.cff(parsed_person)
parsed_person
Expand Down
2 changes: 1 addition & 1 deletion R/cff_read.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' A `cff` object. Under the hood, a `cff` object is a regular [`list`] object
#' with a special [print()] method.
#'
#' @family core functions
#' @family Core functions
#'
#' @param path The path to a `CITATION.cff` file.
#' @param ... Named arguments to be used for creating a [`cff`] object. See
Expand Down
13 changes: 7 additions & 6 deletions R/cff_to_bibtex.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#' - `all`: A combination of the previous two options. This would extract
#' both the preferred citation info and the references.
#'
#' @family bibtex
#' @family BibTeX helpers
#'
#' @return A `bibentry` object or a list of `bibentry` objects. This could
#' be parsed to BibTeX using [toBibtex()]
Expand Down Expand Up @@ -91,7 +91,7 @@ cff_to_bibtex <- function(x,
return(NULL)
}

if (is.cff.file(x)) {
if (is.cff_file(x)) {
x <- cff_read(x)
}

Expand Down Expand Up @@ -195,8 +195,10 @@ cff_bibtex_parser <- function(x) {
# Check if it may be an incollection
# Hint: is misc with collection-title and publisher

if (tobibentry$bibtype == "misc" && !is.null(x$`collection-title`) &&
!is.null(x$publisher)) {
if (all(
tobibentry$bibtype == "misc", !is.null(x$`collection-title`),
!is.null(x$publisher)
)) {
tobibentry$bibtype <- "incollection"
}

Expand Down Expand Up @@ -225,8 +227,7 @@ cff_bibtex_parser <- function(x) {
))

# As a fallback, use also location
if (is.null(tobibentry$address) &&
!is.null(x$location)) {
if (is.null(tobibentry$address) && !is.null(x$location)) {
tobibentry$address <- x$location$name
}

Expand Down
2 changes: 1 addition & 1 deletion R/cff_validate.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#' ```
#' @export
#'
#' @family core functions
#' @family Core functions
#'
#' @seealso
#' ```{r, echo=FALSE, results='asis'}
Expand Down
2 changes: 1 addition & 1 deletion R/cff_write.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#' function is basically a wrapper around [cff_create()] to both create the
#' [`cff`] object and writes it out to a YAML-formatted file in one command.
#'
#' @family core functions
#' @family Core functions
#'
#' @param x The source that would be used for generating
#' the `CITATION.cff` file. It could be:
Expand Down
3 changes: 1 addition & 2 deletions R/parse_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,12 @@ parse_desc_contacts <- function(pkg) {
parse_desc_date_released <- function(pkg) {
# See https://cran.r-project.org/doc/manuals/R-exts.html#The-DESCRIPTION-file
date1 <- pkg$get("Date")
# CRAN/BioConductor
# This is for CRAN/BioConductor packages
date2 <- pkg$get("Date/Publication")
# R-universe
date3 <- pkg$get("Packaged")
# Work with vector
alldates <- unname(c(date1, date2, date3))
x <- alldates[3]
clean_dates <- lapply(alldates, function(x) {
if (is.na(x) || is.null(x)) {
return(NULL)
Expand Down
2 changes: 1 addition & 1 deletion R/utils-bibtex.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#'
#' @param x A string, possibly encoded in UTF-8 encoding system.
#'
#' @family bibtex
#' @family BibTeX helpers
#'
#' @seealso [tools::encoded_text_to_latex()]
#'
Expand Down
2 changes: 1 addition & 1 deletion R/utils-schema.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#'
#' ```
#'
#' @family schema
#' @family Schemas
#'
#' @export
#'
Expand Down
8 changes: 6 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ fuzzy_keys <- function(keys) {
))

# Message
ll <- paste0("{.dt ", names_fuzzy, "}{.dl ", keys_match, "}\n", collapse = "")
cli::cli_alert_warning(paste0("Found misspelled keys. Trying to map:\n", ll))
ll <- paste0("{.dt ", names_fuzzy, "}{.dl ", keys_match, "}\n",
collapse = ""
)
cli::cli_alert_warning(
paste0("Found misspelled keys. Trying to map:\n", ll)
)

# Modify names
names[!is_valid_key] <- keys_match
Expand Down
14 changes: 6 additions & 8 deletions R/write_bib.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Create a .bib file
#' Create a `.bib` file
#'
#' Creates a .bib file from a `bibentry` object(s)
#' Creates `a .bib` file from a `bibentry` object(s)
#'
#' @param x A `bibentry` object created with:
#' - [cff_to_bibtex()]
Expand All @@ -13,7 +13,7 @@
#' @param ascii Whether to write the entries using ASCII characters only or not.
#'
#' @export
#' @family bibtex
#' @family BibTeX helpers
#'
#' @return Writes an `.bib` file specified on `file` parameter and the
#' equivalent `Bibtex` object created with [utils::toBibtex()]. It also
Expand All @@ -26,9 +26,9 @@
#'
#' @seealso `vignette("bibtex_cff", "cffr")`, [knitr::write_bib()] and the
#' following packages:
#' - [bibtex](https://github.com/ropensci/bibtex) package.
#' - [RefManageR](https://github.com/ropensci/RefManageR) package.
#' - [rbibutils](https://github.com/GeoBosh/rbibutils/)
#' - \CRANpkg{bibtex}.
#' - \CRANpkg{RefManageR}
#' - \CRANpkg{rbibutils}
#'
#' @examples
#'
Expand All @@ -53,11 +53,9 @@ write_bib <- function(x,

if (ascii) {
# Base encoding as per file()
encoding <- getOption("encoding")
btex <- encoded_utf_to_latex(btex)
class(btex) <- "Bibtex"
} else {
encoding <- "UTF-8"
btex <- enc2utf8(btex)
}

Expand Down
2 changes: 1 addition & 1 deletion R/write_citation.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @inheritDotParams cff_to_bibtex
#'
#' @export
#' @family bibtex
#' @family BibTeX helpers
#'
#' @return Writes an `inst/CITATION` file and (invisibly) returns the
#' `bibentry` object that has been written to the file.
Expand Down
66 changes: 1 addition & 65 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ file and the `CITATION` file (if present) of your package. Note that
**cffr** works best if your package pass
`R CMD check/devtools::check()`.

As per 2023-08-02 there are at least 204 repos on GitHub using **cffr**.
As per 2023-08-02 there are at least 202 repos on GitHub using **cffr**.
[Check them out
here](https://github.com/search?q=cffr%20path%3A**%2FCITATION.cff&type=code).

Expand Down Expand Up @@ -566,25 +566,6 @@ test <- cff_create("rmarkdown")
- family-names: Attali.
given-names: Dean
year: '2023'
- type: software
title: dygraphs
abstract: 'dygraphs: Interface to ''Dygraphs'' Interactive Time Series Charting
Library'
notes: Suggests
url: https://github.com/rstudio/dygraphs
repository: https://CRAN.R-project.org/package=dygraphs
authors:
- family-names: Vanderkam
given-names: Dan
- family-names: Allaire
given-names: JJ
- family-names: Owen
given-names: Jonathan
- family-names: Gromer
given-names: Daniel
- family-names: Thieurmel
given-names: Benoit
year: '2023'
- type: software
title: fs
abstract: 'fs: Cross-Platform File System Operations Based on ''libuv'''
Expand All @@ -601,26 +582,6 @@ test <- cff_create("rmarkdown")
given-names: Gábor
email: [email protected]
year: '2023'
- type: software
title: rsconnect
abstract: 'rsconnect: Deploy Docs, Apps, and APIs to ''Posit Connect'', ''shinyapps.io'',
and ''RPubs'''
notes: Suggests
url: https://github.com/rstudio/rsconnect
repository: https://CRAN.R-project.org/package=rsconnect
authors:
- family-names: Atkins
given-names: Aron
email: [email protected]
- family-names: Allen
given-names: Toph
- family-names: Wickham
given-names: Hadley
- family-names: McPherson
given-names: Jonathan
- family-names: Allaire
given-names: JJ
year: '2023'
- type: software
title: downlit
abstract: 'downlit: Syntax Highlighting and Automatic Linking'
Expand All @@ -633,19 +594,6 @@ test <- cff_create("rmarkdown")
email: [email protected]
year: '2023'
version: '>= 0.4.0'
- type: software
title: katex
abstract: 'katex: Rendering Math to HTML, ''MathML'', or R-Documentation Format'
notes: Suggests
url: https://docs.ropensci.org/katex/
repository: https://CRAN.R-project.org/package=katex
authors:
- family-names: Ooms
given-names: Jeroen
email: [email protected]
orcid: https://orcid.org/0000-0002-4035-0289
year: '2023'
version: '>= 1.4.0'
- type: software
title: sass
abstract: 'sass: Syntactically Awesome Style Sheets (''Sass'')'
Expand Down Expand Up @@ -757,18 +705,6 @@ test <- cff_create("rmarkdown")
given-names: Davis
email: [email protected]
year: '2023'
- type: software
title: cleanrmd
abstract: 'cleanrmd: Clean Class-Less ''R Markdown'' HTML Documents'
notes: Suggests
url: https://pkg.garrickadenbuie.com/cleanrmd/
repository: https://CRAN.R-project.org/package=cleanrmd
authors:
- family-names: Aden-Buie
given-names: Garrick
email: [email protected]
orcid: https://orcid.org/0000-0002-7111-0077
year: '2023'
- type: software
title: withr
abstract: 'withr: Run Code ''With'' Temporarily Modified Global State'
Expand Down
Loading

0 comments on commit 50930ce

Please sign in to comment.