diff --git a/scaladoc-testcases/src/tests/hugetype.scala b/scaladoc-testcases/src/tests/hugetype.scala new file mode 100644 index 000000000000..2f0f7f79540b --- /dev/null +++ b/scaladoc-testcases/src/tests/hugetype.scala @@ -0,0 +1,48 @@ +package tests.hugetype + +import compiletime._ +import compiletime.ops.int._ +import scala.annotation.experimental + +/** + * a particular group of people or things that share similar characteristics and form a smaller division of a larger set: + * - There were so many different types of bread that I didn't know which to buy. + * - What type of clothes does she wear? + * - It was dark so I didn't notice what type of car it was. + * - He's the type of man you could take home to your mother. + * - He's very attractive, if you like the blond, athletic type. + * - They sell dried flowers and baskets and that type of thing. + * - We have a range of moisturizers for all different skin types. + * - She was young and she was wearing student-type clothes, so I assumed she was studying here. + * - He took me to a bar full of actor types trying to get noticed. + * + */ +type Take[T <: Tuple, N <: Int] <: Tuple = N match { + case 0 => EmptyTuple + case S[n1] => T match { + case EmptyTuple => EmptyTuple + case x *: xs => x *: Take[xs, n1] + } +} + +trait E: + @experimental + @deprecated + protected implicit def same[A](a: A): A + +trait XD extends E: + /** + * Some important information :o + * + * @param a any value of type forall a. a + * @return Nothing, because I haven't implemented it yet ^^ + */ + @experimental + @deprecated + protected override final implicit transparent inline abstract infix def same[A](a: A): A = a + +trait Parent[X, A[_], B[_, _]] + +trait HugeTrait[X] extends Parent[X, HugeTrait, Map] + +trait EvenBiggerTrait[X, Y] extends Parent[X, Seq, EvenBiggerTrait] diff --git a/scaladoc/resources/dotty_res/styles/scalastyle.css b/scaladoc/resources/dotty_res/styles/scalastyle.css index 679fbc846fb7..4657d59b0673 100644 --- a/scaladoc/resources/dotty_res/styles/scalastyle.css +++ b/scaladoc/resources/dotty_res/styles/scalastyle.css @@ -262,6 +262,7 @@ th { padding-left: calc(1.015 * var(--side-width)); padding-right: calc(0.15 * var(--side-width)); box-sizing: border-box; + text-decoration: none; } #sideMenu2 a span:not(.micon) { @@ -582,14 +583,20 @@ footer .mode { .documentableElement .modifiers { display: table-cell; - padding-right: 0.5em; min-width: 10em; max-width: 10em; width: 10em; overflow: hidden; - direction: rtl; + text-align: right; white-space: nowrap; + text-overflow: ellipsis; text-indent: 0em; + padding-right: 0.5em; +} + +.documentableElement.expand .modifiers { + white-space: break-spaces; + text-overflow: unset; } .documentableElement .docs { @@ -602,7 +609,7 @@ footer .mode { } .kind { - margin-left: 0.5em; + font-weight: bold; } .other-modifiers a, .other-modifiers a:visited, .other-modifiers span[data-unresolved-link] { @@ -610,8 +617,7 @@ footer .mode { } .documentableElement.expand .modifiers { - display: inline-table; - min-width: 7em; + display: table-cell; } .documentableElement .signature { @@ -622,6 +628,12 @@ footer .mode { .signature.monospace { padding: 8px; + display: flex; + border-radius: 3px; +} + +.signature.monospace .modifiers { + white-space: break-spaces; } .signature a, .signature a:visited, .signature span[data-unresolved-link] { @@ -629,7 +641,11 @@ footer .mode { } .expand .signature { - display: inline; + display: table-cell; +} + +.documentableFilter { + border-radius: 3px; } .documentableElement { @@ -642,20 +658,15 @@ footer .mode { background: var(--documentable-bg); border-left: 0.25em solid transparent; margin: 0.5em 0; + border-radius: 3px; } .documentableElement>div { display: table; } -.expand.documentableElement>div { - display: block; -} - .expand.documentableElement>div.header { - display: block; - padding-left: 4.5em; - text-indent: -4.5em; + display: inline-table; } .documentableElement>div .cover { @@ -666,10 +677,6 @@ footer .mode { display: block; } -.expand .doc { - margin-left: 6.5em; -} - .doc code { padding: 0; } @@ -684,6 +691,7 @@ footer .mode { } .documentableElement .annotations { color: var(--grey600); + margin-left: 10em; display: none; } @@ -695,13 +703,17 @@ footer .mode { display: none; } +.documentableElement:hover .documentableAnchor:before { + display: flex; +} + .documentableAnchor:before { content: "\e901"; /* arrow down */ font-family: "dotty-icons" !important; - transform: rotate(45deg); + transform: rotate(-45deg); font-size: 20px; color: var(--icon-color); - display: flex; + display: none; flex-direction: row; align-items: center; justify-content: center; diff --git a/scaladoc/src/dotty/tools/scaladoc/api.scala b/scaladoc/src/dotty/tools/scaladoc/api.scala index c759bfe75b74..b96e3f219740 100644 --- a/scaladoc/src/dotty/tools/scaladoc/api.scala +++ b/scaladoc/src/dotty/tools/scaladoc/api.scala @@ -40,6 +40,8 @@ enum Modifier(val name: String, val prefix: Boolean): case Erased extends Modifier("erased", true) case Opaque extends Modifier("opaque", true) case Open extends Modifier("open", true) + case Transparent extends Modifier("transparent", true) + case Infix extends Modifier("infix", true) case class ExtensionTarget(name: String, typeParams: Seq[TypeParameter], argsLists: Seq[ParametersList], signature: Signature, dri: DRI, position: Long) case class ImplicitConversion(from: DRI, to: DRI) diff --git a/scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala b/scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala index d62938f16f6d..d02b0bb7248a 100644 --- a/scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala +++ b/scaladoc/src/dotty/tools/scaladoc/renderers/MemberRenderer.scala @@ -134,16 +134,17 @@ class MemberRenderer(signatureRenderer: SignatureRenderer)(using DocContext) ext val rawBuilder = ScalaSignatureProvider.rawSignature(member, InlineSignatureBuilder()) val inlineBuilder = rawBuilder.asInstanceOf[InlineSignatureBuilder] - if inlineBuilder.preName.isEmpty then println(member) val kind :: modifiersRevered = inlineBuilder.preName val signature = inlineBuilder.names.reverse Seq( span(cls := "modifiers")( span(cls := "other-modifiers")(modifiersRevered.reverse.map(renderElement)), + ), + div(cls := "signature")( span(cls := "kind")(renderElement(kind)), + renderLink(member.name, member.dri, nameClasses), + span(signature.map(renderElement)) ), - renderLink(member.name, member.dri, nameClasses), - span(cls := "signature")(signature.map(renderElement)), ) def memberIcon(member: Member) = member.kind match { diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala index b1b3cac11e50..69e2ef0c6341 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala @@ -603,20 +603,20 @@ trait ClassLikeSupport: graph: HierarchyGraph = HierarchyGraph.empty, deprecated: Option[Annotation] = None, ) = Member( - name = symbol.normalizedName, - dri = symbol.dri, - kind = kind, - visibility = symbol.getVisibility(), - modifiers = modifiers, - annotations = symbol.getAnnotations(), - signature = signature, - sources = symbol.source, - origin = origin, - inheritedFrom = inheritedFrom, - graph = graph, - docs = symbol.documentation, - deprecated = deprecated - ) + name = symbol.normalizedName, + dri = symbol.dri, + kind = kind, + visibility = symbol.getVisibility(), + modifiers = modifiers, + annotations = symbol.getAnnotations(), + signature = signature, + sources = symbol.source, + origin = origin, + inheritedFrom = inheritedFrom, + graph = graph, + docs = symbol.documentation, + deprecated = deprecated + ) object EvidenceOnlyParameterList type RegularParameterList = Map[String, TypeRepr] diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala index b8a4df3a39d1..defbdd5bbee7 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/SymOps.scala @@ -70,6 +70,7 @@ object SymOps: case (None, None, (false, true, true)) => Visibility.Protected(ThisScope) case (None, None, (false, true, false)) => Visibility.Protected(implicitScope(sym.owner)) case (None, None, (false, false, false)) => Visibility.Unrestricted + case (None, None, (true, true, false)) => Visibility.Protected(ThisScope) case _ => throw new Exception(s"Visibility for symbol $sym cannot be determined") @@ -83,6 +84,8 @@ object SymOps: Flags.Abstract -> Modifier.Abstract, Flags.Deferred -> Modifier.Deferred, Flags.Implicit -> Modifier.Implicit, + Flags.Infix -> Modifier.Infix, + Flags.Transparent -> Modifier.Transparent, Flags.Inline -> Modifier.Inline, Flags.Lazy -> Modifier.Lazy, Flags.Open -> Modifier.Open, diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala index 7156314e40aa..ed79da0e83b8 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala @@ -80,7 +80,7 @@ trait TypesSupport: case _ => false // TODO #23 add support for all types signatures that makes sense - private def inner(using Quotes)(tp: reflect.TypeRepr): DocSignature = + private def inner(using Quotes)(tp: reflect.TypeRepr)(using indent: Int = 0): DocSignature = import reflect._ def noSupported(name: String): DocSignature = println(s"WARN: Unsupported type: $name: ${tp.show}") @@ -99,6 +99,9 @@ trait TypesSupport: inner(tpe) :+ text("*") case AnnotatedType(tpe, _) => inner(tpe) + case tl @ TypeLambda(params, paramBounds, resType@AppliedType(tpe, args)) + if paramBounds.map(inner).forall(_.isEmpty) && params.zip(args.map(inner)).forall(List(_) == _) => + inner(tpe) case tl @ TypeLambda(params, paramBounds, resType) => texts("[") ++ commas(params.zip(paramBounds).map { (name, typ) => val normalizedName = if name.matches("_\\$\\d*") then "_" else name @@ -251,13 +254,15 @@ trait TypesSupport: case NoPrefix() => Nil case MatchType(bond, sc, cases) => + val caseSpaces = " " * (indent + 2) + val spaces = " " * (indent) val casesTexts = cases.flatMap { case MatchCase(from, to) => - texts(" case ") ++ inner(from) ++ texts(" => ") ++ inner(to) ++ texts("\n") + texts(caseSpaces + "case ") ++ inner(from) ++ texts(" => ") ++ inner(to)(using indent = indent + 2) ++ texts("\n") case TypeLambda(_, _, MatchCase(from, to)) => - texts(" case ") ++ inner(from) ++ texts(" => ") ++ inner(to) ++ texts("\n") + texts(caseSpaces + "case ") ++ inner(from) ++ texts(" => ") ++ inner(to)(using indent = indent + 2) ++ texts("\n") } - inner(sc) ++ texts(" match {\n") ++ casesTexts ++ texts("}") + inner(sc) ++ texts(" match {\n") ++ casesTexts ++ texts(spaces + "}") case ParamRef(TypeLambda(names, _, _), i) => texts(names.apply(i)) diff --git a/scaladoc/test/dotty/tools/scaladoc/signatures/SignatureTest.scala b/scaladoc/test/dotty/tools/scaladoc/signatures/SignatureTest.scala index c232f03a63a1..ebd53db8c77e 100644 --- a/scaladoc/test/dotty/tools/scaladoc/signatures/SignatureTest.scala +++ b/scaladoc/test/dotty/tools/scaladoc/signatures/SignatureTest.scala @@ -119,7 +119,7 @@ abstract class SignatureTest( val sigPrefix = elem.select(".header .signature").textNodes match case list if list.size > 0 && list.get(0).getWholeText().startsWith(" ") => " " case _ => "" - val all = s"$annotations$other $kind $name$sigPrefix$signature".trim() + val all = s"$annotations$other $sigPrefix$signature".trim() signatures += all }