diff --git a/documentation/docs/static-page/random.html b/documentation/docs/static-page/random.html new file mode 100644 index 0000000..fe04218 --- /dev/null +++ b/documentation/docs/static-page/random.html @@ -0,0 +1,6 @@ +--- +layout: vl_header +title: Sample html page +--- + +Hello world! diff --git a/documentation/index.md b/documentation/index.md index 579b3f1..2445cca 100644 --- a/documentation/index.md +++ b/documentation/index.md @@ -1,9 +1,11 @@ +--- +layout: vl_header +--- + # Dokka site **Generate a static documentation for in your dokka project** - - **Yes, this page was generated using dokka-site** You can learn more from out [documentation](dokka-site/index.html). diff --git a/src/main/kotlin/com/virtuslab/dokka/site/processors.kt b/src/main/kotlin/com/virtuslab/dokka/site/processors.kt index da0d1d4..4ca0380 100644 --- a/src/main/kotlin/com/virtuslab/dokka/site/processors.kt +++ b/src/main/kotlin/com/virtuslab/dokka/site/processors.kt @@ -157,7 +157,6 @@ class SiteResourceManager(cxt: DokkaContext) : BaseStaticSiteProcessor(cxt) { } }.toSet() - override fun transform(input: RootPageNode): RootPageNode { val images = File(root, "images").walkTopDown().filter { it.isFile } .map { root.toPath().relativize(it.toPath()).toString() } diff --git a/src/main/kotlin/com/virtuslab/dokka/site/renderer.kt b/src/main/kotlin/com/virtuslab/dokka/site/renderer.kt index 2d8e1ee..edf7c3e 100644 --- a/src/main/kotlin/com/virtuslab/dokka/site/renderer.kt +++ b/src/main/kotlin/com/virtuslab/dokka/site/renderer.kt @@ -31,8 +31,8 @@ class ExternalDocsToolRenderer(context: DokkaContext) : org.jetbrains.dokka.base is BaseStaticSiteProcessor.MdPageNode -> if (page.dri.contains(docsRootDRI)) { val parser: Parser = Parser.builder().build() - val htmlContent = - HtmlRenderer.builder(defaultMarkdownOptions).build().render(parser.parse(page.resolved.code)) + val htmlRenderer = HtmlRenderer.builder(defaultMarkdownOptions).build() + val htmlContent = htmlRenderer.render(parser.parse(page.resolved.code)) createHtml(page, htmlContent) } else super.buildHtml(page, resources, content) else -> diff --git a/src/main/kotlin/com/virtuslab/dokka/site/templates.kt b/src/main/kotlin/com/virtuslab/dokka/site/templates.kt index bf4ad5e..3aacb29 100644 --- a/src/main/kotlin/com/virtuslab/dokka/site/templates.kt +++ b/src/main/kotlin/com/virtuslab/dokka/site/templates.kt @@ -81,24 +81,30 @@ data class TemplateFile(val file: File, val rawCode: String, private val setting fun title(): String = stringSetting("title") ?: name() fun layout(): String? = stringSetting("layout") - fun resolve(ctx: RenderingContext): ResolvedPage = - resolveInner(ctx.copy(properties = HashMap(ctx.properties) + ("page" to mapOf("title" to title()))), hasHtmlContent = false) + resolveInner( + ctx = ctx.copy(properties = HashMap(ctx.properties) + ("page" to mapOf("title" to title()))), + hasHtmlContent = false + ) private fun resolveInner(ctx: RenderingContext, hasHtmlContent: Boolean): ResolvedPage { if (ctx.resolving.contains(file.absolutePath)) throw java.lang.RuntimeException("Cycle in templates involving $file: ${ctx.resolving}") val rendered = Template.parse(this.rawCode).render(HashMap(ctx.properties)) // Library requires mutable maps.. - val code = if (!(isHtml || hasHtmlContent)) rendered else { + val toBeResolvedIsHtml = isHtml || hasHtmlContent + val code = if (!toBeResolvedIsHtml) rendered else { val parser: Parser = Parser.builder().build() HtmlRenderer.builder(ctx.markdownOptions).build().render(parser.parse(rendered)) } val resources = listSetting("extraCSS") + listSetting("extraJS") return layout()?.let { val layoutTemplate = ctx.layouts[it] ?: throw RuntimeException("No layouts named $it in ${ctx.layouts}") - layoutTemplate.resolveInner(ctx.nest(code, file.absolutePath, resources), hasHtmlContent = isHtml) - } ?: ResolvedPage(code, isHtml, resources + ctx.resources) + layoutTemplate.resolveInner( + ctx = ctx.nest(code, file.absolutePath, resources), + hasHtmlContent = toBeResolvedIsHtml + ) + } ?: ResolvedPage(code, toBeResolvedIsHtml, resources + ctx.resources) } } @@ -124,5 +130,6 @@ fun loadTemplateFile(file: File): TemplateFile { return TemplateFile( file = file, rawCode = content.joinToString(LineSeparator), - settings = yamlCollector.data) + settings = yamlCollector.data + ) }