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

Scaladoc - Inkuire search engine UI improvements #13052

Merged
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
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ object Build {

lazy val scalacOptionsDocSettings = Seq(
"-external-mappings:" +
".*scala.*::scaladoc3::http://dotty.epfl.ch/api/," +
".*scala.*::scaladoc3::https://dotty.epfl.ch/api/," +
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
"-skip-by-regex:.+\\.internal($|\\..+)",
"-skip-by-regex:.+\\.impl($|\\..+)",
Expand Down
9 changes: 7 additions & 2 deletions scaladoc-js/src/searchbar/SearchbarComponent.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
if selectedElement != null then {
selectedElement.removeAttribute("selected")
val sibling = selectedElement.previousElementSibling
if sibling != null then {
if sibling != null && sibling.classList.contains("scaladoc-searchbar-result") then {
sibling.setAttribute("selected", "")
resultsDiv.scrollTop = sibling.asInstanceOf[html.Element].offsetTop - (2 * sibling.asInstanceOf[html.Element].clientHeight)
}
Expand All @@ -184,9 +184,14 @@ class SearchbarComponent(engine: SearchbarEngine, inkuireEngine: InkuireJSSearch
}
} else {
val firstResult = resultsDiv.firstElementChild
if firstResult != null then {
if firstResult != null && firstResult.classList.contains("scaladoc-searchbar-result") then {
firstResult.setAttribute("selected", "")
resultsDiv.scrollTop = firstResult.asInstanceOf[html.Element].offsetTop - (2 * firstResult.asInstanceOf[html.Element].clientHeight)
} else if firstResult != null && firstResult.firstElementChild != null && firstResult.firstElementChild.nextElementSibling != null then {
// for Inkuire there is another wrapper to avoid displaying old results + the first (child) div is a loading animation wrapper | should be resolved in #12995
val properFirstResult = firstResult.firstElementChild.nextElementSibling
properFirstResult.setAttribute("selected", "")
resultsDiv.scrollTop = properFirstResult.asInstanceOf[html.Element].offsetTop - (2 * properFirstResult.asInstanceOf[html.Element].clientHeight)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions scaladoc/resources/dotty_res/styles/search-bar.css
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
width: 10px;
height: 10px;
border-radius: 5px;
background-color: white;
color: white;
background-color: var(--shadow);
color: var(--shadow);
animation: dotFlashing 1s infinite alternate;
display: inline-block;
position: absolute;
Expand Down Expand Up @@ -104,6 +104,6 @@
background-color: var(--leftbar-bg);
}
100% {
background-color: white;
background-color: var(--shadow);
}
}
16 changes: 9 additions & 7 deletions scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,15 @@ class SymOpsWithLinkCache:
import dotty.tools.dotc
given ctx: dotc.core.Contexts.Context = quotes.asInstanceOf[scala.quoted.runtime.impl.QuotesImpl].ctx
val csym = sym.asInstanceOf[dotc.core.Symbols.Symbol]
val extLink = if externalLinkCache.contains(csym.associatedFile) then externalLinkCache(csym.associatedFile)
else {
val calculatedLink = Option(csym.associatedFile).map(_.path).flatMap( path =>
dctx.externalDocumentationLinks.find(_.originRegexes.exists(r => r.matches(path))))
externalLinkCache += (csym.associatedFile -> calculatedLink)
calculatedLink
}
val extLink = if externalLinkCache.contains(csym.associatedFile)
then externalLinkCache(csym.associatedFile)
else {
val calculatedLink = Option(csym.associatedFile).map(_.path).flatMap { path =>
dctx.externalDocumentationLinks.find(_.originRegexes.exists(r => r.matches(path)))
}
externalLinkCache += (csym.associatedFile -> calculatedLink)
calculatedLink
}
extLink.map(link => sym.constructPath(location, anchor, link))
}

Expand Down