Skip to content

MIgrate away from Kotlin Documentable #10660

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
merged 12 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ println(e1) // Apply(Apply(Var(wrap),Var(f)),Apply(Var(wrap),Var(a)))
### Relationship With Type Lambdas

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

Expand Down
15 changes: 13 additions & 2 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1565,7 +1565,14 @@ object Build {
generateDocumentation(
classDirectory.in(Compile).value.getAbsolutePath,
"scala3doc", "scala3doc/output/self", VersionUtil.gitHash,
"-siteroot scala3doc/documentation -project-logo scala3doc/documentation/logo.svg")
"-siteroot scala3doc/documentation -project-logo scala3doc/documentation/logo.svg " +
"-external-mappings " + raw".*scala.*" + "::" +
"scala3doc" + "::" +
"http://dotty.epfl.ch/api/" + ":::" +
raw".*java.*" + "::" +
"javadoc" + "::" +
"https://docs.oracle.com/javase/8/docs/api/"
)
}.value,

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

generateTestcasesDocumentation := Def.taskDyn {
Expand Down
2 changes: 2 additions & 0 deletions scala3doc-testcases/src/tests/extensionMethodSignatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ClassOne
extension (c: ClassTwo)
def |||:(a: Int, b: Int, d: Int)(e: String): Int
= 56
def ++:(a: Int): Int
= 45

extension (b: Int)
def secondGroup(): String
Expand Down
42 changes: 7 additions & 35 deletions scala3doc-testcases/src/tests/givenSignatures.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,15 @@ package tests

package givenSignatures

object Obj

given Seq[String] = Nil

class GivenClass {
trait B
trait C[T]
val r: Int = 5
type R = Int
given R = r
trait Ord[T] {
def compare(x: T, y: T): Int
extension (x: T) def < (y: T) = compare(x, y) < 0
extension (x: T) def > (y: T) = compare(x, y) > 0
}
given intOrd: Ord[Int] with {
def compare(x: Int, y: Int) =
if (x < y) -1 else if (x > y) +1 else 0
}
given GivenType = GivenType()

given asd(using int: Int): B with {}
class GivenType

given asd2[T]: C[T] with {}

given listOrd[T](using ord: Ord[T]): Ord[List[T]] with {

def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
case (Nil, Nil) => 0
case (Nil, _) => -1
case (_, Nil) => +1
case (x :: xs1, y :: ys1) =>
val fst = ord.compare(x, y)
if (fst != 0) fst else compare(xs1, ys1)
}

given IntOps: Int.type = Int

given GivenType = GivenType()

class GivenType
}
trait Ord[T]

given listOrd[T](using ord: Ord[T]): Ord[List[T]]
= ???
44 changes: 44 additions & 0 deletions scala3doc-testcases/src/tests/givenSignaturesPg.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package tests

package givenSignaturesPg



class GivenClass {
trait B
trait C[T]
val r: Int = 5
type R = Int
given R = r
trait Ord[T] {
def compare(x: T, y: T): Int
extension (x: T) def < (y: T) = compare(x, y) < 0
extension (x: T) def > (y: T) = compare(x, y) > 0
}
given intOrd: Ord[Int] with {
def compare(x: Int, y: Int) =
if (x < y) -1 else if (x > y) +1 else 0
}

given asd(using int: Int): B with {}

given asd2[T]: C[T] with {}

given listOrd[T](using ord: Ord[T]): Ord[List[T]] with {

def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
case (Nil, Nil) => 0
case (Nil, _) => -1
case (_, Nil) => +1
case (x :: xs1, y :: ys1) =>
val fst = ord.compare(x, y)
if (fst != 0) fst else compare(xs1, ys1)
}

given IntOps: Int.type = Int

given GivenType = GivenType()

class GivenType
}

7 changes: 7 additions & 0 deletions scala3doc-testcases/src/tests/methodsAndConstructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ class Methods:

def arrays(a: Array[String], b: Array[Int]): Array[Double]
= ???

def rightA1(a: Int): Int
= ???

def ++:(a: Int)(b: Double): Int
= ???

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ abstract class Methods()

implicit def toImplicitString(): String
= "asd"

inline def method2(inline name: String): String
= "ala"
}

class ImplementedMethods() extends Methods/*<-*/()/*->*/
Expand Down
16 changes: 16 additions & 0 deletions scala3doc-testcases/src/tests/nestingDRI.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tests.nestingDRI

trait TestClass

class A:
class B
object B:
object C
class C:
object D


class AA:
object B:
class C:
object D
3 changes: 3 additions & 0 deletions scala3doc-testcases/src/toplevel.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def toplevelDef = 123

class ToplevelClass
18 changes: 18 additions & 0 deletions scala3doc/resources/dotty_res/scripts/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@ window.addEventListener("DOMContentLoaded", () => {
document.getElementById("leftColumn").classList.toggle("open");
};
}

var elements = document.getElementsByClassName("documentableElement")
if (elements) {
for (i = 0; i < elements.length; i++) {
elements[i].onclick = function(){
this.classList.toggle("expand")
}
}
}


if (location.hash) {
var selected = document.getElementById(location.hash.substring(1));
if (selected){
selected.classList.toggle("expand");
}
}

var logo = document.getElementById("logo");
if (logo) {
logo.onclick = function() {
Expand Down
85 changes: 81 additions & 4 deletions scala3doc/resources/dotty_res/styles/scalastyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
--inactive-fg: #777;
--title-fg: #00485E;

--link-sig-fd: #7c99a5;
--link-sig-hover-fd: #7c99a5;

--leftbar-bg: #003048;
--leftbar-fg: #fff;
--leftbar-current-bg: #0090BB;
Expand Down Expand Up @@ -364,7 +367,7 @@ dl.attributes > dt.implicit {
}
dl.attributes > dd {
display: block;
padding-left: 10em;
padding-left: 6em;
margin-bottom: 5px;
min-height: 15px;
}
Expand Down Expand Up @@ -437,11 +440,43 @@ footer .pull-right {
margin-left: auto;
}


.modifiers {
width: 12em;
display: table-cell;
text-align: right;
padding-right: 0.5em;
min-width: 10em;
max-width: 10em;
overflow: hidden;
direction: rtl;
white-space: nowrap;
text-indent: 0em;
}

.modifiers .other-modifiers {
color: gray;
}

.other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] {
color: var(--link-sig-fd);
}

.expand .modifiers {
display: inline-table;
min-width: 7em;
}

.signature {
color: gray;
display: table-cell;
padding-left: 0.5em;
}

.signature a, .signature a:visited, .signature span[data-unresolved-link] {
color: var(--link-sig-fd);
}

.expand .signature {
display: inline;
}

.documentableElement {
Expand All @@ -454,15 +489,57 @@ footer .pull-right {
font-weight: 500;
font-size: 12px;
background: var(--code-bg);
border: 0.25em solid white;
}

.documentableElement>div {
display: table;
}

.expand.documentableElement>div {
display: block;
padding-left: 3em;
}

.expand.documentableElement>div.header {
display: block;
padding-left: 7.5em;
text-indent: -4.5em;
}

.documentableElement>div .cover {
display: none;
}

.documentableElement.expand>div .cover {
display: block;
}

.expand .doc {
margin-left: 6.5em;
}

.doc code {
padding: 0;
}

.documentableElement:hover {
cursor: pointer;
border-left: 0.25em solid var(--leftbar-bg);
}

.expand.documentableElement {
border-left: 0.25em solid var(--leftbar-bg);
}
.annotations {
margin-left: 9em;
color: gray;
display: none;
}

.expand .annotations {
display: inline-block;
}

.documentableAnchor {
position: absolute;
width: 24px;
Expand Down
Loading