aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-01-18 11:03:43 +0100
committerFelix Mulder <felix.mulder@gmail.com>2017-01-31 14:32:39 +0100
commit25821bfc25685ab648dd6eb1a11d0f8991a07a75 (patch)
treec204d26687f78c6a2c8f830059cca707b3d4b3af /doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala
parent8b9b98a22f364a35e32b674b9ef5188bee15a2c9 (diff)
downloaddotty-25821bfc25685ab648dd6eb1a11d0f8991a07a75.tar.gz
dotty-25821bfc25685ab648dd6eb1a11d0f8991a07a75.tar.bz2
dotty-25821bfc25685ab648dd6eb1a11d0f8991a07a75.zip
Rewire `MemberLookup` to return `Option[Entity]`
This allows for the rendering engine to supply the base url for the site and thus being able to simplify the entity links. They now simply become `Entity#path + .html` instead of a convoluted rendering in the html renderers.
Diffstat (limited to 'doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala')
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala20
1 files changed, 11 insertions, 9 deletions
diff --git a/doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala b/doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala
index 5b13930f2..245db060d 100644
--- a/doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/core/TypeLinkingPhases.scala
@@ -43,9 +43,7 @@ class LinkSuperTypes extends DocMiniPhase with TypeLinker {
def linkSuperTypes(ent: Entity with SuperTypes)(implicit ctx: Context): List[MaterializableLink] =
ent.superTypes.collect {
case UnsetLink(title, query) =>
- val packages = ctx.docbase.packages
- val entityLink = makeEntityLink(ent, packages, Text(title), NoPosition, query).link
- handleEntityLink(title, entityLink, ent)
+ handleEntityLink(title, lookup(ent, ctx.docbase.packages, query), ent)
}
override def transformClass(implicit ctx: Context) = { case cls: ClassImpl =>
@@ -80,11 +78,15 @@ class LinkImplicitlyAddedTypes extends DocMiniPhase with TypeLinker {
}
trait TypeLinker extends MemberLookup {
- def handleEntityLink(title: String, lt: LinkTo, ent: Entity): MaterializableLink = lt match {
- case Tooltip(str) => NoLink(title, str)
- case LinkToExternal(_, url) => MaterializedLink(title, url)
- case LinkToEntity(target) => MaterializedLink(title, util.traversing.relativePath(ent, target))
- }
+ def handleEntityLink(title: String, target: Option[Entity], ent: Entity, query: String = ""): MaterializableLink =
+ target match {
+ case Some(target: Package) =>
+ MaterializedLink(title, target.path.mkString("/") + "/index.html")
+ case Some(target) =>
+ MaterializedLink(title, target.path.mkString("/") + ".html")
+ case none =>
+ NoLink(title, query)
+ }
def linkReference(ent: Entity, ref: Reference, packs: Map[String, Package]): Reference = {
def linkRef(ref: Reference) = linkReference(ent, ref, packs)
@@ -94,7 +96,7 @@ trait TypeLinker extends MemberLookup {
val inlineToHtml = InlineToHtml(ent)
val title = t
- val target = handleEntityLink(title, makeEntityLink(ent, packs, Text(t), NoPosition, query).link, ent)
+ val target = handleEntityLink(title, lookup(ent, packs, query), ent, query)
val tpTargets = tps.map(linkReference(ent, _, packs))
ref.copy(tpeLink = target, paramLinks = tpTargets)
case ref @ OrTypeReference(left, right) =>