Skip to content

Commit e7f7c2e

Browse files
committed
Add id attributes to anchors of members in Scaladoc searchbar
This allows to snap to a specific member after clicking, even if it is found under the same URL.
1 parent 8e2fab7 commit e7f7c2e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

scaladoc/src/dotty/tools/scaladoc/renderers/Locations.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ trait Locations(using ctx: DocContext):
8282

8383
def resolveRoot(dri: DRI, path: String): String = resolveRoot(rawLocation(dri), path)
8484
def absolutePath(dri: DRI, extension: String = "html"): String = rawLocation(dri).mkString("", "/", s".$extension")
85+
def absolutePathWithAnchor(dri: DRI, extension: String = "html"): String = s"${absolutePath(dri, extension)}#${dri.anchor}"
8586

8687
def resolveLink(dri: DRI, url: String): String =
8788
if URI(url).isAbsolute then url else resolveRoot(dri, url)

scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
133133
}.mkString
134134

135135
def mkEntry(dri: DRI, name: String, text: String, descr: String, kind: String) = jsonObject(
136-
"l" -> jsonString(absolutePath(dri)),
136+
"l" -> jsonString(absolutePathWithAnchor(dri)),
137137
"n" -> jsonString(name),
138138
"t" -> jsonString(text),
139139
"d" -> jsonString(descr),

0 commit comments

Comments
 (0)