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

show_news() only checks {pkg}/NEWS #2499

Open
arcresu opened this issue Feb 23, 2023 · 1 comment · May be fixed by #2551
Open

show_news() only checks {pkg}/NEWS #2499

arcresu opened this issue Feb 23, 2023 · 1 comment · May be fixed by #2551
Labels
feature a feature request or enhancement

Comments

@arcresu
Copy link

arcresu commented Feb 23, 2023

The show_news() function is hard-coded to check only for NEWS in a package directory:

news_path <- path(pkg$path, "NEWS")

However (from the docs of utils::news()):

[...] it is attempted to read its news in structured form from files ‘inst/NEWS.Rd’, ‘NEWS.md’ (since R version 3.6.0, needs packages commonmark and xml2 to be available), ‘NEWS’ or ‘inst/NEWS’ (in that order).

This means that if a NEWS.md file exists, for example, there's a confusing error:

> show_news()
Error in `show_news()`:
! No NEWS found
Run `rlang::last_error()` to see where the error occurred.

It would be nice if show_news() could use the same search path as utils::news() does.

@jennybc
Copy link
Member

jennybc commented Nov 2, 2023

If you'd like to make a PR, you could adapt related logic from build_readme():

build_readme <- function(path = ".", quiet = TRUE, ...) {
pkg <- as.package(path)
regexp <- paste0(path_file(pkg$path), "/(inst/)?readme[.]rmd")
readme_path <- path_abs(dir_ls(pkg$path, ignore.case = TRUE, regexp = regexp, recurse = 1, type = "file"))
if (length(readme_path) == 0) {
cli::cli_abort("Can't find {.file README.Rmd} or {.file inst/README.Rmd}.")
}
if (length(readme_path) > 1) {
cli::cli_abort("Can't have both {.file README.Rmd} and {.file inst/README.Rmd}.")
}
build_rmd(readme_path, path = path, quiet = quiet, ...)
}

@jennybc jennybc added the feature a feature request or enhancement label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants