@@ -5,13 +5,14 @@ import org.jetbrains.dokka.pages.ContentPage
55import org .jetbrains .dokka .pages .PageNode
66import org .jetbrains .dokka .pages .RootPageNode
77import org .jetbrains .dokka .pages .ModulePage
8+ import org .jetbrains .dokka .pages .ClasslikePageNode
89import org .jetbrains .dokka .model .DPackage
910import org .jetbrains .dokka .plugability .DokkaContext
1011import org .jetbrains .dokka .base .resolvers .external ._
1112import org .jetbrains .dokka .base .resolvers .shared ._
1213import org .jetbrains .dokka .base .resolvers .local ._
1314import org .jetbrains .dokka .model .DisplaySourceSet
14- import dotty .dokka .model . api . withNoOrigin
15+ import dotty .dokka .withNoOrigin
1516
1617import scala .collection .JavaConverters ._
1718import java .nio .file .Paths
@@ -86,17 +87,35 @@ class StaticSiteLocationProvider(pageNode: RootPageNode)(using ctx: DokkaContext
8687 override val getPathsIndex : JMap [PageNode , JList [String ]] =
8788 super .getPathsIndex.asScala.mapValuesInPlace(updatePageEntry).asJava
8889
90+ // We should build our own provider at some point
91+ val ourPages : Map [String , ClasslikePageNode ] = getPathsIndex.asScala.collect {
92+ case (node : ClasslikePageNode , path) => node.getDri.asScala.head.location -> node
93+ }.toMap
94+
95+
96+ override def resolve (
97+ dri : DRI ,
98+ sourceSets : JSet [DisplaySourceSet ],
99+ context : PageNode ): String =
100+ ourPages.get(dri.location).fold(super .resolve(dri, sourceSets, context)){ page =>
101+ val path = pathTo(page,context) match
102+ case " " => " "
103+ case path => s " $path.html "
104+ dri.anchor.fold(path)(hash => s " $path# $hash" )
105+ }
89106
90107 override def pathTo (node : PageNode , context : PageNode ): String =
91- val nodePaths = getPathsIndex.get(node).asScala
92- val contextPaths = Option (context).fold(Nil )(getPathsIndex.get(_).asScala.dropRight(1 ))
93- val commonPaths = nodePaths.zip(contextPaths).takeWhile{ case (a, b) => a == b }.size
94-
95- val contextPath = contextPaths.drop(commonPaths).map(_ => " .." )
96- val nodePath = nodePaths.drop(commonPaths) match
97- case l if l.isEmpty => Seq (" index" )
98- case l => l
99- (contextPath ++ nodePath).mkString(" /" )
108+ if node == context then " "
109+ else
110+ val nodePaths = getPathsIndex.get(node).asScala
111+ val contextPaths = Option (context).fold(Nil )(getPathsIndex.get(_).asScala.dropRight(1 ))
112+ val commonPaths = nodePaths.zip(contextPaths).takeWhile{ case (a, b) => a == b }.size
113+
114+ val contextPath = contextPaths.drop(commonPaths).map(_ => " .." )
115+ val nodePath = nodePaths.drop(commonPaths) match
116+ case l if l.isEmpty => Seq (" index" )
117+ case l => l
118+ (contextPath ++ nodePath).mkString(" /" )
100119
101120 val externalLocationProviders : List [(List [Regex ], ExternalLocationProvider )] =
102121 val sourceSet = ctx.getConfiguration.getSourceSets.asScala(0 )
0 commit comments