aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dottydoc/js/src/html/Member.scala27
-rw-r--r--dottydoc/jvm/resources/index.css5
-rw-r--r--dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala10
-rw-r--r--dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala1
-rw-r--r--dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala43
-rw-r--r--dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/pickling.scala1
6 files changed, 62 insertions, 25 deletions
diff --git a/dottydoc/js/src/html/Member.scala b/dottydoc/js/src/html/Member.scala
index 92c758caf..4ab214fdb 100644
--- a/dottydoc/js/src/html/Member.scala
+++ b/dottydoc/js/src/html/Member.scala
@@ -122,15 +122,30 @@ trait MemberLayout {
if (rv.paramLinks.nonEmpty) span(
returnValue,
- "[", rv.paramLinks.map(decodeTpeLink), "]" //FIXME: does not get spacing and commas
+ "[",
+ rv.paramLinks
+ .map(decodeTpeLink)
+ .flatMap { sp =>
+ Seq(sp, span(cls := "type-separator no-left-margin", ",").render)
+ }
+ .dropRight(1),
+ "]"
).render
else returnValue
- case _ => ??? /** TODO: should not happen currently, but when
- * `returnValue` in factories is changes - this will get
- * triggered
- */
- }
+ case OrTypeReference(left, right) => span(
+ cls := "member-return-value or-type",
+ link(left),
+ span(cls := "type-separator", "|"),
+ link(right)
+ ).render
+ case AndTypeReference(left, right) => span(
+ cls := "member-return-value and-type",
+ link(left),
+ span(cls := "type-separator", "&"),
+ link(right)
+ ).render
+ }
}
m match {
diff --git a/dottydoc/jvm/resources/index.css b/dottydoc/jvm/resources/index.css
index 6d3a06bdd..e68cf5ac5 100644
--- a/dottydoc/jvm/resources/index.css
+++ b/dottydoc/jvm/resources/index.css
@@ -146,6 +146,11 @@ div.summary-comment {
margin-left: 0;
}
+span.member-return-value > span.type-separator {
+ margin: 0 10px;
+}
+
+
/* Search results ----------------------------------------------------------- */
main#search-results {
display: none;
diff --git a/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala b/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala
index bcb51b3d9..71ed12cec 100644
--- a/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala
+++ b/dottydoc/jvm/src/dotty/tools/dottydoc/model/json.scala
@@ -36,10 +36,11 @@ object json extends DefaultJsonProtocol {
implicit object ReferenceFormat extends RootJsonFormat[Reference] {
def write(obj: Reference) = obj match {
- case obj: AndTypeReference => obj.toJson
- case obj: OrTypeReference => obj.toJson
- case obj: TypeReference => obj.toJson
- case obj: NamedReference => obj.toJson
+ case obj: AndTypeReference => obj.toJson
+ case obj: OrTypeReference => obj.toJson
+ case obj: TypeReference => obj.toJson
+ case obj: NamedReference => obj.toJson
+ case obj: ConstantReference => obj.toJson
}
def read(json: JsValue) = ??? // The json serialization is supposed to be one way
}
@@ -48,6 +49,7 @@ object json extends DefaultJsonProtocol {
implicit val orRefFormat = lazyFormat(jsonFormat(OrTypeReference, "left", "right"))
implicit val andRefFormat = lazyFormat(jsonFormat(AndTypeReference, "left", "right"))
implicit val namedRefFormat = lazyFormat(jsonFormat(NamedReference, "title", "ref"))
+ implicit val constRefFormat = lazyFormat(jsonFormat(ConstantReference, "title"))
implicit object EntityJsonFormat extends RootJsonFormat[Entity] {
diff --git a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala
index bd082ef1e..37f1b05fe 100644
--- a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala
+++ b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/comment/BodyEntities.scala
@@ -104,3 +104,4 @@ final case class TypeReference(title: String, tpeLink: MaterializableLink, param
final case class OrTypeReference(left: Reference, right: Reference) extends Reference
final case class AndTypeReference(left: Reference, right: Reference) extends Reference
final case class NamedReference(title: String, ref: Reference) extends Reference
+final case class ConstantReference(title: String) extends Reference
diff --git a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala
index c66576896..e6a548b0f 100644
--- a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala
+++ b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/factories.scala
@@ -61,24 +61,37 @@ object factories {
}
def returnType(t: TypeTree)(implicit ctx: Context): Reference = {
- def tpeWithParamTpes(t: Type): List[String] = t match {
- case ref @ RefinedType(parent, rn) =>
- val name = ref.refinedInfo match {
- case ta: TypeAlias => ta.alias.asInstanceOf[NamedType].name.decode.toString
- case _ => rn.decode.toString.split("\\$").last
+ def typeRef(name: String, params: List[MaterializableLink]) =
+ TypeReference(name, UnsetLink(Text(name), name), params)
+
+ def expandTpe(t: Type, params: List[MaterializableLink] = Nil): Reference = t match {
+ case ref @ RefinedType(parent, rn) => {
+ val paramName = ref.refinedInfo match {
+ case ta: TypeAlias if ta.alias.isInstanceOf[NamedType] =>
+ ta.alias.asInstanceOf[NamedType].name.decode.toString
+ case _ =>
+ rn.decode.toString.split("\\$").last
}
- tpeWithParamTpes(parent) ++ (name :: Nil)
- case TypeRef(_, name) => name.decode.toString :: Nil
- case OrType(left, right) => "ortype" :: Nil
- case AndType(left, right) => "andtype" :: Nil
- case AnnotatedType(tpe, _) => tpeWithParamTpes(tpe)
- case c: ConstantType => c.show :: Nil
+ val param = UnsetLink(Text(paramName), paramName)
+ expandTpe(parent, param :: params)
+ }
+ case TypeRef(_, name) =>
+ typeRef(name.decode.toString, params)
+ case OrType(left, right) =>
+ OrTypeReference(expandTpe(left), expandTpe(right))
+ case AndType(left, right) =>
+ AndTypeReference(expandTpe(left), expandTpe(right))
+ case AnnotatedType(tpe, _) =>
+ expandTpe(tpe)
+ case ExprType(tpe) =>
+ expandTpe(tpe)
+ case c: ConstantType =>
+ ConstantReference(c.show)
+ case tt: ThisType =>
+ expandTpe(tt.underlying)
}
- val List(retTpe, params @ _*) = tpeWithParamTpes(t.tpe)
-
- //TODO: should not be a TypeReference but a Reference because of Or/And-types
- TypeReference(retTpe, UnsetLink(Text(retTpe), retTpe), params.map(x => UnsetLink(Text(x), x)).toList)
+ expandTpe(t.tpe)
}
def typeParams(t: Tree)(implicit ctx: Context): List[String] = t match {
diff --git a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/pickling.scala b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/pickling.scala
index 3ef4ab4a9..76a2effa6 100644
--- a/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/pickling.scala
+++ b/dottydoc/shared/src/main/scala/dotty/tools/dottydoc/model/pickling.scala
@@ -27,6 +27,7 @@ object pickling {
.concreteType[OrTypeReference]
.concreteType[AndTypeReference]
.concreteType[NamedReference]
+ .concreteType[ConstantReference]
implicit val entityPickler: PicklerPair[Entity] = CompositePickler[Entity]
.concreteType[NonEntity.type]