Skip to content

Commit 33fca15

Browse files
authored
Merge pull request #11396 from BarkingBad/scala3doc/ux-fixes
UX scaladoc improvements
2 parents 815841b + b4a5276 commit 33fca15

File tree

4 files changed

+54
-10
lines changed

4 files changed

+54
-10
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* These are useful methods that exist for both $some and $none.
3+
* * [[isDefined]] — True if not empty
4+
* - [[isEmpty]] — True if empty
5+
* - [[nonEmpty]] — True if not empty
6+
* - [[orElse]] — Evaluate and return alternate optional value if empty
7+
* - [[getOrElse]] — Evaluate and return alternate value if empty
8+
* - [[get]] — Return value, throw exception if empty
9+
* - [[fold]] — Apply function on optional value, return default if empty
10+
* - [[map]] — Apply a function on the optional value
11+
* - [[flatMap]] — Same as map but function must return an optional value
12+
* - [[foreach]] — Apply a procedure on option value
13+
* - [[collect]] — Apply partial pattern match on optional value
14+
* - [[filter]] — An optional value satisfies predicate
15+
* - [[filterNot]] — An optional value doesn't satisfy predicate
16+
* - [[exists]] — Apply predicate on optional value, or false if empty
17+
* - [[forall]] — Apply predicate on optional value, or true if empty
18+
* - [[contains]] — Checks if value equals optional value, or false if empty
19+
* - [[zip]] — Combine two optional values to make a paired optional value
20+
* - [[unzip]] — Split an optional pair to two optional values
21+
* - [[unzip3]] — Split an optional triple to three optional values
22+
* - [[toList]] — Unary list of optional value, otherwise the empty list
23+
*/
24+
trait O
25+
26+
/**
27+
* Some text
28+
*
29+
*
30+
* Next paragraph
31+
*
32+
*
33+
* Last paragraph
34+
*/
35+
trait K

scaladoc/resources/dotty_res/scripts/ux.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ window.addEventListener("DOMContentLoaded", () => {
99
var elements = document.getElementsByClassName("documentableElement")
1010
if (elements) {
1111
for (i = 0; i < elements.length; i++) {
12-
elements[i].onclick = function(){
13-
this.classList.toggle("expand")
12+
elements[i].onclick = function(e) {
13+
if(!$(e.target).is("a"))
14+
this.classList.toggle("expand")
1415
}
1516
}
1617
}

scaladoc/resources/dotty_res/styles/scalastyle.css

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

15-
--link-sig-fd: #7c99a5;
15+
--link-sig-fd: #2da0d1;
1616
--link-sig-hover-fd: #7c99a5;
1717

1818
--leftbar-bg: #003048;
@@ -155,7 +155,9 @@ th {
155155

156156
/* Navigation */
157157
#sideMenu2 {
158-
overflow-y: auto;
158+
overflow: auto;
159+
overflow-x: hidden;
160+
overflow-y: scroll;
159161
scrollbar-width: thin;
160162
height: 100%;
161163
font-size: var(--leftbar-font-size);
@@ -206,7 +208,7 @@ th {
206208
margin-top: 1px;
207209
margin-bottom: 1px;
208210
width: 100%;
209-
/* This trick adds selected bachground stratching to the lef side of screen */
211+
/* This trick adds selected background stretching to the left side of screen */
210212
margin-left: calc(0px - var(--side-width));
211213
padding-left: var(--side-width);
212214
width: calc(2 * var(--side-width));
@@ -490,7 +492,7 @@ footer .pull-right {
490492
}
491493

492494
.documentableElement .signature {
493-
color: gray;
495+
color: #5a5a5a;
494496
display: table-cell;
495497
white-space: pre-wrap;
496498
}
@@ -775,3 +777,6 @@ footer .socials {
775777
}
776778
}
777779

780+
footer {
781+
background-color: white;
782+
}

scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,19 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
173173
)
174174
)
175175

176-
private case class MGroup(header: AppliedTag, members: Seq[Member])
176+
private case class MGroup(header: AppliedTag, members: Seq[Member], groupName: String)
177177

178178
private def actualGroup(name: String, members: Seq[Member | MGroup]): Seq[AppliedTag] =
179179
if members.isEmpty then Nil else
180180
div(cls := "documentableList")(
181181
h3(cls:="groupHeader")(name),
182-
members.map {
182+
members.sortBy {
183+
case m: Member => m.name
184+
case MGroup(_, _, name) => name
185+
}.map {
183186
case element: Member =>
184187
member(element)
185-
case MGroup(header, members) =>
188+
case MGroup(header, members, _) =>
186189
div(
187190
header,
188191
members.map(member)
@@ -255,7 +258,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
255258
}.collect {
256259
case (Some(on), members) =>
257260
val sig = Signature(s"extension (${on.name}: ") ++ on.signature ++ Signature(")")
258-
MGroup(span(sig.map(renderElement)), members.toSeq)
261+
MGroup(span(sig.map(renderElement)), members.sortBy(_.name).toSeq, on.name)
259262
}.toSeq
260263

261264
div(cls := "membersList")(renderTabs(

0 commit comments

Comments
 (0)