-
Notifications
You must be signed in to change notification settings - Fork 1.1k
UX improvements for scaladoc #11434
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
BarkingBad
merged 2 commits into
scala:master
from
BarkingBad:scala3doc/ux-fixes-part-2
Feb 19, 2021
Merged
UX improvements for scaladoc #11434
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
scaladoc-testcases/src/tests/abstractmembersignatures.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package tests | ||
package abstractmembersignatures | ||
|
||
|
||
trait TestTrait: | ||
def shouldBeAbstract: Int | ||
def shouldBeConcrete: Int = 1 | ||
|
||
class TestClass: | ||
def shouldBeConcrete: Int = 1 | ||
|
||
abstract class AbstractTestClass: | ||
def shouldBeAbstract: Int | ||
def shouldBeConcrete: Int = 1 | ||
|
||
object TestObject: | ||
abstract class AbstractInnerClass: | ||
def shouldBeAbstract: Int | ||
def shouldBeConcrete: Int = 1 | ||
|
||
class InnerClass: | ||
def shouldBeConcrete: Int = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package tests | ||
package secondaryconstructors | ||
|
||
class Person(val firstName: String, val lastName: String, val age: Int): | ||
def this(firstName: String) = this(firstName, "", 0) | ||
def this(firstName: String, lastName: String) = this(firstName, lastName, 0) | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
scaladoc/test/dotty/tools/scaladoc/signatures/AbstractMemberSignaturesTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package dotty.tools.scaladoc | ||
package signatures | ||
|
||
import scala.io.Source | ||
import scala.jdk.CollectionConverters._ | ||
import scala.util.matching.Regex | ||
import dotty.tools.scaladoc.test.BuildInfo | ||
import java.nio.file.Path; | ||
import org.jsoup.Jsoup | ||
import util.IO | ||
import org.junit.Assert.assertTrue | ||
|
||
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 "Classlikes" => assertTrue(v.forall((m, n) => m.contains("abstract") == n.contains("Abstract"))) | ||
case _ => | ||
} | ||
} | ||
} | ||
|
||
private def signaturesFromDocumentation()(using DocContext): Map[String, List[(String, String)]] = | ||
val output = summon[DocContext].args.output.toPath.resolve("api") | ||
val signatures = List.newBuilder[(String, (String, String))] | ||
def processFile(path: Path): Unit = | ||
val document = Jsoup.parse(IO.read(path)) | ||
val content = document.select(".documentableList").forEach { elem => | ||
val group = elem.select(".groupHeader").eachText.asScala.mkString("") | ||
elem.select(".documentableElement").forEach { elem => | ||
val modifiers = elem.select(".header .other-modifiers").eachText.asScala.mkString("") | ||
val name = elem.select(".header .documentableName").eachText.asScala.mkString("") | ||
signatures += group -> (modifiers, name) | ||
} | ||
} | ||
IO.foreachFileIn(output, processFile) | ||
signatures.result.groupMap(_._1)(_._2) |
1 change: 1 addition & 0 deletions
1
.../dotty/tools/scaladoc/SignatureTest.scala → ...s/scaladoc/signatures/SignatureTest.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
package dotty.tools.scaladoc | ||
package signatures | ||
|
||
import scala.io.Source | ||
import scala.jdk.CollectionConverters._ | ||
|
2 changes: 1 addition & 1 deletion
2
...y/tools/scaladoc/SignatureTestCases.scala → ...res/TranslatableSignaturesTestCases.scala
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.