@@ -5,13 +5,14 @@ import org.jetbrains.dokka.pages.ContentPage
5
5
import org .jetbrains .dokka .pages .PageNode
6
6
import org .jetbrains .dokka .pages .RootPageNode
7
7
import org .jetbrains .dokka .pages .ModulePage
8
+ import org .jetbrains .dokka .pages .ClasslikePageNode
8
9
import org .jetbrains .dokka .model .DPackage
9
10
import org .jetbrains .dokka .plugability .DokkaContext
10
11
import org .jetbrains .dokka .base .resolvers .external ._
11
12
import org .jetbrains .dokka .base .resolvers .shared ._
12
13
import org .jetbrains .dokka .base .resolvers .local ._
13
14
import org .jetbrains .dokka .model .DisplaySourceSet
14
- import dotty .dokka .model . api . withNoOrigin
15
+ import dotty .dokka .withNoOrigin
15
16
16
17
import scala .collection .JavaConverters ._
17
18
import java .nio .file .Paths
@@ -86,17 +87,35 @@ class StaticSiteLocationProvider(pageNode: RootPageNode)(using ctx: DokkaContext
86
87
override val getPathsIndex : JMap [PageNode , JList [String ]] =
87
88
super .getPathsIndex.asScala.mapValuesInPlace(updatePageEntry).asJava
88
89
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
+ }
89
106
90
107
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(" /" )
100
119
101
120
val externalLocationProviders : List [(List [Regex ], ExternalLocationProvider )] =
102
121
val sourceSet = ctx.getConfiguration.getSourceSets.asScala(0 )
0 commit comments