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

Revert "Sync with carpentries/sandpaper" #103

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 0 additions & 9 deletions R/utils-xml.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,23 +134,14 @@ add_anchors <- function(nodes, ids) {
anchor <- paste0(
"<a class='anchor' aria-label='", tranchor, "' href='#", ids, "'></a>"
)

for (i in seq_along(nodes)) {
heading <- nodes[[i]]

if (length(xml2::xml_contents(heading)) == 0) {
# skip empty headings
next
}

# Insert anchor in first element of header
xml2::xml_add_child(heading, xml2::read_xml(anchor[[i]]))

# fix for pkgdown 2.1.0 now adding in anchors for <section> tags
# rename our workbench translated sections <workbench-section>
# this would require a lot more downstream work
# sections <- xml2::xml_parent(heading)
# xml2::xml_set_name(sections, "workbench-section")
}
}

Expand Down
2 changes: 1 addition & 1 deletion R/utils-yaml.R
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ create_pkgdown_yaml <- function(path) {
branch = siQuote(usr$branch),
contact = siQuote(usr$contact),
# What carpentry are we dealing with?
carpentry_name = siQuote(which_carpentry(usr$carpentry, usr$carpentry_description)),
carpentry_name = siQuote(which_carpentry(usr$carpentry)),
carpentry = siQuote(usr$carpentry),
carpentry_icon = siQuote(which_icon_carpentry(usr$carpentry)),
license = siQuote(usr$license),
Expand Down
11 changes: 3 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,15 @@ create_description <- function(path) {
desc$write(fs::path(path_site(path), "DESCRIPTION"))
}

which_carpentry <- function(carpentry, carpentry_description = NULL) {
if (!is.null(carpentry_description)) {
return(carpentry_description)
}
which_carpentry <- function(carpentry) {
switch(carpentry,
lc = "Library Carpentry",
dc = "Data Carpentry",
swc = "Software Carpentry",
cp = "The Carpentries",
incubator = "Carpentries Incubator",
lab = "Carpentries Lab",
# Default: match the input
carpentry
l2d = "l2d"
)
}

Expand All @@ -211,8 +207,7 @@ which_icon_carpentry <- function(carpentry) {
cp = "carpentries",
incubator = "incubator",
lab = "lab",
# Default: match the input
carpentry
l2d = "l2d"
)
}

Expand Down
6 changes: 0 additions & 6 deletions inst/templates/config-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@
# lc: Library Carpentry
# cp: Carpentries (to use for instructor training for instance)
# incubator: The Carpentries Incubator
# Note that you can also use a custom carpentry type. For more info,
# see the documentation: https://carpentries.github.io/sandpaper-docs/editing.html
carpentry: {{ carpentry }}

# Custom carpentry description
# This will be used as the alt text for the logo
# carpentry_description: "Custom Carpentry"

# Overall title for pages.
title: {{ title }}

Expand Down
12 changes: 0 additions & 12 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,3 @@ test_that("a sitemap can be generated for urls", {
urls <- c("https://example.com/one", "https://example.com/two")
expect_snapshot(urls_to_sitemap(urls))
})

test_that("which_carpentry_workshop works for default carpentries", {
expect_equal(which_carpentry("swc"), "Software Carpentry")
expect_equal(which_carpentry("dc"), "Data Carpentry")
expect_equal(which_carpentry("lc"), "Library Carpentry")
expect_equal(which_carpentry("cp"), "The Carpentries")
})

test_that("which_carpentry can take a custom description", {
expect_equal(which_carpentry("ice-cream", "Ice Cream Carpentry"), "Ice Cream Carpentry")
expect_equal(which_carpentry("mexican-guitars"), "mexican-guitars")
})
Loading