Skip to content

Commit

Permalink
Add test:
Browse files Browse the repository at this point in the history
  - topic named "matches"
  - matches("A") still works
  • Loading branch information
dmurdoch committed Feb 14, 2024
1 parent 1a0da86 commit 82df973
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/_snaps/build-reference-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,31 @@
has_icons: no

# can use a selector name as a topic name

Code
data_reference_index(pkg)
Output
pagetitle: Function reference
rows:
- title: bla
slug: bla
desc: ~
is_internal: no
- topics:
- path: matches.html
title: matches
aliases: matches()
icon: ~
- path: A.html
title: A
aliases: A()
icon: ~
names:
- matches
- A
row_has_icons: no
is_internal: no
has_icons: no

6 changes: 6 additions & 0 deletions tests/testthat/assets/reference-selector/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Package: testpackage
Version: 1.0.0
Title: A test package
Description: A test package
Authors@R: person("Hadley Wickham")
RoxygenNote: 7.3.1
4 changes: 4 additions & 0 deletions tests/testthat/assets/reference-selector/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Generated by roxygen2: do not edit by hand

export(A)
export(matches)
7 changes: 7 additions & 0 deletions tests/testthat/assets/reference-selector/R/funs.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#' matches
#' @export
matches <- function() {}

#' A
#' @export
A <- function() {}
1 change: 1 addition & 0 deletions tests/testthat/assets/reference-selector/_pkgdown.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
url: http://test.org
11 changes: 11 additions & 0 deletions tests/testthat/assets/reference-selector/man/A.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions tests/testthat/assets/reference-selector/man/matches.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/testthat/test-build-reference-index.R
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,13 @@ test_that("can use a topic from another package", {

expect_snapshot(data_reference_index(pkg))
})

test_that("can use a selector name as a topic name", {
meta <- list(reference = list(list(
title = "bla",
contents = c("matches", "matches('A')")
)))
pkg <- as_pkgdown(test_path("assets/reference-selector"), override = meta)

expect_snapshot(data_reference_index(pkg))
})

0 comments on commit 82df973

Please sign in to comment.