From 25821bfc25685ab648dd6eb1a11d0f8991a07a75 Mon Sep 17 00:00:00 2001 From: Felix Mulder Date: Wed, 18 Jan 2017 11:03:43 +0100 Subject: 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. --- doc-tool/src/dotty/tools/dottydoc/model/comment/Comment.scala | 9 ++++----- .../src/dotty/tools/dottydoc/model/comment/HtmlParsers.scala | 4 ++-- doc-tool/src/dotty/tools/dottydoc/model/comment/WikiParser.scala | 2 +- doc-tool/src/dotty/tools/dottydoc/model/factories.scala | 1 + 4 files changed, 8 insertions(+), 8 deletions(-) (limited to 'doc-tool/src/dotty/tools/dottydoc/model') 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(_ != "") .filter(_ != "interface") + .filter(_ != "case") def path(sym: Symbol)(implicit ctx: Context): List[String] = sym match { case sym if sym.name.decode.toString == "" => Nil -- cgit v1.2.3