Skip to content

Commit

Permalink
Add support to the YAML key roles (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgallou committed Jul 30, 2023
2 parents 66ee234 + 5e51400 commit b8625ef
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 269 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export(Plume)
export(PlumeQuarto)
export(enumerate)
export(orcid)
export(plm_push)
export(plm_template)
export(sequential)
export(set_default_names)
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

## Minor improvements and bug fixes

* `PlumeQuarto` now handles roles via the `roles` YAML key (#5).

* New method `get_orcids()` that returns authors' ORCID.

* Phone numbers are now set using the variable and attribute `phone` (#4).

* plume methods now print outputs in the same way.

* New function `plm_push()` that can be used to insert author information into a Quarto document from a separate R script.

* `get_author_list()` now accepts `format = ""` to return author names only. This is equivalent to `format = NULL` (#3).

* plume classes now error when a given or family name is `NA` or a blank string.
Expand Down
2 changes: 1 addition & 1 deletion R/Plume.R
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Plume <- R6Class(
last = sep_last
), .by = all_of(pars$grp_var))
out <- collapse_cols(out, pars$format, sep = pars$divider)
new_plm_agt(out, name = "contributions")
new_plm(out)
}
),

Expand Down
15 changes: 15 additions & 0 deletions R/PlumeQuarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,28 @@ PlumeQuarto <- R6Class(
phone = private$get("phone"),
fax = private$get("fax"),
url = private$get("url"),
roles = private$author_roles(),
note = private$author_notes(),
attribute = private$author_attributes(),
affiliations = private$author_affiliations(),
metadata = private$author_metadata()
)
},

author_roles = function() {
col <- private$names$role
if (!private$has_col(col)) {
return()
}
out <- unnest_drop(private$plume, cols = all_of(col))
out <- summarise(
out,
`_` = list(tolower(.data[[col]])),
.by = all_of(private$names$id)
)
out[["_"]]
},

author_notes = function() {
col <- private$names$note
if (!private$has_col(col)) {
Expand Down
83 changes: 0 additions & 83 deletions R/plm_push.R

This file was deleted.

4 changes: 0 additions & 4 deletions R/utils-plm.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ new_plm <- function(x, ..., class = character()) {
structure(x, ..., class = c(class, "plm", "character"))
}

new_plm_agt <- function(x, name) {
new_plm(x, name = name, class = "plm_agt")
}

compare_proxy.plm <- function(x, path = "x") {
x <- unstructure(x)
NextMethod()
Expand Down
5 changes: 3 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ library(plume)
encyclopedists
aut <- PlumeQuarto$new(encyclopedists)
aut
Plume$new(encyclopedists)
```

```{r, include = FALSE}
Expand All @@ -68,11 +67,13 @@ cat(readr::read_file(tmp))
```

```{r, eval = FALSE}
aut <- PlumeQuarto$new(encyclopedists, names = c(role = "role_n"))
aut$set_corresponding_authors(1, 4)
aut$to_yaml("file.qmd")
```

```{r, echo = FALSE, comment = ""}
aut <- PlumeQuarto$new(encyclopedists, names = c(role = "role_n"))
aut$set_corresponding_authors(1, 4)
aut$to_yaml(tmp)
cat(readr::read_file(tmp))
Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ encyclopedists
#> 4 Jean Le Rond d'… alem… <NA> 0000… Writing Superv… contri… superv… born…
#> # ℹ 2 more variables: affiliation1 <chr>, affiliation2 <chr>

aut <- PlumeQuarto$new(encyclopedists)
aut
Plume$new(encyclopedists)
#> # A tibble: 4 × 11
#> id given_name family_name literal_name initials email orcid phone note
#> <int> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
Expand All @@ -76,6 +75,7 @@ Consider the following example:
Qui scribit bis legit

``` r
aut <- PlumeQuarto$new(encyclopedists, names = c(role = "role_n"))
aut$set_corresponding_authors(1, 4)
aut$to_yaml("file.qmd")
```
Expand All @@ -90,6 +90,9 @@ aut$to_yaml("file.qmd")
orcid: 0000-0000-0000-0001
email: diderot@encyclopediste.fr
phone: 00 00 00 01
roles:
- writing
- supervision
note: born in 1713 in Langres
attribute:
corresponding: true
Expand All @@ -101,6 +104,8 @@ aut$to_yaml("file.qmd")
family: Rousseau
orcid: 0000-0000-0000-0002
email: rousseau@encyclopediste.fr
roles:
- writing
attribute:
corresponding: false
affiliations:
Expand All @@ -110,6 +115,8 @@ aut$to_yaml("file.qmd")
given: François-Marie
family: Arouet
email: arouet@encyclopediste.fr
roles:
- writing
note: also known as Voltaire
attribute:
corresponding: false
Expand All @@ -121,6 +128,9 @@ aut$to_yaml("file.qmd")
family: Le Rond d'Alembert
orcid: 0000-0000-0000-0003
email: alembert@encyclopediste.fr
roles:
- writing
- supervision
note: born in 1717 in Paris
attribute:
corresponding: true
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ reference:
contents:
- enumerate
- orcid
- plm_push
- plm_template
- sequential
- set_default_names
Expand Down
47 changes: 0 additions & 47 deletions man/plm_push.Rd

This file was deleted.

70 changes: 0 additions & 70 deletions tests/testthat/_snaps/plm-push.md

This file was deleted.

0 comments on commit b8625ef

Please sign in to comment.