Skip to content

Prevent mismatches on members named md #2526

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,28 @@ 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]): Unit =
def apply(node: Node, docs: Map[String, Package], params: Map[String, AnyRef])(implicit ctx: Context): 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")) node.setUrl {
url.subSequence(0, url.lastIndexOf('.')).append(".html")

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")
}
}
else if (EntityLink.unapplySeq(url.toString).isDefined) {
lookup(NonEntity, docs, url.toString).foreach { ent =>
Expand Down