@@ -8,10 +8,13 @@ import java.nio.file.FileVisitOption
8
8
import org .jetbrains .dokka .base .renderers .html .{NavigationNode , NavigationPage }
9
9
import org .jetbrains .dokka .links .DRI
10
10
import org .jetbrains .dokka .model .Documentable
11
+ import org .jetbrains .dokka .model .DPackage
12
+ import org .jetbrains .dokka .model .DModule
11
13
import org .jetbrains .dokka .pages ._
12
14
import org .jetbrains .dokka .transformers .pages .PageTransformer
13
15
14
16
import scala .collection .JavaConverters ._
17
+ import dotty .dokka .model .api ._
15
18
16
19
abstract class BaseStaticSiteProcessor (staticSiteContext : Option [StaticSiteContext ]) extends PageTransformer :
17
20
final override def invoke (input : RootPageNode ): RootPageNode = staticSiteContext.fold(input)(transform(input, _))
@@ -119,22 +122,36 @@ class RootIndexPageCreator(ctx: Option[StaticSiteContext]) extends BaseStaticSit
119
122
val (contentNodes, nonContent) = input.getChildren.asScala.partition { _.isInstanceOf [ContentNode ] }
120
123
val (navigations, rest) = nonContent.partition { _.isInstanceOf [NavigationPage ] }
121
124
val modifiedNavigation = navigations.map { it =>
122
- val root = it.asInstanceOf [NavigationPage ].getRoot
123
- val api = root.getChildren.asScala.filter(_.getDri == apiPageDRI)
125
+ val sourceSets = it.asInstanceOf [NavigationPage ].getRoot.getSourceSets
126
+ def flatMapPackages (pn : PageNode ): List [NavigationNode ] =
127
+ def processChildren = pn.getChildren.asScala.flatMap(flatMapPackages).toList
128
+ pn match
129
+ case cp : ContentPage => cp.getDocumentable match
130
+ case null =>
131
+ processChildren
132
+ case p : DPackage =>
133
+ List (new NavigationNode (p.getName, p.getDri, sourceSets, JList ())) ++ processChildren
134
+ case other =>
135
+ Nil
136
+ case _ =>
137
+ Nil
138
+
139
+ val packagesNavigation = input.getChildren.asScala.flatMap(flatMapPackages).sortBy(_.getName)
140
+ val api = new NavigationNode (" API" , apiPageDRI, sourceSets, packagesNavigation.asJava)
124
141
125
142
def toNavigationNode (page : StaticPageNode ): NavigationNode = NavigationNode (
126
143
page.title(),
127
144
page.getDri.asScala.head,
128
- root.getSourceSets ,
145
+ sourceSets ,
129
146
page.getChildren.asScala.collect { case p : StaticPageNode => toNavigationNode(p)}.asJava
130
147
)
131
148
132
149
new NavigationPage (
133
150
new NavigationNode (
134
151
input.getName,
135
152
docsRootDRI,
136
- root.getSourceSets ,
137
- (ctx.mainPages.map(toNavigationNode) ++ api).asJava
153
+ sourceSets ,
154
+ (ctx.mainPages.map(toNavigationNode) ++ Seq ( api) ).asJava
138
155
)
139
156
)
140
157
}
0 commit comments