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

Consider not always generating pages from PR and issue templates #2358

Closed
hsloot opened this issue Oct 25, 2023 · 3 comments · Fixed by #2362
Closed

Consider not always generating pages from PR and issue templates #2358

hsloot opened this issue Oct 25, 2023 · 3 comments · Fixed by #2362
Labels
feature a feature request or enhancement home 🏠

Comments

@hsloot
Copy link
Contributor

hsloot commented Oct 25, 2023

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

# 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"))
}

@hadley
Copy link
Member

hadley commented Oct 30, 2023

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.

@hadley hadley added feature a feature request or enhancement home 🏠 labels Oct 30, 2023
@hsloot
Copy link
Contributor Author

hsloot commented Oct 30, 2023

I can do that. Could you clarify if you consider this a user-facing change that should be mentioned in NEWS.md?

@hadley
Copy link
Member

hadley commented Oct 30, 2023

I'd say it's user facing enough to be mentioned.

hsloot added a commit to hsloot/pkgdown that referenced this issue Oct 30, 2023
hadley added a commit that referenced this issue Apr 12, 2024
SebKrantz pushed a commit to SebKrantz/pkgdown that referenced this issue Jun 1, 2024
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 home 🏠
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants