aboutsummaryrefslogtreecommitdiff
path: root/doc-tool/src/dotty/tools/dottydoc/model
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/model
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/model')
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala9
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala4
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala2
-rw-r--r--doc-tool/src/dotty/tools/dottydoc/model/factories.scala1
4 files changed, 8 insertions, 8 deletions
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala
index 842746338..e50d2be90 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala
@@ -62,9 +62,8 @@ object MarkdownComment extends util.MemberLookup {
val inlineToHtml = InlineToHtml(ent)
def linkedExceptions(m: Map[String, String]): Map[String, String] = {
m.map { case (targetStr, body) =>
- val link = lookup(ent, ctx.docbase.packages, targetStr)
- val entityLink = EntityLink(Monospace(Text(targetStr)), link)
- (targetStr, inlineToHtml(entityLink))
+ val link = makeEntityLink(ent, ctx.docbase.packages, Monospace(Text(targetStr)), targetStr)
+ (targetStr, inlineToHtml(link))
}
}
@@ -121,8 +120,8 @@ object WikiComment extends util.MemberLookup {
val newBody = body match {
case Body(List(Paragraph(Chain(content)))) =>
val descr = Text(" ") +: content
- val entityLink = EntityLink(Monospace(Text(targetStr)), link)
- Body(List(Paragraph(Chain(entityLink +: descr))))
+ val link = makeEntityLink(ent, ctx.docbase.packages, Monospace(Text(targetStr)), targetStr)
+ Body(List(Paragraph(Chain(link +: descr))))
case _ => body
}
(targetStr, newBody)
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala
index 475157dce..4ddbfd6ab 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala
@@ -37,7 +37,7 @@ object HtmlParsers {
val linkVisitor = new NodeVisitor(
new VisitHandler(classOf[Link], new Visitor[Link] with MemberLookup {
- def queryToUrl(link: String) = lookup(origin, ctx.docbase.packages, link) match {
+ def queryToUrl(title: String, link: String) = makeEntityLink(origin, ctx.docbase.packages, Text(title), link).link match {
case Tooltip(_) => "#"
case LinkToExternal(_, url) => url
case LinkToEntity(t: Entity) => t match {
@@ -49,7 +49,7 @@ object HtmlParsers {
override def visit(link: Link) = {
val linkUrl = link.getUrl.toString
if (!isOuter(linkUrl) && !isRelative(linkUrl))
- link.setUrl(CharSubSequence.of(queryToUrl(linkUrl)))
+ link.setUrl(CharSubSequence.of(queryToUrl(link.getTitle.toString, linkUrl)))
}
})
)
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala b/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala
index 13d74d4b3..176dab569 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala
@@ -335,7 +335,7 @@ private[comment] final class WikiParser(
case (SchemeUri(uri), optTitle) =>
Link(uri, optTitle getOrElse Text(uri))
case (qualName, optTitle) =>
- makeEntityLink(entity, packages, optTitle getOrElse Text(target), pos, target)
+ makeEntityLink(entity, packages, optTitle getOrElse Text(target), target)
}
}
diff --git a/doc-tool/src/dotty/tools/dottydoc/model/factories.scala b/doc-tool/src/dotty/tools/dottydoc/model/factories.scala
index 0f4df7640..568b532b7 100644
--- a/doc-tool/src/dotty/tools/dottydoc/model/factories.scala
+++ b/doc-tool/src/dotty/tools/dottydoc/model/factories.scala
@@ -26,6 +26,7 @@ object factories {
.flagStrings.toList
.filter(_ != "<trait>")
.filter(_ != "interface")
+ .filter(_ != "case")
def path(sym: Symbol)(implicit ctx: Context): List[String] = sym match {
case sym if sym.name.decode.toString == "<root>" => Nil