Skip to content

Scala3doc: Fix searchbar to match only by name #10263

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

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

pikinier20
Copy link
Contributor

It's fix of a bug reported in #200

@pikinier20 pikinier20 force-pushed the searchbar-data-update branch from 32b847c to 410d1ca Compare November 10, 2020 09:41
object PluginUtils:
import scala.reflect.ClassTag
import scala.reflect._
def query[T <: DokkaPlugin, E](ctx: DokkaContext, queryFunction: (T) => ExtensionPoint[E])(implicit tag: ClassTag[T]): List[E] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe:

    def plugin[T <: DokkaPlugin: ClassTag](ctx: DokkaContext) = 
      ctx.plugin[T](getKotlinClass(implicitly[ClassTag[T]].runtimeClass.asInstanceOf[Class[T]]))

    def query[T <: DokkaPlugin: ClassTag, E](ctx: DokkaContext, queryFunction: (T) => ExtensionPoint[E]): List[E] = 
        ctx.get(queryFunction(plugin[T](ctx))).asScala.toList

    def querySingle[T <: DokkaPlugin: ClassTag, E](ctx: DokkaContext, queryFunction: (T) => ExtensionPoint[E]): E = 
        ctx.single(queryFunction(plugin[T](ctx)))

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks better

@@ -40,6 +41,19 @@ class SignatureRenderer(pageContext: ContentPage, sourceSetRestriciton: JSet[Dis

class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) {

// TODO #239
val hackScalaSearchbarDataInstaller: SearchbarDataInstaller = {
import java.lang.reflect.Field;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that code below will work as well (without nasty warnings):

    val f = classOf[HtmlRenderer].getDeclaredField("searchbarDataInstaller")
    f.setAccessible(true)
    f.set(this, ScalaSearchbarDataInstaller(ctx))
    f.get(this).asInstanceOf[ScalaSearchbarDataInstaller]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


case class PageEntry(val name: String, val signature: String, val link: String, val pkg: String)

val pages = TrieMap[String, PageEntry]()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can add a comment that this is such a strange piece of code (concurrent collection, mutable state etc.) due to dokka?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

override def processPage(page: ContentPage, link: String) =
Option(page.getDocumentable) match {
case Some(member) => processMember(member, link)
case None => ()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to add support for titles from static documentation nodes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added support

@pikinier20 pikinier20 force-pushed the searchbar-data-update branch 2 times, most recently from 55d6fe9 to 198d62e Compare November 10, 2020 10:33
@pikinier20 pikinier20 force-pushed the searchbar-data-update branch from 198d62e to 9e4bdc7 Compare November 13, 2020 10:22
@romanowski
Copy link
Contributor

@smarter it seems that dotty.tools.dotc.CompilationTests is flaky on Windows (or jvm 8). Is that a known problem?

@romanowski romanowski merged commit d8fc06c into scala:master Nov 13, 2020
@smarter
Copy link
Member

smarter commented Nov 13, 2020

@smarter it seems that dotty.tools.dotc.CompilationTests is flaky on Windows (or jvm 8). Is that a known problem?

Not that I know of, /cc @liufengyun

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants