Skip to content

Commit f3312e5

Browse files
committed
Preliminary commit for preventing mismatches on members named md
1 parent 5192eac commit f3312e5

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

doc-tool/src/dotty/tools/dottydoc/staticsite/MarkdownLinkVisitor.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ import com.vladsch.flexmark.util.sequence.CharSubSequence
77
import model.{ Package, NonEntity, Val, Def, TypeAlias }
88
import dottydoc.util.MemberLookup
99

10+
import dotty.tools.dotc.core.Contexts.Context
11+
import dotty.tools.dotc.core.Decorators._
12+
1013
object MarkdownLinkVisitor {
1114
private val EntityLink = """([^\.]+)(\.[^\.]+)*""".r
12-
def apply(node: Node, docs: Map[String, Package], params: Map[String, AnyRef]): Unit =
15+
def apply(node: Node, docs: Map[String, Package], params: Map[String, AnyRef])(implicit ctx: Context): Unit =
1316
(new NodeVisitor(
1417
new VisitHandler(classOf[Link], new Visitor[Link] with MemberLookup {
1518
override def visit(node: Link): Unit = {
1619
val url = node.getUrl
17-
if (url.endsWith(".md")) node.setUrl {
20+
val x = new java.net.URI(url.toString)
21+
val path = x.getPath()
22+
val method = path.substring(path.lastIndexOf('/')+1).dropRight(3);
23+
val method1 = method.toTypeName
24+
if ((url.endsWith(".md")) && (ctx.getClassIfDefined(method1).exists == false)) node.setUrl{
1825
url.subSequence(0, url.lastIndexOf('.')).append(".html")
1926
}
2027
else if (EntityLink.unapplySeq(url.toString).isDefined) {

0 commit comments

Comments
 (0)