Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

document how to load package with only extra Rd tags #1682

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions vignettes/extending.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@ topic$get_section("tip")

Note that there is no namespacing so if you're defining multiple new tags I recommend using your package name as the common prefix.

### Adding new .Rd tags to your workflow

To use your new tags in another package, you must tell roxygen to load the package inlcuding your new tags.

If, for example, you created some new tags in *packageFoo*, and would like to use these tags in your documentation for *packageBar*, append this like to the `DESCRIPTION` of *packageBar*:

```
Roxygen: list(packages = "packageFoo")
```

See [roxygen2::load_options()] for more details.

Notice that this only covers new `*.Rd` tags; if your workflow also depends on new roclets, see below.

## Creating a new roclet

Creating a new roclet is usually a two part process.
Expand Down Expand Up @@ -227,7 +241,7 @@ roxy_tag_parse.roxy_tag_memo <- function(x) {
parsed <- stringi::stri_match(str = x$raw, regex = "\\[(.*)\\](.*)")[1, ]

x$val <- list(
header = parsed[[2]],
header = parsed[[2]],
message = parsed[[3]]
)
x
Expand Down Expand Up @@ -278,7 +292,7 @@ For this roclet, we'll have `roclet_process()` collect all the memo tags into a
```{r}
roclet_process.roclet_memo <- function(x, blocks, env, base_path) {
results <- list()

for (block in blocks) {
tags <- block_get_tags(block, "memo")

Expand All @@ -287,7 +301,7 @@ roclet_process.roclet_memo <- function(x, blocks, env, base_path) {
results[[tag$val$header]] <- c(results[[tag$val$header]], msg)
}
}

results
}
```
Expand Down Expand Up @@ -345,7 +359,7 @@ above.
You can also add the roclet to the target package's DESCRIPTION file, like this:

```r
Roxygen: list(roclets = c("collate", "rd", "namespace", "yourPackage::roclet"))
Roxygen: list(roclets = c("collate", "rd", "namespace", "yourPackage::roclet"))
```

Optionally, you can add your roclet package to the target package as a `Suggests:` dependency:
Expand Down
Loading