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

Refactor use_vignette() #1700

Merged
merged 3 commits into from
Nov 8, 2022
Merged

Refactor use_vignette() #1700

merged 3 commits into from
Nov 8, 2022

Conversation

jennybc
Copy link
Member

@jennybc jennybc commented Nov 8, 2022

Motivated by experiments made while updating R Packages

Basically I found it confusing that knitr was added to DESCRIPTION early on and then ... later ... rmarkdown was added.

I can't think of any reason why we had it this way and looking through git blame didn't shed any light either.

This seems more obvious and obviously correct to me.


BEFORE

> use_vignette("my-vignette")
✔ Adding 'knitr' to Suggests field in DESCRIPTIONSetting VignetteBuilder field in DESCRIPTION to 'knitr'Adding 'inst/doc' to '.gitignore'Creating 'vignettes/'Adding '*.html', '*.R' to 'vignettes/.gitignore'Adding 'rmarkdown' to Suggests field in DESCRIPTIONWriting 'vignettes/my-vignette.Rmd'Modify 'vignettes/my-vignette.Rmd'

AFTER

> use_vignette("my-vignette")
✔ Adding 'knitr' to Suggests field in DESCRIPTIONAdding 'rmarkdown' to Suggests field in DESCRIPTIONSetting VignetteBuilder field in DESCRIPTION to 'knitr'Adding 'inst/doc' to '.gitignore'Creating 'vignettes/'Adding '*.html', '*.R' to 'vignettes/.gitignore'Writing 'vignettes/my-vignette.Rmd'Modify 'vignettes/my-vignette.Rmd'

@@ -26,6 +26,8 @@ use_vignette <- function(name, title = name) {
check_vignette_name(name)

use_dependency("knitr", "Suggests")
use_dependency("rmarkdown", "Suggests")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hoisted this up out of a helper.

if (!"rmarkdown" %in% deps$package) {
ui_done("
Adding {ui_value('rmarkdown')} to {ui_field('Config/Needs/website')}")
use_description_list("Config/Needs/website", "rmarkdown")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're doing this here in use_article() specifically, we know enough to avoid adding markdown as an actual dependency in the case of an "articles only" package. I.e. then you only need it in Config/Needs/website.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems worthy of a news bullet.


if (!is.null(subdir)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drive-by change. I just prefer if (TRUE) instead of if (!TRUE).

@@ -54,15 +63,13 @@ use_vignette_template <- function(template, name, title, subdir = NULL) {
use_directory(path("vignettes", subdir))
}
use_git_ignore(c("*.html", "*.R"), directory = "vignettes")
use_dependency("rmarkdown", "Suggests")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't think of any reason why we did this here specifically 🤔

@jennybc jennybc requested a review from hadley November 8, 2022 20:41
@jennybc jennybc merged commit b9acf67 into main Nov 8, 2022
@jennybc jennybc deleted the refactor-use-vignette branch November 8, 2022 22:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants