Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudgallou committed Aug 25, 2024
1 parent bff48a8 commit 43fffff
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
17 changes: 9 additions & 8 deletions R/plume-quarto.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
))

#' @title PlumeQuarto class
#' @description Class that pushes author metadata in the YAML header
#' of Quarto files.
#' @description Class that pushes author metadata in YAML files or the YAML
#' header of Quarto files.
#' @examples
#' # Create a simple temporary file with a YAML header
#' # containing a title
Expand Down Expand Up @@ -53,7 +53,7 @@ PlumeQuarto <- R6Class(
public = list(
#' @description Create a `PlumeQuarto` object.
#' @param data A data frame containing author-related data.
#' @param file A `.qmd` file to insert author data into.
#' @param file A `.qmd`, `.yml` or `.yaml` file to insert author data into.
#' @param names A vector of key-value pairs specifying custom names to use,
#' where keys are default names and values their respective replacements.
#' @param roles A vector of key-value pairs defining roles where keys
Expand Down Expand Up @@ -82,12 +82,13 @@ PlumeQuarto <- R6Class(
private$id <- private$pick("id")
},

#' @description Push or update author information in a YAML header. The
#' generated YAML complies with Quarto's `r link("quarto_schemas")`.
#' @description Push or update author information in a YAML file or YAML
#' header. The generated YAML complies with Quarto's
#' `r link("quarto_schemas")`.
#' @details
#' If missing, `to_yaml()` pushes author information into a YAML header. If
#' already existing, the function replaces old `author` and `affiliations`
#' values with the ones provided in the input data.
#' If missing, `to_yaml()` inserts author information into the desired file.
#' Otherwise, the function replaces old `author` and `affiliations` values
#' with the ones provided in the input data.
#' @return The input `file` invisibly.
to_yaml = function() {
yaml_push(private$get_template(), file = private$file)
Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ knitr::opts_chunk$set(

plume provides tools for handling and generating author-related information for scientific writing in R Markdown and Quarto. The package implements two R6 classes:

- `PlumeQuarto`: class that allows you to push author metadata in the YAML header of Quarto files. The generated YAML complies with Quarto's [author and affiliations schemas](https://quarto.org/docs/journals/authors.html). This is the class to use if you work with journal templates.
- `PlumeQuarto`: class that allows you to push author metadata in YAML files or the YAML header of Quarto files. The generated YAML complies with Quarto's [author and affiliations schemas](https://quarto.org/docs/journals/authors.html). This is the class to use if you work with journal templates.

- `Plume`: class that generates author lists and other author-related information as character strings. This is an easy and convenient solution when you don't need preformatted documents.

Expand Down Expand Up @@ -64,7 +64,7 @@ tmp_file <- withr::local_tempfile(
)
```

`PlumeQuarto` lets you push author metadata in the YAML header of any `.qmd` file using the `to_yaml()` method.
`PlumeQuarto` lets you push author metadata in YAML files or the YAML header of any `.qmd` file using the `to_yaml()` method.

Consider the following example:

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ plume provides tools for handling and generating author-related
information for scientific writing in R Markdown and Quarto. The package
implements two R6 classes:

- `PlumeQuarto`: class that allows you to push author metadata in the
YAML header of Quarto files. The generated YAML complies with Quarto’s
[author and affiliations
- `PlumeQuarto`: class that allows you to push author metadata in YAML
files or the YAML header of Quarto files. The generated YAML complies
with Quarto’s [author and affiliations
schemas](https://quarto.org/docs/journals/authors.html). This is the
class to use if you work with journal templates.

Expand Down Expand Up @@ -74,8 +74,8 @@ Plume$new(encyclopedists)
#> # ℹ 2 more variables: affiliation <list>, role <list>
```

`PlumeQuarto` lets you push author metadata in the YAML header of any
`.qmd` file using the `to_yaml()` method.
`PlumeQuarto` lets you push author metadata in YAML files or the YAML
header of any `.qmd` file using the `to_yaml()` method.

Consider the following example:

Expand Down
17 changes: 9 additions & 8 deletions man/PlumeQuarto.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vignettes/plume.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ aut$set_corresponding_authors(everyone())
aut
```

## Pushing data into YAML headers
## Pushing data into a YAML or Quarto file

`PlumeQuarto` allows you to inject author metadata directly into the YAML header of `.qmd` files.
`PlumeQuarto` allows you to inject author metadata directly into YAML files or the YAML header of `.qmd` files.

Consider the following Quarto document:

Expand All @@ -219,7 +219,7 @@ tmp_file <- withr::local_tempfile(
cat(read_file(tmp_file))
```

You can push information from the input data into the YAML header using the `to_yaml()` method:
You can push information from the input data into the YAML or Quarto file using the `to_yaml()` method:

```{r, eval = FALSE}
aut <- PlumeQuarto$new(
Expand All @@ -237,7 +237,7 @@ cat(read_file(tmp_file))

Authors are listed in the order they're defined in the input data.

If the YAML header already has an `author` and `affiliations` keys, `to_yaml()` replaces old values with new ones.
If the YAML or Quarto file already has an `author` and `affiliations` keys, `to_yaml()` replaces old values with new ones.

```{r, eval = FALSE}
aut <- PlumeQuarto$new(
Expand Down

0 comments on commit 43fffff

Please sign in to comment.