Skip to content

Commit c823781

Browse files
committed
fix(#19377): show inherited abstract members in dedicated section
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
1 parent 1716bcd commit c823781

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

Diff for: scaladoc-testcases/src/tests/abstractmembersignatures.scala

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ trait TestTrait:
99
class TestClass:
1010
def shouldBeConcrete: Int = 1
1111

12+
abstract class TestInheritedAbstractMembers extends TestTrait
13+
1214
abstract class AbstractTestClass:
1315
def shouldBeAbstract: Int
1416
def shouldBeConcrete: Int = 1

Diff for: scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
323323
val (allInherited, allDefined) = nonExperimental.partition(isInherited)
324324
val (depDefined, defined) = allDefined.partition(isDeprecated)
325325
val (depInherited, inherited) = allInherited.partition(isDeprecated)
326+
val (abstractInherited, concreteInherited) = inherited.partition(isAbstract)
326327
val normalizedName = name.toLowerCase
327328
val definedWithGroup = if Set("methods", "fields").contains(normalizedName) then
328329
val (abstr, concr) = defined.partition(isAbstract)
@@ -335,7 +336,8 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
335336

336337
definedWithGroup ++ List(
337338
actualGroup(s"Deprecated ${normalizedName}", depDefined),
338-
actualGroup(s"Inherited ${normalizedName}", inherited),
339+
actualGroup(s"Inherited ${normalizedName}", concreteInherited),
340+
actualGroup(s"Inherited and Abstract ${normalizedName}", abstractInherited),
339341
actualGroup(s"Deprecated and Inherited ${normalizedName}", depInherited),
340342
actualGroup(name = s"Experimental ${normalizedName}", experimental)
341343
)

Diff for: scaladoc/test/dotty/tools/scaladoc/signatures/AbstractMemberSignaturesTest.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class AbstractMembers extends ScaladocTest("abstractmembersignatures"):
1818
def runTest = {
1919
afterRendering {
2020
val actualSignatures = signaturesFromDocumentation()
21-
2221
actualSignatures.foreach { (k, v) => k match
2322
case "Abstract methods" => assertTrue(v.forall(_._2 == "shouldBeAbstract"))
2423
case "Concrete methods" => assertTrue(v.forall(_._2 == "shouldBeConcrete"))
24+
case "Inherited and Abstract methods" => assertTrue(v.forall(_._2 == "shouldBeAbstract"))
2525
case "Classlikes" => assertTrue(v.forall((m, n) => m.contains("abstract") == n.contains("Abstract")))
2626
case _ =>
2727
}

0 commit comments

Comments
 (0)