@@ -20,6 +20,7 @@ import dotty.dokka.model.api.Link
20
20
import dotty .dokka .model .api .HierarchyGraph
21
21
import org .jetbrains .dokka .base .resolvers .local .LocationProvider
22
22
import dotty .dokka .site .StaticPageNode
23
+ import dotty .dokka .site .PartiallyRenderedContent
23
24
24
25
class SignatureRenderer (pageContext : ContentPage , sourceSetRestriciton : JSet [DisplaySourceSet ], locationProvider : LocationProvider ):
25
26
def link (dri : DRI ): Option [String ] = Option (locationProvider.resolve(dri, sourceSetRestriciton, pageContext))
@@ -37,7 +38,7 @@ class SignatureRenderer(pageContext: ContentPage, sourceSetRestriciton: JSet[Dis
37
38
38
39
def renderElement (e : String | (String , DRI ) | Link ) = renderElementWith(e)
39
40
40
- class ScalaHtmlRenderer (ctx : DokkaContext ) extends HtmlRenderer (ctx) { // TODO migrate from dokka site!
41
+ class ScalaHtmlRenderer (ctx : DokkaContext ) extends HtmlRenderer (ctx) {
41
42
42
43
// Implementation below is based on Kotlin bytecode and we will try to migrate it to dokka
43
44
// TODO (https://github.com/lampepfl/scala3doc/issues/232): Move this method to dokka
@@ -206,6 +207,7 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) { // TODO m
206
207
pageContext : ContentPage ,
207
208
): Unit = {
208
209
// we cannot use Scalatags, because we need to call buildContentNode
210
+ // TODO rewrite it to using HTML
209
211
import kotlinx .html .{Gen_consumer_tagsKt => dsl }
210
212
val c = f.getConsumer
211
213
@@ -231,6 +233,30 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) { // TODO m
231
233
).toString()
232
234
)
233
235
236
+ private def render (c : PartiallyRenderedContent , p : ContentPage ): String =
237
+ val parsed = if (! c.page.hasMarkdown) c.page.code else
238
+ div(raw(
239
+ buildWithKotlinx{ div =>
240
+ c.getChildren.forEach(build(_, div, p, /* sourceSetRestriction=*/ null ))
241
+ U
242
+ }
243
+ )).toString
244
+
245
+ return c.page.render(parsed).code
246
+
247
+
248
+ override def buildPageContent (context : FlowContent , page : ContentPage ): Unit =
249
+ page match
250
+ case s : StaticPageNode if ! s.hasFrame() =>
251
+ case _ => buildNavigation(context, page)
252
+
253
+ page.getContent match
254
+ case prc : PartiallyRenderedContent =>
255
+ withHtml(context, render(prc, page))
256
+ case content =>
257
+ build(content, context, page, /* sourceSetRestriction=*/ null )
258
+
259
+
234
260
override def buildHtml (page : PageNode , resources : JList [String ], kotlinxContent : FlowContentConsumer ): String =
235
261
val (pageTitle, pageResources, fromTemplate) = page match
236
262
case static : StaticPageNode =>
@@ -316,5 +342,4 @@ class ScalaHtmlRenderer(ctx: DokkaContext) extends HtmlRenderer(ctx) { // TODO m
316
342
null ,
317
343
func
318
344
).toString.stripPrefix(" <div>" ).stripSuffix(" </div>\n " )
319
-
320
345
}
0 commit comments