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: fix #14481: certain functions not being shown in searchbar #14546

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
9 changes: 9 additions & 0 deletions scaladoc-testcases/src/tests/inheritedMembersFromHidden.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package tests
package inheritedMembersFromHidden

private[inheritedMembersFromHidden] trait HiddenTrait { //unexpected
def method: Unit
= ???
}

object PublicObject extends HiddenTrait //expected: object PublicObject
2 changes: 1 addition & 1 deletion scaladoc/src/dotty/tools/scaladoc/api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ enum Origin:

case class Overridden(name: String, dri: DRI)

case class InheritedFrom(name: String, dri: DRI)
case class InheritedFrom(name: String, dri: DRI, isSourceSuperclassHidden: Boolean)

case class Annotation(val dri: DRI, val params: List[Annotation.AnnotationParameter])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
case _ => Nil

def inheritedFrom(m: Member) = m.inheritedFrom match
case Some(InheritedFrom(name, dri)) => tableRow("Inherited from:", signatureRenderer.renderLink(name, dri))
case Some(InheritedFrom(name, dri, isSourceSuperclassHidden)) =>
val hiddenNameSuffix = if isSourceSuperclassHidden then " (hidden)" else ""
tableRow("Inherited from:", signatureRenderer.renderLink(name + hiddenNameSuffix, dri))
case _ => Nil

def docAttributes(m: Member): Seq[AppliedTag] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
val entry = mkEntry(member.dri, member.name, flattenToText(sig), descr, member.kind.name)
val children = member
.membersBy(m => m.kind != Kind.Package && !m.kind.isInstanceOf[Classlike])
.filter(m => m.origin == Origin.RegularlyDefined && m.inheritedFrom.isEmpty)
.filter(m => m.origin == Origin.RegularlyDefined && m.inheritedFrom.fold(false)(_.isSourceSuperclassHidden))
Seq(entry) ++ children.flatMap(processMember)

processMember(m)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ trait ClassLikeSupport:
}

private def parseInheritedMember(c: ClassDef)(s: Tree): Option[Member] =
def inheritance = Some(InheritedFrom(s.symbol.owner.normalizedName, s.symbol.dri))
def inheritance = Some(InheritedFrom(s.symbol.owner.normalizedName, s.symbol.dri, s.symbol.owner.isHiddenByVisibility))
processTreeOpt(s)(s match
case c: ClassDef if c.symbol.shouldDocumentClasslike => Some(parseClasslike(c, signatureOnly = true))
case other => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object FilterAttributes:
Map("visibility" -> m.visibility.name)

private def inheritedFrom(m: Member): Map[String, String] = m.inheritedFrom match
case Some(InheritedFrom(name, _)) => Map("inherited" -> name)
case Some(InheritedFrom(name, _, _)) => Map("inherited" -> name)
case _ => Map.empty

private def origin(m: Member): Map[String, String] = m.origin match
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ class InheritanceLoop extends SignatureTest("inheritanceLoop", SignatureTest.all
class InheritedMembers extends SignatureTest("inheritedMembers2", SignatureTest.all.filter(_ != "class"),
sourceFiles = List("inheritedMembers1", "inheritedMembers2"))

class InheritedFromHiddenClasslike extends SignatureTest("inheritedMembersFromHidden", SignatureTest.all)

class ComplexNames extends SignatureTest("complexNames", Seq("def", "class"))

class WrongDocumentationLinks extends SignatureTest("links", Seq("def"))
Expand Down