From ff8948350406b085ca7feeb5d8aabd74b9eadf83 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Sat, 2 Dec 2017 05:21:10 +0300 Subject: Fix outline file names, fix incorrect placement of support files --- core/src/main/kotlin/Generation/FileGenerator.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'core/src') diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt index 9c7c65e6..ea34a269 100644 --- a/core/src/main/kotlin/Generation/FileGenerator.kt +++ b/core/src/main/kotlin/Generation/FileGenerator.kt @@ -17,11 +17,14 @@ class FileGenerator @Inject constructor(@Named("outputDir") val rootFile: File) override val root: File = rootFile override fun location(node: DocumentationNode): FileLocation { - return FileLocation(File(rootFile, relativePathToNode(node.path.map { it.name }, node.members.any())).appendExtension(formatService.extension)) + return locationWithoutExtension(node).let { it.copy(file = it.file.appendExtension(formatService.linkExtension)) } + } + + fun locationWithoutExtension(node: DocumentationNode): FileLocation { + return FileLocation(File(rootFile, relativePathToNode(node.path.map { it.name }, node.members.any()))) } override fun buildPages(nodes: Iterable) { - //val specificLocationService = locationService.withExtension(formatService.extension) for ((location, items) in nodes.groupBy { location(it) }) { val file = location.file @@ -41,7 +44,7 @@ class FileGenerator @Inject constructor(@Named("outputDir") val rootFile: File) override fun buildOutlines(nodes: Iterable) { val outlineService = this.outlineService ?: return - for ((location, items) in nodes.groupBy { location(it) }) { + for ((location, items) in nodes.groupBy { locationWithoutExtension(it) }) { val file = outlineService.getOutlineFileName(location) file.parentFile?.mkdirsOrFail() FileOutputStream(file).use { @@ -54,7 +57,7 @@ class FileGenerator @Inject constructor(@Named("outputDir") val rootFile: File) override fun buildSupportFiles() { formatService.enumerateSupportFiles { resource, targetPath -> - FileOutputStream(relativePathToNode(listOf(targetPath), false)).use { + FileOutputStream(File(root, relativePathToNode(listOf(targetPath), false))).use { javaClass.getResourceAsStream(resource).copyTo(it) } } -- cgit