Skip to content

UX scaladoc improvements #11396

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 1 commit into from
Feb 12, 2021
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
35 changes: 35 additions & 0 deletions scaladoc-testcases/src/tests/listindocstring.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* These are useful methods that exist for both $some and $none.
* * [[isDefined]] — True if not empty
* - [[isEmpty]] — True if empty
* - [[nonEmpty]] — True if not empty
* - [[orElse]] — Evaluate and return alternate optional value if empty
* - [[getOrElse]] — Evaluate and return alternate value if empty
* - [[get]] — Return value, throw exception if empty
* - [[fold]] — Apply function on optional value, return default if empty
* - [[map]] — Apply a function on the optional value
* - [[flatMap]] — Same as map but function must return an optional value
* - [[foreach]] — Apply a procedure on option value
* - [[collect]] — Apply partial pattern match on optional value
* - [[filter]] — An optional value satisfies predicate
* - [[filterNot]] — An optional value doesn't satisfy predicate
* - [[exists]] — Apply predicate on optional value, or false if empty
* - [[forall]] — Apply predicate on optional value, or true if empty
* - [[contains]] — Checks if value equals optional value, or false if empty
* - [[zip]] — Combine two optional values to make a paired optional value
* - [[unzip]] — Split an optional pair to two optional values
* - [[unzip3]] — Split an optional triple to three optional values
* - [[toList]] — Unary list of optional value, otherwise the empty list
*/
trait O

/**
* Some text
*
*
* Next paragraph
*
*
* Last paragraph
*/
trait K
5 changes: 3 additions & 2 deletions scaladoc/resources/dotty_res/scripts/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ window.addEventListener("DOMContentLoaded", () => {
var elements = document.getElementsByClassName("documentableElement")
if (elements) {
for (i = 0; i < elements.length; i++) {
elements[i].onclick = function(){
this.classList.toggle("expand")
elements[i].onclick = function(e) {
if(!$(e.target).is("a"))
this.classList.toggle("expand")
}
}
}
Expand Down
13 changes: 9 additions & 4 deletions scaladoc/resources/dotty_res/styles/scalastyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
--inactive-fg: #777;
--title-fg: #00485E;

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

--leftbar-bg: #003048;
Expand Down Expand Up @@ -155,7 +155,9 @@ th {

/* Navigation */
#sideMenu2 {
overflow-y: auto;
overflow: auto;
overflow-x: hidden;
overflow-y: scroll;
scrollbar-width: thin;
height: 100%;
font-size: var(--leftbar-font-size);
Expand Down Expand Up @@ -206,7 +208,7 @@ th {
margin-top: 1px;
margin-bottom: 1px;
width: 100%;
/* This trick adds selected bachground stratching to the lef side of screen */
/* This trick adds selected background stretching to the left side of screen */
margin-left: calc(0px - var(--side-width));
padding-left: var(--side-width);
width: calc(2 * var(--side-width));
Expand Down Expand Up @@ -490,7 +492,7 @@ footer .pull-right {
}

.documentableElement .signature {
color: gray;
color: #5a5a5a;
display: table-cell;
white-space: pre-wrap;
}
Expand Down Expand Up @@ -775,3 +777,6 @@ footer .socials {
}
}

footer {
background-color: white;
}
11 changes: 7 additions & 4 deletions scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,19 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
)
)

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

private def actualGroup(name: String, members: Seq[Member | MGroup]): Seq[AppliedTag] =
if members.isEmpty then Nil else
div(cls := "documentableList")(
h3(cls:="groupHeader")(name),
members.map {
members.sortBy {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Members are sort by poistion in the source files/files. Three is a way to sort members by name using buttons.

case m: Member => m.name
case MGroup(_, _, name) => name
}.map {
case element: Member =>
member(element)
case MGroup(header, members) =>
case MGroup(header, members, _) =>
div(
header,
members.map(member)
Expand Down Expand Up @@ -255,7 +258,7 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
}.collect {
case (Some(on), members) =>
val sig = Signature(s"extension (${on.name}: ") ++ on.signature ++ Signature(")")
MGroup(span(sig.map(renderElement)), members.toSeq)
MGroup(span(sig.map(renderElement)), members.sortBy(_.name).toSeq, on.name)
}.toSeq

div(cls := "membersList")(renderTabs(
Expand Down