Skip to content

Commit a6e24e4

Browse files
authored
Merge pull request #10660 from romanowski/scala3doc/member-migration
MIgrate away from Kotlin Documentable
2 parents 28f04c6 + 74c45cf commit a6e24e4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1342
-836
lines changed

docs/docs/reference/new-types/polymorphic-function-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ println(e1) // Apply(Apply(Var(wrap),Var(f)),Apply(Var(wrap),Var(a)))
8080
### Relationship With Type Lambdas
8181

8282
Polymorphic function types are not to be confused with
83-
[_type lambdas_](new-types/type-lambdas.md).
83+
[_type lambdas_](type-lambdas.md).
8484
While the former describes the _type_ of a polymorphic _value_,
8585
the latter is an actual function value _at the type level_.
8686

project/Build.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,7 +1565,14 @@ object Build {
15651565
generateDocumentation(
15661566
classDirectory.in(Compile).value.getAbsolutePath,
15671567
"scala3doc", "scala3doc/output/self", VersionUtil.gitHash,
1568-
"-siteroot scala3doc/documentation -project-logo scala3doc/documentation/logo.svg")
1568+
"-siteroot scala3doc/documentation -project-logo scala3doc/documentation/logo.svg " +
1569+
"-external-mappings " + raw".*scala.*" + "::" +
1570+
"scala3doc" + "::" +
1571+
"http://dotty.epfl.ch/api/" + ":::" +
1572+
raw".*java.*" + "::" +
1573+
"javadoc" + "::" +
1574+
"https://docs.oracle.com/javase/8/docs/api/"
1575+
)
15691576
}.value,
15701577

15711578
generateScala3Documentation := Def.inputTaskDyn {
@@ -1589,7 +1596,11 @@ object Build {
15891596
IO.write(dest / "CNAME", "dotty.epfl.ch")
15901597
}.dependsOn(generateDocumentation(
15911598
roots, "Scala 3", dest.getAbsolutePath, "master",
1592-
"-comment-syntax wiki -siteroot scala3doc/scala3-docs -project-logo scala3doc/scala3-docs/logo.svg"))
1599+
"-comment-syntax wiki -siteroot scala3doc/scala3-docs -project-logo scala3doc/scala3-docs/logo.svg " +
1600+
"-external-mappings " + raw".*java.*" + "::" +
1601+
"javadoc" + "::" +
1602+
"https://docs.oracle.com/javase/8/docs/api/"
1603+
))
15931604
}.evaluated,
15941605

15951606
generateTestcasesDocumentation := Def.taskDyn {

scala3doc-testcases/src/tests/extensionMethodSignatures.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class ClassOne
1717
extension (c: ClassTwo)
1818
def |||:(a: Int, b: Int, d: Int)(e: String): Int
1919
= 56
20+
def ++:(a: Int): Int
21+
= 45
2022

2123
extension (b: Int)
2224
def secondGroup(): String

scala3doc-testcases/src/tests/givenSignatures.scala

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,15 @@ package tests
22

33
package givenSignatures
44

5+
object Obj
56

7+
given Seq[String] = Nil
68

7-
class GivenClass {
8-
trait B
9-
trait C[T]
10-
val r: Int = 5
11-
type R = Int
12-
given R = r
13-
trait Ord[T] {
14-
def compare(x: T, y: T): Int
15-
extension (x: T) def < (y: T) = compare(x, y) < 0
16-
extension (x: T) def > (y: T) = compare(x, y) > 0
17-
}
18-
given intOrd: Ord[Int] with {
19-
def compare(x: Int, y: Int) =
20-
if (x < y) -1 else if (x > y) +1 else 0
21-
}
9+
given GivenType = GivenType()
2210

23-
given asd(using int: Int): B with {}
11+
class GivenType
2412

25-
given asd2[T]: C[T] with {}
26-
27-
given listOrd[T](using ord: Ord[T]): Ord[List[T]] with {
28-
29-
def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
30-
case (Nil, Nil) => 0
31-
case (Nil, _) => -1
32-
case (_, Nil) => +1
33-
case (x :: xs1, y :: ys1) =>
34-
val fst = ord.compare(x, y)
35-
if (fst != 0) fst else compare(xs1, ys1)
36-
}
37-
38-
given IntOps: Int.type = Int
39-
40-
given GivenType = GivenType()
41-
42-
class GivenType
43-
}
13+
trait Ord[T]
4414

15+
given listOrd[T](using ord: Ord[T]): Ord[List[T]]
16+
= ???
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package tests
2+
3+
package givenSignaturesPg
4+
5+
6+
7+
class GivenClass {
8+
trait B
9+
trait C[T]
10+
val r: Int = 5
11+
type R = Int
12+
given R = r
13+
trait Ord[T] {
14+
def compare(x: T, y: T): Int
15+
extension (x: T) def < (y: T) = compare(x, y) < 0
16+
extension (x: T) def > (y: T) = compare(x, y) > 0
17+
}
18+
given intOrd: Ord[Int] with {
19+
def compare(x: Int, y: Int) =
20+
if (x < y) -1 else if (x > y) +1 else 0
21+
}
22+
23+
given asd(using int: Int): B with {}
24+
25+
given asd2[T]: C[T] with {}
26+
27+
given listOrd[T](using ord: Ord[T]): Ord[List[T]] with {
28+
29+
def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
30+
case (Nil, Nil) => 0
31+
case (Nil, _) => -1
32+
case (_, Nil) => +1
33+
case (x :: xs1, y :: ys1) =>
34+
val fst = ord.compare(x, y)
35+
if (fst != 0) fst else compare(xs1, ys1)
36+
}
37+
38+
given IntOps: Int.type = Int
39+
40+
given GivenType = GivenType()
41+
42+
class GivenType
43+
}
44+

scala3doc-testcases/src/tests/methodsAndConstructors.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ class Methods:
4747

4848
def arrays(a: Array[String], b: Array[Int]): Array[Double]
4949
= ???
50+
51+
def rightA1(a: Int): Int
52+
= ???
53+
54+
def ++:(a: Int)(b: Double): Int
55+
= ???
56+

scala3doc-testcases/src/tests/modifiersSignatureTestSource.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ abstract class Methods()
2424

2525
implicit def toImplicitString(): String
2626
= "asd"
27+
28+
inline def method2(inline name: String): String
29+
= "ala"
2730
}
2831

2932
class ImplementedMethods() extends Methods/*<-*/()/*->*/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package tests.nestingDRI
2+
3+
trait TestClass
4+
5+
class A:
6+
class B
7+
object B:
8+
object C
9+
class C:
10+
object D
11+
12+
13+
class AA:
14+
object B:
15+
class C:
16+
object D
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def toplevelDef = 123
2+
3+
class ToplevelClass

scala3doc/resources/dotty_res/scripts/ux.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ window.addEventListener("DOMContentLoaded", () => {
55
document.getElementById("leftColumn").classList.toggle("open");
66
};
77
}
8+
9+
var elements = document.getElementsByClassName("documentableElement")
10+
if (elements) {
11+
for (i = 0; i < elements.length; i++) {
12+
elements[i].onclick = function(){
13+
this.classList.toggle("expand")
14+
}
15+
}
16+
}
17+
18+
19+
if (location.hash) {
20+
var selected = document.getElementById(location.hash.substring(1));
21+
if (selected){
22+
selected.classList.toggle("expand");
23+
}
24+
}
25+
826
var logo = document.getElementById("logo");
927
if (logo) {
1028
logo.onclick = function() {

scala3doc/resources/dotty_res/styles/scalastyle.css

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
--inactive-fg: #777;
1313
--title-fg: #00485E;
1414

15+
--link-sig-fd: #7c99a5;
16+
--link-sig-hover-fd: #7c99a5;
17+
1518
--leftbar-bg: #003048;
1619
--leftbar-fg: #fff;
1720
--leftbar-current-bg: #0090BB;
@@ -364,7 +367,7 @@ dl.attributes > dt.implicit {
364367
}
365368
dl.attributes > dd {
366369
display: block;
367-
padding-left: 10em;
370+
padding-left: 6em;
368371
margin-bottom: 5px;
369372
min-height: 15px;
370373
}
@@ -437,11 +440,43 @@ footer .pull-right {
437440
margin-left: auto;
438441
}
439442

443+
440444
.modifiers {
441-
width: 12em;
442445
display: table-cell;
443-
text-align: right;
444446
padding-right: 0.5em;
447+
min-width: 10em;
448+
max-width: 10em;
449+
overflow: hidden;
450+
direction: rtl;
451+
white-space: nowrap;
452+
text-indent: 0em;
453+
}
454+
455+
.modifiers .other-modifiers {
456+
color: gray;
457+
}
458+
459+
.other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] {
460+
color: var(--link-sig-fd);
461+
}
462+
463+
.expand .modifiers {
464+
display: inline-table;
465+
min-width: 7em;
466+
}
467+
468+
.signature {
469+
color: gray;
470+
display: table-cell;
471+
padding-left: 0.5em;
472+
}
473+
474+
.signature a, .signature a:visited, .signature span[data-unresolved-link] {
475+
color: var(--link-sig-fd);
476+
}
477+
478+
.expand .signature {
479+
display: inline;
445480
}
446481

447482
.documentableElement {
@@ -454,15 +489,57 @@ footer .pull-right {
454489
font-weight: 500;
455490
font-size: 12px;
456491
background: var(--code-bg);
492+
border: 0.25em solid white;
457493
}
458494

459495
.documentableElement>div {
460496
display: table;
461497
}
462498

499+
.expand.documentableElement>div {
500+
display: block;
501+
padding-left: 3em;
502+
}
503+
504+
.expand.documentableElement>div.header {
505+
display: block;
506+
padding-left: 7.5em;
507+
text-indent: -4.5em;
508+
}
509+
510+
.documentableElement>div .cover {
511+
display: none;
512+
}
513+
514+
.documentableElement.expand>div .cover {
515+
display: block;
516+
}
517+
518+
.expand .doc {
519+
margin-left: 6.5em;
520+
}
521+
522+
.doc code {
523+
padding: 0;
524+
}
525+
526+
.documentableElement:hover {
527+
cursor: pointer;
528+
border-left: 0.25em solid var(--leftbar-bg);
529+
}
530+
531+
.expand.documentableElement {
532+
border-left: 0.25em solid var(--leftbar-bg);
533+
}
463534
.annotations {
464-
margin-left: 9em;
535+
color: gray;
536+
display: none;
465537
}
538+
539+
.expand .annotations {
540+
display: inline-block;
541+
}
542+
466543
.documentableAnchor {
467544
position: absolute;
468545
width: 24px;

0 commit comments

Comments
 (0)