Skip to content

Commit 4ddd8eb

Browse files
committed
Fix displaying multi-line signatures
1 parent 35eb5a9 commit 4ddd8eb

File tree

5 files changed

+67
-27
lines changed

5 files changed

+67
-27
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package tests.hugetype
2+
3+
import compiletime._
4+
import compiletime.ops.int._
5+
import scala.annotation.experimental
6+
7+
/**
8+
* type
9+
* noun
10+
*
11+
* a particular group of people or things that share similar characteristics and form a smaller division of a larger set:
12+
* - There were so many different types of bread that I didn't know which to buy.
13+
* - What type of clothes does she wear?
14+
* - It was dark so I didn't notice what type of car it was.
15+
* - He's the type of man you could take home to your mother.
16+
* - He's very attractive, if you like the blond, athletic type.
17+
* - They sell dried flowers and baskets and that type of thing.
18+
* - We have a range of moisturizers for all different skin types.
19+
* - She was young and she was wearing student-type clothes, so I assumed she was studying here.
20+
* - He took me to a bar full of actor types trying to get noticed.
21+
*
22+
*/
23+
type Take[T <: Tuple, N <: Int] <: Tuple = N match {
24+
case 0 => EmptyTuple
25+
case S[n1] => T match {
26+
case EmptyTuple => EmptyTuple
27+
case x *: xs => x *: Take[xs, n1]
28+
}
29+
}
30+
31+
/**
32+
* Some important information :o
33+
*
34+
* @param a any value of type forall a. a
35+
* @return Nothing, because I haven't implemented it yet ^^
36+
*/
37+
@experimental
38+
@deprecated
39+
implicit transparent inline def same[A](a: A): A = ???

scaladoc/resources/dotty_res/styles/scalastyle.css

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -602,15 +602,15 @@ footer .mode {
602602
}
603603

604604
.kind {
605-
margin-left: 0.5em;
605+
font-weight: bold;
606606
}
607607

608608
.other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] {
609609
color: var(--link-sig-fg);
610610
}
611611

612612
.documentableElement.expand .modifiers {
613-
display: inline-table;
613+
display: table-cell;
614614
min-width: 7em;
615615
}
616616

@@ -629,7 +629,7 @@ footer .mode {
629629
}
630630

631631
.expand .signature {
632-
display: inline;
632+
display: table-cell;
633633
}
634634

635635
.documentableElement {
@@ -653,9 +653,7 @@ footer .mode {
653653
}
654654

655655
.expand.documentableElement>div.header {
656-
display: block;
657-
padding-left: 4.5em;
658-
text-indent: -4.5em;
656+
display: inline-table;
659657
}
660658

661659
.documentableElement>div .cover {

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,17 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext
134134

135135
val rawBuilder = ScalaSignatureProvider.rawSignature(member, InlineSignatureBuilder())
136136
val inlineBuilder = rawBuilder.asInstanceOf[InlineSignatureBuilder]
137-
if inlineBuilder.preName.isEmpty then println(member)
138137
val kind :: modifiersRevered = inlineBuilder.preName
139138
val signature = inlineBuilder.names.reverse
140139
Seq(
141140
span(cls := "modifiers")(
142141
span(cls := "other-modifiers")(modifiersRevered.reverse.map(renderElement)),
142+
),
143+
div(cls := "signature")(
143144
span(cls := "kind")(renderElement(kind)),
145+
renderLink(member.name, member.dri, nameClasses),
146+
span(signature.map(renderElement))
144147
),
145-
renderLink(member.name, member.dri, nameClasses),
146-
span(cls := "signature")(signature.map(renderElement)),
147148
)
148149

149150
def memberIcon(member: Member) = member.kind match {

scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -603,20 +603,20 @@ trait ClassLikeSupport:
603603
graph: HierarchyGraph = HierarchyGraph.empty,
604604
deprecated: Option[Annotation] = None,
605605
) = Member(
606-
name = symbol.normalizedName,
607-
dri = symbol.dri,
608-
kind = kind,
609-
visibility = symbol.getVisibility(),
610-
modifiers = modifiers,
611-
annotations = symbol.getAnnotations(),
612-
signature = signature,
613-
sources = symbol.source,
614-
origin = origin,
615-
inheritedFrom = inheritedFrom,
616-
graph = graph,
617-
docs = symbol.documentation,
618-
deprecated = deprecated
619-
)
606+
name = symbol.normalizedName,
607+
dri = symbol.dri,
608+
kind = kind,
609+
visibility = symbol.getVisibility(),
610+
modifiers = modifiers,
611+
annotations = symbol.getAnnotations(),
612+
signature = signature,
613+
sources = symbol.source,
614+
origin = origin,
615+
inheritedFrom = inheritedFrom,
616+
graph = graph,
617+
docs = symbol.documentation,
618+
deprecated = deprecated
619+
)
620620

621621
object EvidenceOnlyParameterList
622622
type RegularParameterList = Map[String, TypeRepr]

scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ trait TypesSupport:
8080
case _ => false
8181

8282
// TODO #23 add support for all types signatures that makes sense
83-
private def inner(using Quotes)(tp: reflect.TypeRepr): DocSignature =
83+
private def inner(using Quotes)(tp: reflect.TypeRepr)(using indent: Int = 0): DocSignature =
8484
import reflect._
8585
def noSupported(name: String): DocSignature =
8686
println(s"WARN: Unsupported type: $name: ${tp.show}")
@@ -251,13 +251,15 @@ trait TypesSupport:
251251
case NoPrefix() => Nil
252252

253253
case MatchType(bond, sc, cases) =>
254+
val caseSpaces = " " * (indent + 2)
255+
val spaces = " " * (indent)
254256
val casesTexts = cases.flatMap {
255257
case MatchCase(from, to) =>
256-
texts(" case ") ++ inner(from) ++ texts(" => ") ++ inner(to) ++ texts("\n")
258+
texts(caseSpaces + "case ") ++ inner(from) ++ texts(" => ") ++ inner(to)(using indent = indent + 2) ++ texts("\n")
257259
case TypeLambda(_, _, MatchCase(from, to)) =>
258-
texts(" case ") ++ inner(from) ++ texts(" => ") ++ inner(to) ++ texts("\n")
260+
texts(caseSpaces + "case ") ++ inner(from) ++ texts(" => ") ++ inner(to)(using indent = indent + 2) ++ texts("\n")
259261
}
260-
inner(sc) ++ texts(" match {\n") ++ casesTexts ++ texts("}")
262+
inner(sc) ++ texts(" match {\n") ++ casesTexts ++ texts(spaces + "}")
261263

262264
case ParamRef(TypeLambda(names, _, _), i) => texts(names.apply(i))
263265

0 commit comments

Comments
 (0)