From 4a36cc6bd8fc3fe48ca3dd4dc69bd22cf58733e2 Mon Sep 17 00:00:00 2001 From: Krzysztof Romanowski Date: Wed, 9 Sep 2020 01:52:20 +0200 Subject: [PATCH] Update dokka to 1.4 Change the way how we render pages, so we parse .md files and then apply html layouts. Do no render files other then .md or .html ones --- .gitignore | 1 + build.gradle.kts | 7 +- documentation/_layouts/vl_html_layout.html | 7 + documentation/docs/static-page/links.md | 12 + .../static-page/{random.html => random.md} | 2 +- .../docs/static-page/samples/html_template.md | 6 + .../docs/static-page/samples/index.md | 6 + .../static-page/samples/no_md_nor_html.txt | 1 + .../plainFramelessHtmlIndex/index.html | 4 + .../samples/plainHtmlIndexFile/index.html | 1 + .../samples/plainIndexFile/index.md | 1 + .../static-page/samples/plain_html_file.html | 1 + .../docs/static-page/samples/plain_md_file.md | 1 + .../docs/static-page/samples/tables.md | 21 + documentation/index.md | 2 +- gradle.properties | 4 +- settings.gradle.kts | 1 + .../virtuslab/dokka/site/StaticSitePlugin.kt | 2 +- .../com/virtuslab/dokka/site/contentNodes.kt | 26 ++ .../virtuslab/dokka/site/locationProvider.kt | 15 +- .../kotlin/com/virtuslab/dokka/site/parser.kt | 359 ++++++++++++++++++ .../com/virtuslab/dokka/site/processors.kt | 258 ++++++------- .../com/virtuslab/dokka/site/renderer.kt | 135 ++++--- .../com/virtuslab/dokka/site/templates.kt | 90 +++-- src/test/kotlin/headerTests.kt | 73 +++- src/test/kotlin/parserTests.kt | 58 +++ 26 files changed, 856 insertions(+), 238 deletions(-) create mode 100644 documentation/_layouts/vl_html_layout.html create mode 100644 documentation/docs/static-page/links.md rename documentation/docs/static-page/{random.html => random.md} (62%) create mode 100644 documentation/docs/static-page/samples/html_template.md create mode 100644 documentation/docs/static-page/samples/index.md create mode 100644 documentation/docs/static-page/samples/no_md_nor_html.txt create mode 100644 documentation/docs/static-page/samples/plainFramelessHtmlIndex/index.html create mode 100644 documentation/docs/static-page/samples/plainHtmlIndexFile/index.html create mode 100644 documentation/docs/static-page/samples/plainIndexFile/index.md create mode 100644 documentation/docs/static-page/samples/plain_html_file.html create mode 100644 documentation/docs/static-page/samples/plain_md_file.md create mode 100644 documentation/docs/static-page/samples/tables.md create mode 100644 src/main/kotlin/com/virtuslab/dokka/site/contentNodes.kt create mode 100644 src/main/kotlin/com/virtuslab/dokka/site/parser.kt create mode 100644 src/test/kotlin/parserTests.kt diff --git a/.gitignore b/.gitignore index 79a9324..b1189f9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ build/ gradle/ lib/ +out diff --git a/build.gradle.kts b/build.gradle.kts index 61ec8d0..ce2e509 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "com.virtuslab.dokka" -version = "0.1.1" +version = "0.1.3-SNAPSHOT" tasks.withType(KotlinCompile::class).all { val language_version: String by project @@ -34,11 +34,12 @@ dependencies { implementation("org.jetbrains.dokka:dokka-base:$dokka_version") implementation("com.vladsch.flexmark:flexmark-all:0.42.12") implementation("nl.big-o:liqp:0.6.7") - implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.10") + implementation("org.jetbrains.kotlinx:kotlinx-html-jvm:0.7.2") implementation("junit:junit:4.13") dokkaHtmlPlugin(project(":")) + testImplementation("org.jetbrains.dokka:dokka-core:$dokka_version") } // Gradle metadata @@ -83,5 +84,5 @@ publishing { // Configure dokka tasks.dokkaHtml { - pluginsConfiguration += "ExternalDocsTooKey" to "documentation" + pluginsConfiguration.put("ExternalDocsTooKey", "documentation") } diff --git a/documentation/_layouts/vl_html_layout.html b/documentation/_layouts/vl_html_layout.html new file mode 100644 index 0000000..0750c7b --- /dev/null +++ b/documentation/_layouts/vl_html_layout.html @@ -0,0 +1,7 @@ +
+ Powered by VirtusLab +
+ +
+ {{ content }} +
diff --git a/documentation/docs/static-page/links.md b/documentation/docs/static-page/links.md new file mode 100644 index 0000000..f48706f --- /dev/null +++ b/documentation/docs/static-page/links.md @@ -0,0 +1,12 @@ +--- +layout: vl_header +title: Links +--- + +## Links + +Our side supports stadnard 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 API using `[fully.quallifty.Name]` diff --git a/documentation/docs/static-page/random.html b/documentation/docs/static-page/random.md similarity index 62% rename from documentation/docs/static-page/random.html rename to documentation/docs/static-page/random.md index fe04218..53ae26c 100644 --- a/documentation/docs/static-page/random.html +++ b/documentation/docs/static-page/random.md @@ -1,6 +1,6 @@ --- layout: vl_header -title: Sample html page +title: Sample md page --- Hello world! diff --git a/documentation/docs/static-page/samples/html_template.md b/documentation/docs/static-page/samples/html_template.md new file mode 100644 index 0000000..caebc52 --- /dev/null +++ b/documentation/docs/static-page/samples/html_template.md @@ -0,0 +1,6 @@ +--- +layout: vl_html_layout +title: Use Html template +--- + +## Test 123 diff --git a/documentation/docs/static-page/samples/index.md b/documentation/docs/static-page/samples/index.md new file mode 100644 index 0000000..e4eaa86 --- /dev/null +++ b/documentation/docs/static-page/samples/index.md @@ -0,0 +1,6 @@ +--- +layout: vl_header +title: Samples +--- + +Samples for our **plugin** diff --git a/documentation/docs/static-page/samples/no_md_nor_html.txt b/documentation/docs/static-page/samples/no_md_nor_html.txt new file mode 100644 index 0000000..f8e130c --- /dev/null +++ b/documentation/docs/static-page/samples/no_md_nor_html.txt @@ -0,0 +1 @@ +I am text file! diff --git a/documentation/docs/static-page/samples/plainFramelessHtmlIndex/index.html b/documentation/docs/static-page/samples/plainFramelessHtmlIndex/index.html new file mode 100644 index 0000000..0a097cc --- /dev/null +++ b/documentation/docs/static-page/samples/plainFramelessHtmlIndex/index.html @@ -0,0 +1,4 @@ +--- +hasFrame: false +--- +

No frame!

diff --git a/documentation/docs/static-page/samples/plainHtmlIndexFile/index.html b/documentation/docs/static-page/samples/plainHtmlIndexFile/index.html new file mode 100644 index 0000000..7f86bfe --- /dev/null +++ b/documentation/docs/static-page/samples/plainHtmlIndexFile/index.html @@ -0,0 +1 @@ +

Plain html file

diff --git a/documentation/docs/static-page/samples/plainIndexFile/index.md b/documentation/docs/static-page/samples/plainIndexFile/index.md new file mode 100644 index 0000000..8dafe72 --- /dev/null +++ b/documentation/docs/static-page/samples/plainIndexFile/index.md @@ -0,0 +1 @@ +## Plain file diff --git a/documentation/docs/static-page/samples/plain_html_file.html b/documentation/docs/static-page/samples/plain_html_file.html new file mode 100644 index 0000000..7cbf949 --- /dev/null +++ b/documentation/docs/static-page/samples/plain_html_file.html @@ -0,0 +1 @@ +

Plain Html file

diff --git a/documentation/docs/static-page/samples/plain_md_file.md b/documentation/docs/static-page/samples/plain_md_file.md new file mode 100644 index 0000000..5f509bb --- /dev/null +++ b/documentation/docs/static-page/samples/plain_md_file.md @@ -0,0 +1 @@ +# Plain Md file diff --git a/documentation/docs/static-page/samples/tables.md b/documentation/docs/static-page/samples/tables.md new file mode 100644 index 0000000..06e395a --- /dev/null +++ b/documentation/docs/static-page/samples/tables.md @@ -0,0 +1,21 @@ +--- +layout: vl_html_layout +title: Tables +--- + +## Tables + + +Some random table (to show how we render it). + +## SBT Commands Cheat Sheet ## +The basics of working with Dotty codebase are documented [here](https://dotty.epfl.ch/docs/contributing/getting-started.html) and [here](https://dotty.epfl.ch/docs/contributing/workflow.html). Below is a cheat sheet of some frequently used commands (to be used from SBT console – `sbt`). + + +| Command | Description | +| ---------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------- | +| `dotc ../issues/Playground.scala` | Compile the given file – path relative to the Dotty directory. Output the compiled class files to the Dotty directory itself. | +| `dotr Playground` | Run the compiled class `Playground`. Dotty directory is on classpath by default. | +| `repl` | Start REPL | +| `testOnly dotty.tools.dotc.CompilationTests -- *pos` | Run test (method) `pos` from `CompilationTests` suite. | +| `testCompilation sample` | In all test suites, run test files containing the word `sample` in their title. | diff --git a/documentation/index.md b/documentation/index.md index 2445cca..b5a4d39 100644 --- a/documentation/index.md +++ b/documentation/index.md @@ -8,7 +8,7 @@ layout: vl_header **Yes, this page was generated using dokka-site** -You can learn more from out [documentation](dokka-site/index.html). +You can learn more from our [documentation](dokka-site/index.html). ## Getting started diff --git a/gradle.properties b/gradle.properties index 8011222..42a1667 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ kotlin.code.style=official -kotlin_version=1.4-M3 -dokka_version=1.4.0-rc +kotlin_version=1.4.0 +dokka_version=1.4.0 language_version=1.4 diff --git a/settings.gradle.kts b/settings.gradle.kts index a43f0bc..6d524ac 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,5 +17,6 @@ pluginManagement { mavenCentral() jcenter() gradlePluginPortal() + mavenLocal() } } diff --git a/src/main/kotlin/com/virtuslab/dokka/site/StaticSitePlugin.kt b/src/main/kotlin/com/virtuslab/dokka/site/StaticSitePlugin.kt index 469977a..4f984db 100644 --- a/src/main/kotlin/com/virtuslab/dokka/site/StaticSitePlugin.kt +++ b/src/main/kotlin/com/virtuslab/dokka/site/StaticSitePlugin.kt @@ -27,7 +27,7 @@ class StaticSitePlugin : DokkaPlugin() { val customRenderer by extending { (CoreExtensions.renderer - providing { ctx -> ExternalDocsToolRenderer(ctx) } + providing { ctx -> RendererDispatcher(ctx) } override dokkaBase.htmlRenderer) } diff --git a/src/main/kotlin/com/virtuslab/dokka/site/contentNodes.kt b/src/main/kotlin/com/virtuslab/dokka/site/contentNodes.kt new file mode 100644 index 0000000..092eb68 --- /dev/null +++ b/src/main/kotlin/com/virtuslab/dokka/site/contentNodes.kt @@ -0,0 +1,26 @@ +package com.virtuslab.dokka.site + +import org.jetbrains.dokka.model.DisplaySourceSet +import org.jetbrains.dokka.model.properties.PropertyContainer +import org.jetbrains.dokka.pages.* + +data class PartiallyRenderedContent( + val page: PreResolvedPage, + override val children: List, + override val dci: DCI, + override val sourceSets: Set, + override val style: Set