From 8f3802672c6a07e9f5f949ef0b5482383b467cb6 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 29 Dec 2014 15:32:15 +0100 Subject: layout: api is specific to Kotlin web site, don't generate it in regular Jekyll output --- src/Formats/JekyllFormatService.kt | 7 +++++-- src/Formats/KotlinWebsiteFormatService.kt | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) 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) { to.appendln("---") - to.appendln("layout: api") - to.appendln("title: ${nodes.first().name}") + appendFrontMatter(nodes, to) to.appendln("---") to.appendln("") super.appendNodes(location, to, nodes) } + + protected open fun appendFrontMatter(nodes: Iterable, 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, to: StringBuilder) { + super.appendFrontMatter(nodes, to) + to.appendln("layout: api") + } + override public fun formatBreadcrumbs(items: Iterable): String { items.drop(1) -- cgit From 2dbd849c7c603a25607bcc66025138dee3c30458 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 29 Dec 2014 15:40:21 +0100 Subject: add command line argument for specifying output format --- src/main.kt | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main.kt b/src/main.kt index 4e627376..bc7cefd7 100644 --- a/src/main.kt +++ b/src/main.kt @@ -22,10 +22,14 @@ class DokkaArguments { ValueDescription("") public var samples: String = "" - Argument(value = "output", description = "Output directory path for .md files") + Argument(value = "output", description = "Output directory path") ValueDescription("") public var outputDir: String = "out/doc/" + Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)") + ValueDescription("") + public var outputFormat: String = "html" + Argument(value = "module", description = "Name of the documentation module") ValueDescription("") public var moduleName: String = "" @@ -118,8 +122,19 @@ public fun main(args: Array) { 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 -> null + } + if (formatter == null) { + print("Unrecognized output format ${arguments.outputFormat}") + return + } + val generator = FileGenerator(signatureGenerator, locationService, formatter) print("Generating pages... ") generator.buildPage(documentation) -- cgit From 0b8e04af82a80ccce4460a78b614d6bc2483efae Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 29 Dec 2014 16:06:45 +0100 Subject: cleanup --- src/main.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main.kt b/src/main.kt index bc7cefd7..0c853bc7 100644 --- a/src/main.kt +++ b/src/main.kt @@ -128,11 +128,10 @@ public fun main(args: Array) { "markdown" -> MarkdownFormatService(locationService, signatureGenerator) "jekyll" -> JekyllFormatService(locationService, signatureGenerator) "kotlin-website" -> KotlinWebsiteFormatService(locationService, signatureGenerator) - else -> null - } - if (formatter == null) { - print("Unrecognized output format ${arguments.outputFormat}") - return + else -> { + print("Unrecognized output format ${arguments.outputFormat}") + return + } } val generator = FileGenerator(signatureGenerator, locationService, formatter) -- cgit From be20c3f5bc21ab5604b31b2af419b9076a743d74 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Mon, 29 Dec 2014 20:51:32 +0100 Subject: add -format argument --- .idea/runConfigurations/Dokka.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 @@