Skip to content

Commit

Permalink
fix(#19377): show inherited abstract members in dedicated section (#1…
Browse files Browse the repository at this point in the history
…9552)

close #19377 

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


<img width="1334" alt="image"
src="https://github.com/lampepfl/dotty/assets/39330037/c033704d-0e30-49ff-954e-2c2ab0dace21">
  • Loading branch information
Florian3k authored Feb 2, 2024
2 parents 0011ea6 + c823781 commit 5850d2d
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 5850d2d

Please sign in to comment.