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

Adds "Getting help" to "Community" on homepage #2125

Merged
merged 4 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# pkgdown (development version)

* If `SUPPORT.md` is present in `/.github` folder, it will be included on
homepage as "Getting help" (@patilindrajeets, #2124).
Copy link
Member

Choose a reason for hiding this comment

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

Isn't your github user name @IndrajeetPatil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

LOL. Sorry, included the Twitter handle instead of GitHub! 😅


# pkgdown 2.0.4

* New `check_pkgdown()` provides a lightweight way to check that your
Expand Down
9 changes: 9 additions & 0 deletions R/build-home-community.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ has_coc <- function(path = ".") {
file_exists(path(path, '.github', 'CODE_OF_CONDUCT.md'))
}

has_support <- function(path = ".") {
file_exists(path(path, 'SUPPORT.md')) ||
file_exists(path(path, '.github', 'SUPPORT.md'))
}

data_home_sidebar_community <- function (pkg){

pkg <- as_pkgdown(pkg)
Expand All @@ -22,6 +27,10 @@ data_home_sidebar_community <- function (pkg){
links <- c(links, a(tr_("Code of conduct"), "CODE_OF_CONDUCT.html"))
}

if (has_support(pkg$src_path)) {
links <- c(links, a(tr_("Getting help"), "SUPPORT.html"))
}

if (is.null(links)) {
return("")
}
Expand Down
3 changes: 2 additions & 1 deletion tests/testthat/_snaps/build-home-community.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# handles coc if present
# handles CoC and SUPPORT if present

<div class='community'>
<h2 data-toc-skip>Community</h2>
<ul class='list-unstyled'>
<li><a href='CODE_OF_CONDUCT.html'>Code of conduct</a></li>
<li><a href='SUPPORT.html'>Getting help</a></li>
</ul>
</div>

4 changes: 4 additions & 0 deletions tests/testthat/assets/site-dot-github/.github/SUPPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Getting help with pkgdown

Thanks for using pkgdown. Before filing an issue, there are a few places
to explore and pieces to put together to make the process as smooth as possible.
3 changes: 2 additions & 1 deletion tests/testthat/test-build-home-community.R
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
test_that("handles coc if present", {
test_that("handles CoC and SUPPORT if present", {
# .github is build-ignored to prevent a NOTE about unexpected hidden directory
# so need to skip when run from R CMD check
skip_if_not(dir_exists(test_path("assets/site-dot-github/.github")))

pkg <- as_pkgdown(test_path("assets/site-dot-github"))
expect_true(has_coc(pkg$src_path))
expect_true(has_support(pkg$src_path))

# And added to sidebar
text <- data_home_sidebar_community(pkg)
Expand Down