Skip to content

Commit

Permalink
fix(#19377): show inherited abstract members in dedicated section
Browse files Browse the repository at this point in the history
Before this commit, inherited abstract members are displayed in
"Inherited members" section, which made it a bit difficult for
developers to figure out which method to be implemented.

I think there are two solution for the issue.

1. display `abstract` modifier for methods in inherited section
2. add a new dedicated section for inherited abstract members

I choose the 2nd solution because

- it is easier for developers to find methods to be implemented in a dedicated section rather than to look
  up abstract ones from all the inherited members
- it requires smaller modification to scaladoc codebase

[Cherry-picked c823781]
  • Loading branch information
i10416 authored and WojciechMazur committed Jun 30, 2024
1 parent 11e1751 commit 5cb8264
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions scaladoc-testcases/src/tests/abstractmembersignatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ trait TestTrait:
class TestClass:
def shouldBeConcrete: Int = 1

abstract class TestInheritedAbstractMembers extends TestTrait

abstract class AbstractTestClass:
def shouldBeAbstract: Int
def shouldBeConcrete: Int = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
val (allInherited, allDefined) = nonExperimental.partition(isInherited)
val (depDefined, defined) = allDefined.partition(isDeprecated)
val (depInherited, inherited) = allInherited.partition(isDeprecated)
val (abstractInherited, concreteInherited) = inherited.partition(isAbstract)
val normalizedName = name.toLowerCase
val definedWithGroup = if Set("methods", "fields").contains(normalizedName) then
val (abstr, concr) = defined.partition(isAbstract)
Expand All @@ -335,7 +336,8 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext

definedWithGroup ++ List(
actualGroup(s"Deprecated ${normalizedName}", depDefined),
actualGroup(s"Inherited ${normalizedName}", inherited),
actualGroup(s"Inherited ${normalizedName}", concreteInherited),
actualGroup(s"Inherited and Abstract ${normalizedName}", abstractInherited),
actualGroup(s"Deprecated and Inherited ${normalizedName}", depInherited),
actualGroup(name = s"Experimental ${normalizedName}", experimental)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ class AbstractMembers extends ScaladocTest("abstractmembersignatures"):
def runTest = {
afterRendering {
val actualSignatures = signaturesFromDocumentation()

actualSignatures.foreach { (k, v) => k match
case "Abstract methods" => assertTrue(v.forall(_._2 == "shouldBeAbstract"))
case "Concrete methods" => assertTrue(v.forall(_._2 == "shouldBeConcrete"))
case "Inherited and Abstract methods" => assertTrue(v.forall(_._2 == "shouldBeAbstract"))
case "Classlikes" => assertTrue(v.forall((m, n) => m.contains("abstract") == n.contains("Abstract")))
case _ =>
}
Expand Down

0 comments on commit 5cb8264

Please sign in to comment.