From 1230f834d4bf9cdc26730d5c9ac8294d325dc133 Mon Sep 17 00:00:00 2001 From: mkondratek Date: Thu, 17 Sep 2020 11:01:48 +0200 Subject: [PATCH] Handle root related links --- documentation/docs/static-page/links.md | 4 ++-- .../kotlin/com/virtuslab/dokka/site/processors.kt | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/documentation/docs/static-page/links.md b/documentation/docs/static-page/links.md index ea58620..96438dd 100644 --- a/documentation/docs/static-page/links.md +++ b/documentation/docs/static-page/links.md @@ -7,6 +7,6 @@ title: Links Our side supports standard markdown links: - TODO Using standard [urls](https://pl.wikipedia.org/wiki/Uniform_Resource_Locator) - - TODO To [other pages](/docs/static-page/random.html) (or [md base file](/docs/static-page/tables.md)) in our documentation that using paths relative to root od documentation e.g. `/docs/static-page/random.html` for this project - - TODO To [other pages](/docs/static-page/samples/random.html) (or [md base file](samples/tables.md)) in our documentation that using paths relative to this file e.g. using `random.html` (or `tables.md`) + - TODO To [other (html) pages](/docs/static-page/samples/plain_html_file.html) (or [md based files](/docs/static-page/samples/plain_md_file.md)) in our documentation that using paths relative to root od documentation e.g. `/docs/static-page/sample/plain_html_file.html` for this project + - TODO To [other (html) pages](samples/plain_html_file.html) (or [md based files](samples/plain_md_file.md)) in our documentation that using paths relative to this file e.g. using `samples/plain_html_file.html` - TODO To API using `[fully.quallifty.Name]` diff --git a/src/main/kotlin/com/virtuslab/dokka/site/processors.kt b/src/main/kotlin/com/virtuslab/dokka/site/processors.kt index e62a9f5..1f7bbc2 100644 --- a/src/main/kotlin/com/virtuslab/dokka/site/processors.kt +++ b/src/main/kotlin/com/virtuslab/dokka/site/processors.kt @@ -174,7 +174,7 @@ class SitePagesCreator(cxt: DokkaContext) : BaseStaticSiteProcessor(cxt) { private fun isValidTemplate(file: File): Boolean = - (file.isDirectory && !file.name.startsWith("_")) || + (file.isDirectory && !file.name.startsWith("_")) || file.name.endsWith(".md") || file.name.endsWith(".html") @@ -204,9 +204,18 @@ class SitePagesCreator(cxt: DokkaContext) : BaseStaticSiteProcessor(cxt) { null } - private fun parseMarkdown(page: PreResolvedPage, dri: Set, allDirs: Map): ContentNode { + private fun parseMarkdown(page: PreResolvedPage, dri: Set, allDRIs: Map): ContentNode { val nodes = if (page.hasMarkdown) { - val parser = ExtendableMarkdownParser(page.code, allDirs::get) + val parser = ExtendableMarkdownParser(page.code) { link -> + val driKey = if (link.startsWith("/")) { + // handle root related links + link.replace('/', '.').removePrefix(".") + } else { + // todo handle relative links + link + } + allDRIs[driKey] + } val docTag = try { parser.parse()