diff options
-rw-r--r-- | .idea/runConfigurations/Dokka.xml | 2 | ||||
-rw-r--r-- | src/Formats/JekyllFormatService.kt | 7 | ||||
-rw-r--r-- | src/Formats/KotlinWebsiteFormatService.kt | 5 | ||||
-rw-r--r-- | src/main.kt | 20 |
4 files changed, 28 insertions, 6 deletions
diff --git a/.idea/runConfigurations/Dokka.xml b/.idea/runConfigurations/Dokka.xml index 5b2c5a2b..bca49a60 100644 --- a/.idea/runConfigurations/Dokka.xml +++ b/.idea/runConfigurations/Dokka.xml @@ -3,7 +3,7 @@ <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="org.jetbrains.dokka.DokkaPackage" /> <option name="VM_PARAMETERS" value="" /> - <option name="PROGRAM_PARAMETERS" value="src/ -output doc -module dokka -classpath "$KOTLIN_BUNDLED$/lib/kotlin-compiler.jar:$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar"" /> + <option name="PROGRAM_PARAMETERS" value="src/ -output doc -module dokka -format kotlin-website -classpath "$KOTLIN_BUNDLED$/lib/kotlin-compiler.jar:$KOTLIN_BUNDLED$/lib/kotlin-runtime.jar"" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="false" /> <option name="ALTERNATIVE_JRE_PATH" /> diff --git a/src/Formats/JekyllFormatService.kt b/src/Formats/JekyllFormatService.kt index 5179b37d..93861113 100644 --- a/src/Formats/JekyllFormatService.kt +++ b/src/Formats/JekyllFormatService.kt @@ -8,10 +8,13 @@ public open class JekyllFormatService(locationService: LocationService, override fun appendNodes(location: Location, to: StringBuilder, nodes: Iterable<DocumentationNode>) { to.appendln("---") - to.appendln("layout: api") - to.appendln("title: ${nodes.first().name}") + appendFrontMatter(nodes, to) to.appendln("---") to.appendln("") super<MarkdownFormatService>.appendNodes(location, to, nodes) } + + protected open fun appendFrontMatter(nodes: Iterable<DocumentationNode>, to: StringBuilder) { + to.appendln("title: ${nodes.first().name}") + } }
\ No newline at end of file diff --git a/src/Formats/KotlinWebsiteFormatService.kt b/src/Formats/KotlinWebsiteFormatService.kt index e694e222..4f7a013a 100644 --- a/src/Formats/KotlinWebsiteFormatService.kt +++ b/src/Formats/KotlinWebsiteFormatService.kt @@ -5,6 +5,11 @@ public class KotlinWebsiteFormatService(locationService: LocationService, : JekyllFormatService(locationService, signatureGenerator) { override val extension: String = "md" + override fun appendFrontMatter(nodes: Iterable<DocumentationNode>, to: StringBuilder) { + super.appendFrontMatter(nodes, to) + to.appendln("layout: api") + } + override public fun formatBreadcrumbs(items: Iterable<FormatLink>): String { items.drop(1) diff --git a/src/main.kt b/src/main.kt index 4e627376..0c853bc7 100644 --- a/src/main.kt +++ b/src/main.kt @@ -22,10 +22,14 @@ class DokkaArguments { ValueDescription("<path>") public var samples: String = "" - Argument(value = "output", description = "Output directory path for .md files") + Argument(value = "output", description = "Output directory path") ValueDescription("<path>") public var outputDir: String = "out/doc/" + Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)") + ValueDescription("<name>") + public var outputFormat: String = "html" + Argument(value = "module", description = "Name of the documentation module") ValueDescription("<name>") public var moduleName: String = "" @@ -118,8 +122,18 @@ public fun main(args: Array<String>) { val locationService = FoldersLocationService(arguments.outputDir) val templateService = HtmlTemplateService.default("/dokka/styles/style.css") -// val formatter = HtmlFormatService(locationService, signatureGenerator, templateService) - val formatter = KotlinWebsiteFormatService(locationService, signatureGenerator) + val formatter = when (arguments.outputFormat) { + "text" -> TextFormatService(signatureGenerator) + "html" -> HtmlFormatService(locationService, signatureGenerator, templateService) + "markdown" -> MarkdownFormatService(locationService, signatureGenerator) + "jekyll" -> JekyllFormatService(locationService, signatureGenerator) + "kotlin-website" -> KotlinWebsiteFormatService(locationService, signatureGenerator) + else -> { + print("Unrecognized output format ${arguments.outputFormat}") + return + } + } + val generator = FileGenerator(signatureGenerator, locationService, formatter) print("Generating pages... ") generator.buildPage(documentation) |