pkgdown
pkgdown copied to clipboard
Consider not always generating pages from PR and issue templates
Summary
The documentation of build_home
states
build_home()
function generates pages at the top-level of the site including:
- The home page
- HTML files from any .md files in ./ or .github/.
I cannot think of a situation where it makes sense to always generate pages for pull request templates or issues templates, commonly located in the .github/
folder; see creating a pull request template.
Proposition
Add configuration meta$home$build_gh_templates
as per
home:
build_gh_templates: yes # default: no
and in build_home_md()
build_home_md <- function(pkg) {
mds <- dir_ls(pkg$src_path, glob = "*.md")
# Also looks in .github, if it exists
github_path <- path(pkg$src_path, ".github")
if (dir_exists(github_path)) {
mds <- c(mds, dir_ls(github_path, glob = "*.md"))
}
# Remove files handled elsewhere
handled <- c("README.md", "LICENSE.md", "LICENCE.md", "NEWS.md", "cran-comments.md")
mds <- mds[!path_file(mds) %in% handled]
# Do not build 404 page if in-dev
if (pkg$development$in_dev) {
mds <- mds[fs::path_file(mds) != "404.md"]
}
+ # Do not always include GH templates
+ if (!isTRUE(pkg$meta$home$build_gh_templates)) {
+ mds <- mds[!fs::path_file(mds) %in% c("pull_request_template.md", "pull_request_template.md")]
+ }
lapply(mds, render_md, pkg = pkg)
invisible()
}
Alternative
Maybe on a broader scale, one could think of a file .pkgdownignore
to control which files/directories should be ignored by pkgdown.
Context
https://github.com/r-lib/pkgdown/blob/d5432a4e04655c6f9903196890f6bf166fbbd86b/R/build-home-md.R#L5-L9
Would you like to turn this into a PR? I don't think this needs to be an option, since I doubt it is useful to anyone.
I can do that. Could you clarify if you consider this a user-facing change that should be mentioned in NEWS.md
?
I'd say it's user facing enough to be mentioned.