diff --git a/docs/website/docs/api/.gitignore b/docs/website/docs/api/.gitignore deleted file mode 100644 index 72e8ffc..0000000 --- a/docs/website/docs/api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt b/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt index 20757bb..235988a 100644 --- a/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt +++ b/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt @@ -113,9 +113,6 @@ abstract class DokkaMkDocsPlugin : DokkaFormatPlugin(formatName = "mkdocs") { outputs.file(mkdocsYaml) doLast { - val startMarker = "# !!! EMBEDDED DOKKA START, DO NOT COMMIT !!! #" - val endMarker = "# !!! EMBEDDED DOKKA END, DO NOT COMMIT !!! #" - val lines = mkdocsYaml.asFile.readLines() val start = lines.takeWhile { it != startMarker } val end = lines.takeLastWhile { it != endMarker } @@ -127,12 +124,38 @@ abstract class DokkaMkDocsPlugin : DokkaFormatPlugin(formatName = "mkdocs") { } } + val removeMkDocsNavigation by target.tasks.registering { + group = "dokkatoo" + description = "Removes all the generated files to the index of the MkDocs site" + + inputs.file(mkdocsYaml) + outputs.file(mkdocsYaml) + + doLast { + val lines = mkdocsYaml.asFile.readLines() + val start = lines.takeWhile { it != startMarker } + val end = lines.takeLastWhile { it != endMarker } + + val output = start + startMarker + endMarker + end + mkdocsYaml.asFile.writeText(output.joinToString(System.lineSeparator()) + System.lineSeparator()) + } + } + val embedDokkaIntoMkDocs by target.tasks.registering { group = "dokkatoo" description = "Lifecycle task to embed configured Dokkatoo modules into a Material for MkDocs website" dependsOn(dokkaCopyIntoMkDocs, embedMkDocsNavigation) } + + target.tasks.named("clean") { + dependsOn("cleanDokkaCopyIntoMkDocs", removeMkDocsNavigation) + } + } + + companion object { + private const val startMarker = "# !!! EMBEDDED DOKKA START, DO NOT COMMIT !!! #" + private const val endMarker = "# !!! EMBEDDED DOKKA END, DO NOT COMMIT !!! #" } } -- 2.51.2 From d8980762c73854c7e583b9ba8575aa5ff5f76380 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20=E2=80=9CCLOVIS=E2=80=9D=20Canet?= Date: Sat, 3 May 2025 13:08:56 +0200 Subject: [PATCH 2/2] feat(dokka-mkdocs): Generate a .gitignore file in the generated documentation directory --- dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt b/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt index 235988a..835497f 100644 --- a/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt +++ b/dokka-mkdocs/src/main/kotlin/DokkaMkDocsPlugin.kt @@ -44,6 +44,11 @@ abstract class DokkaMkDocsPlugin : DokkaFormatPlugin(formatName = "mkdocs") { exclude("includes/*") + val gitignore = File(siteOutput.asFile, ".gitignore") + doLast { + gitignore.writeText("*") + } + includeEmptyDirs = true duplicatesStrategy = DuplicatesStrategy.WARN // TODO make each module generate files in its own directory, afterwards remove this }