Skip to content

Commit

Permalink
Fix malformed URI issues in Inkuire in Scaladoc
Browse files Browse the repository at this point in the history
  • Loading branch information
jchyb committed Feb 22, 2022
1 parent c5fcfdf commit e834986
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
9 changes: 6 additions & 3 deletions scaladoc-js/main/src/searchbar/SearchbarComponent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
icon.classList.add(m.entryType.take(2))

val resultA = document.createElement("a").asInstanceOf[html.Anchor]
// Inkuire pageLocation should start with e (external)
// or i (internal). The rest of the string is an absolute
// or relative URL
resultA.href =
if(new URI(m.pageLocation).isAbsolute()) {
m.pageLocation
if (m.pageLocation(0) == 'e') {
m.pageLocation.substring(1)
} else {
Globals.pathToRoot + m.pageLocation
Globals.pathToRoot + m.pageLocation.substring(1)
}
resultA.text = m.functionName
resultA.onclick = (event: Event) =>
Expand Down
3 changes: 2 additions & 1 deletion scaladoc/src/dotty/tools/scaladoc/Inkuire.scala
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ object Inkuire {
name: String,
packageName: String,
uri: String,
isLocationExternal: Boolean,
entryType: String
)

Expand Down Expand Up @@ -333,7 +334,7 @@ object Inkuire {
("signature", serialize(e.signature)),
("name", serialize(e.name)),
("packageName", serialize(e.packageName)),
("uri", serialize(e.uri)),
("uri", serialize((if e.isLocationExternal then "e" else "i") + e.uri)),
("entryType", serialize(e.entryType))
)
}
Expand Down
2 changes: 2 additions & 0 deletions scaladoc/src/dotty/tools/scaladoc/tasty/InkuireSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ trait InkuireSupport(using DocContext) extends Resources:
name = name,
packageName = ownerName,
uri = methodSymbol.dri.externalLink.getOrElse(escapedAbsolutePathWithAnchor(methodSymbol.dri)),
isLocationExternal = methodSymbol.dri.externalLink.isDefined,
entryType = "def"
)
val curriedSgn = sgn.copy(signature = Inkuire.curry(sgn.signature))
Expand Down Expand Up @@ -143,6 +144,7 @@ trait InkuireSupport(using DocContext) extends Resources:
name = name,
packageName = ownerName,
uri = valSymbol.dri.externalLink.getOrElse(escapedAbsolutePathWithAnchor(valSymbol.dri)),
isLocationExternal = valSymbol.dri.externalLink.isDefined,
entryType = "val"
)
val curriedSgn = sgn.copy(signature = Inkuire.curry(sgn.signature))
Expand Down

0 comments on commit e834986

Please sign in to comment.