Skip to content

Commit

Permalink
Merge pull request scala#2604 from dotty-staging/topic/revert-2526
Browse files Browse the repository at this point in the history
Revert "Prevent mismatches on members named md (scala#2526)"
  • Loading branch information
felixmulder authored May 30, 2017
2 parents 877e9e7 + aac123d commit 4daa92d
Showing 1 changed file with 3 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,15 @@ import com.vladsch.flexmark.util.sequence.CharSubSequence
import model.{ Package, NonEntity, Val, Def, TypeAlias }
import dottydoc.util.MemberLookup

import dotty.tools.dotc.core.Contexts.Context
import dotty.tools.dotc.core.Decorators._

object MarkdownLinkVisitor {
private val EntityLink = """([^\.]+)(\.[^\.]+)*""".r
def apply(node: Node, docs: Map[String, Package], params: Map[String, AnyRef])(implicit ctx: Context): Unit =
def apply(node: Node, docs: Map[String, Package], params: Map[String, AnyRef]): Unit =
(new NodeVisitor(
new VisitHandler(classOf[Link], new Visitor[Link] with MemberLookup {
override def visit(node: Link): Unit = {
val url = node.getUrl

if (url.endsWith(".md")) {
if (url.subSequence(0, url.lastIndexOf('.')).indexOf("/") < 0) {
val method = url.subSequence(0, url.lastIndexOf('.')).toString.toTypeName
if (ctx.getClassIfDefined(method).exists) node.setUrl {
url.subSequence(0, url.lastIndexOf('.')).append(".html")
} else {
ctx.error(s"""Ambiguous reference to "$url"""")
}
} else node.setUrl {
url.subSequence(0, url.lastIndexOf('.')).append(".html")
}
if (url.endsWith(".md")) node.setUrl {
url.subSequence(0, url.lastIndexOf('.')).append(".html")
}
else if (EntityLink.unapplySeq(url.toString).isDefined) {
lookup(NonEntity, docs, url.toString).foreach { ent =>
Expand Down

0 comments on commit 4daa92d

Please sign in to comment.