Skip to content

Commit 8751161

Browse files
committed
Use globbing rather than regex syntax
1 parent ebc8c46 commit 8751161

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ class ApidocDirective(allClassesAndObjects: IndexedSeq[String]) extends InlineDi
5858
} else
5959
allClasses.filter(_.contains(query.pattern)) match {
6060
case Seq() =>
61-
// No matches? only then try as regex.
62-
val regex = (query.pattern + "$").r
61+
// No matches? then try globbing
62+
val regex = (query.pattern.replaceAll("\\.", "\\\\.").replaceAll("\\*", ".*") + "$").r
6363
allClasses.filter(cls => regex.findFirstMatchIn(cls).isDefined) match {
6464
case Seq() =>
65-
throw new java.lang.IllegalStateException(s"Class not found for by @apidoc[$query]")
65+
throw new java.lang.IllegalStateException(s"Class not found for @apidoc[$query]")
6666
case results =>
6767
renderMatches(query, results, node, visitor, printer)
6868
}

src/test/scala/com.lightbend.paradox/apidoc/ApidocDirectiveSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
9393
}
9494

9595
it should "allow linking to a typed class that is also present in classic" in {
96-
markdown("@apidoc[typed.*Replicator$]") shouldEqual
96+
markdown("@apidoc[typed.*.Replicator$]") shouldEqual
9797
html(
9898
"""<p><span class="group-scala">
9999
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/ddata/typed/scaladsl/Replicator$.html">Replicator</a></span><span class="group-java">

0 commit comments

Comments
 (0)