Revert: Dokka platform changes needed to implement Devsite requirements.
diff --git a/core/src/main/kotlin/Formats/FormatDescriptor.kt b/core/src/main/kotlin/Formats/FormatDescriptor.kt
index e422aa1..fc925f4 100644
--- a/core/src/main/kotlin/Formats/FormatDescriptor.kt
+++ b/core/src/main/kotlin/Formats/FormatDescriptor.kt
@@ -12,5 +12,4 @@
val javaDocumentationBuilderClass: KClass<out JavaDocumentationBuilder>
val sampleProcessingService: KClass<out SampleProcessingService>
val packageListServiceClass: KClass<out PackageListService>?
- val extraOutlineServices: KClass<out ExtraOutlineServices>?
}
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt
index ce9acb2..b667243 100644
--- a/core/src/main/kotlin/Formats/HtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt
@@ -105,8 +105,6 @@
callback("/dokka/styles/style.css", "style.css")
}
- override fun getOutlineFileName(): String = "index"
-
override fun createOutputBuilder(to: StringBuilder, location: Location) =
HtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms, templateService)
@@ -116,7 +114,7 @@
templateService.appendFooter(to)
}
- override fun getOutlineFile(location: Location): File {
+ override fun getOutlineFileName(location: Location): File {
return File("${location.path}-outline.html")
}
@@ -135,7 +133,7 @@
}
}
-fun LocationService.calcPathToRoot(location: Location): Path {
+private fun LocationService.calcPathToRoot(location: Location): Path {
val path = Paths.get(location.path)
return path.parent?.relativize(Paths.get(root.path + '/')) ?: path
}
diff --git a/core/src/main/kotlin/Formats/OutlineService.kt b/core/src/main/kotlin/Formats/OutlineService.kt
index 42151ff..3c31ba5 100644
--- a/core/src/main/kotlin/Formats/OutlineService.kt
+++ b/core/src/main/kotlin/Formats/OutlineService.kt
@@ -6,8 +6,8 @@
* Service for building the outline of the package contents.
*/
interface OutlineFormatService {
- fun getOutlineFile(location: Location): File
- fun getOutlineFileName(): String
+ fun getOutlineFileName(location: Location): File
+
fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder)
fun appendOutlineLevel(to: StringBuilder, body: () -> Unit)
diff --git a/core/src/main/kotlin/Formats/StandardFormats.kt b/core/src/main/kotlin/Formats/StandardFormats.kt
index 9eebaa9..d484263 100644
--- a/core/src/main/kotlin/Formats/StandardFormats.kt
+++ b/core/src/main/kotlin/Formats/StandardFormats.kt
@@ -10,11 +10,10 @@
override val packageDocumentationBuilderClass = KotlinPackageDocumentationBuilder::class
override val javaDocumentationBuilderClass = KotlinJavaDocumentationBuilder::class
- override val generatorServiceClass: KClass<out Generator> = FileGenerator::class
+ override val generatorServiceClass = FileGenerator::class
override val outlineServiceClass: KClass<out OutlineFormatService>? = null
override val sampleProcessingService: KClass<out SampleProcessingService> = DefaultSampleProcessingService::class
override val packageListServiceClass: KClass<out PackageListService>? = DefaultPackageListService::class
- override val extraOutlineServices: KClass<out ExtraOutlineServices>? = null
}
class HtmlFormatDescriptor : KotlinFormatDescriptorBase() {
@@ -30,7 +29,6 @@
override val javaDocumentationBuilderClass = JavaPsiDocumentationBuilder::class
override val sampleProcessingService: KClass<out SampleProcessingService> = DefaultSampleProcessingService::class
override val packageListServiceClass: KClass<out PackageListService>? = DefaultPackageListService::class
- override val extraOutlineServices: KClass<out ExtraOutlineServices>? = null
}
class KotlinWebsiteFormatDescriptor : KotlinFormatDescriptorBase() {
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index 63f51f9..a8b000b 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -286,7 +286,7 @@
singleNode.appendPlatforms()
appendContent(singleNode.content)
} else {
- val breakdownByName = nodes.groupBy { node -> getNameForHeader(node) }
+ val breakdownByName = nodes.groupBy { node -> node.name }
for ((name, items) in breakdownByName) {
if (!noHeader)
appendHeader { appendText(name) }
@@ -295,11 +295,7 @@
}
}
- open fun getNameForHeader(node: DocumentationNode): String {
- return node.name
- }
-
- fun appendDocumentation(overloads: Iterable<DocumentationNode>, isSingleNode: Boolean) {
+ private fun appendDocumentation(overloads: Iterable<DocumentationNode>, isSingleNode: Boolean) {
val breakdownBySummary = overloads.groupByTo(LinkedHashMap()) { node -> node.content }
if (breakdownBySummary.size == 1) {
@@ -315,7 +311,7 @@
}
}
- fun formatOverloadGroup(items: List<DocumentationNode>, isSingleNode: Boolean = false) {
+ private fun formatOverloadGroup(items: List<DocumentationNode>, isSingleNode: Boolean = false) {
for ((index, item) in items.withIndex()) {
if (index > 0) appendLine()
val rendered = languageService.render(item)
@@ -381,7 +377,7 @@
}
}
- fun DocumentationNode.appendPlatforms() {
+ private fun DocumentationNode.appendPlatforms() {
val platforms = if (isModuleOrPackage())
platformsToShow.toSet() + platformsOfItems(members)
else
@@ -441,7 +437,7 @@
}
}
- open inner class GroupNodePageBuilder(val node: DocumentationNode) : PageBuilder(listOf(node)) {
+ inner class GroupNodePageBuilder(val node: DocumentationNode) : PageBuilder(listOf(node)) {
override fun build() {
val breakdownByLocation = node.path.filterNot { it.name.isEmpty() }.map { link(node, it) }
@@ -471,7 +467,7 @@
}
}
- open inner class SingleNodePageBuilder(val node: DocumentationNode, noHeader: Boolean = false)
+ inner class SingleNodePageBuilder(val node: DocumentationNode, noHeader: Boolean = false)
: PageBuilder(listOf(node), noHeader) {
override fun build() {
@@ -616,7 +612,7 @@
}
}
- open inner class AllTypesNodeBuilder(val node: DocumentationNode)
+ inner class AllTypesNodeBuilder(val node: DocumentationNode)
: PageBuilder(listOf(node)) {
override fun build() {
diff --git a/core/src/main/kotlin/Formats/YamlOutlineService.kt b/core/src/main/kotlin/Formats/YamlOutlineService.kt
index 39a5b9b..7968824 100644
--- a/core/src/main/kotlin/Formats/YamlOutlineService.kt
+++ b/core/src/main/kotlin/Formats/YamlOutlineService.kt
@@ -5,7 +5,7 @@
class YamlOutlineService @Inject constructor(val locationService: LocationService,
val languageService: LanguageService) : OutlineFormatService {
- override fun getOutlineFile(location: Location): File = File("${location.path}.yml")
+ override fun getOutlineFileName(location: Location): File = File("${location.path}.yml")
var outlineLevel = 0
override fun appendOutlineHeader(location: Location, node: DocumentationNode, to: StringBuilder) {
@@ -21,6 +21,4 @@
body()
outlineLevel--
}
-
- override fun getOutlineFileName(): String = "index"
}
diff --git a/core/src/main/kotlin/Generation/FileGenerator.kt b/core/src/main/kotlin/Generation/FileGenerator.kt
index f994861..e055c53 100644
--- a/core/src/main/kotlin/Generation/FileGenerator.kt
+++ b/core/src/main/kotlin/Generation/FileGenerator.kt
@@ -6,13 +6,12 @@
import java.io.IOException
import java.io.OutputStreamWriter
-open class FileGenerator @Inject constructor(val locationService: FileLocationService) : Generator {
+class FileGenerator @Inject constructor(val locationService: FileLocationService) : Generator {
@set:Inject(optional = true) var outlineService: OutlineFormatService? = null
@set:Inject(optional = true) lateinit var formatService: FormatService
@set:Inject(optional = true) lateinit var options: DocumentationOptions
@set:Inject(optional = true) var packageListService: PackageListService? = null
- @set:Inject(optional = true) var extraOutlineServices: ExtraOutlineServices? = null
override fun buildPages(nodes: Iterable<DocumentationNode>) {
val specificLocationService = locationService.withExtension(formatService.extension)
@@ -35,10 +34,8 @@
override fun buildOutlines(nodes: Iterable<DocumentationNode>) {
val outlineService = this.outlineService ?: return
- for ((location, items) in nodes.groupBy {
- locationService.location(it, outlineService.getOutlineFileName())
- }) {
- val file = outlineService.getOutlineFile(location)
+ for ((location, items) in nodes.groupBy { locationService.location(it) }) {
+ val file = outlineService.getOutlineFileName(location)
file.parentFile?.mkdirsOrFail()
FileOutputStream(file).use {
OutputStreamWriter(it, Charsets.UTF_8).use {
@@ -48,21 +45,6 @@
}
}
- override fun buildExtraOutlines(nodes: Iterable<DocumentationNode>) {
- val extraOutlinesServices = this.extraOutlineServices ?: return
- if (extraOutlinesServices.services.isEmpty()) return
- val rootNode = nodes.first()
- for (service in extraOutlinesServices.services) {
- val file = service.getFile(locationService.location(rootNode, service.getFileName()))
- file.parentFile?.mkdirsOrFail()
- FileOutputStream(file).use {
- OutputStreamWriter(it, Charsets.UTF_8).use {
- it.write(service.format(rootNode))
- }
- }
- }
- }
-
override fun buildSupportFiles() {
formatService.enumerateSupportFiles { resource, targetPath ->
FileOutputStream(locationService.location(listOf(targetPath), false).file).use {
diff --git a/core/src/main/kotlin/Generation/Generator.kt b/core/src/main/kotlin/Generation/Generator.kt
index 53745e4..76a5f35 100644
--- a/core/src/main/kotlin/Generation/Generator.kt
+++ b/core/src/main/kotlin/Generation/Generator.kt
@@ -5,7 +5,6 @@
fun buildOutlines(nodes: Iterable<DocumentationNode>)
fun buildSupportFiles()
fun buildPackageList(nodes: Iterable<DocumentationNode>)
- fun buildExtraOutlines(nodes: Iterable<DocumentationNode>)
}
fun Generator.buildAll(nodes: Iterable<DocumentationNode>) {
@@ -13,7 +12,6 @@
buildOutlines(nodes)
buildSupportFiles()
buildPackageList(nodes)
- buildExtraOutlines(nodes)
}
fun Generator.buildPage(node: DocumentationNode): Unit = buildPages(listOf(node))
diff --git a/core/src/main/kotlin/Locations/FoldersLocationService.kt b/core/src/main/kotlin/Locations/FoldersLocationService.kt
index a2af03b..83e1cf6 100644
--- a/core/src/main/kotlin/Locations/FoldersLocationService.kt
+++ b/core/src/main/kotlin/Locations/FoldersLocationService.kt
@@ -14,18 +14,17 @@
return if (extension.isEmpty()) FoldersLocationService(rootFile, newExtension) else this
}
- override fun location(qualifiedName: List<String>, hasMembers: Boolean, fileName: String): FileLocation {
- return FileLocation(File(rootFile, relativePathToNode(qualifiedName, hasMembers, fileName))
- .appendExtension(extension))
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation {
+ return FileLocation(File(rootFile, relativePathToNode(qualifiedName, hasMembers)).appendExtension(extension))
}
}
-fun relativePathToNode(qualifiedName: List<String>, hasMembers: Boolean, fileName: String): String {
+fun relativePathToNode(qualifiedName: List<String>, hasMembers: Boolean): String {
val parts = qualifiedName.map { identifierToFilename(it) }.filterNot { it.isEmpty() }
return if (!hasMembers) {
// leaf node, use file in owner's folder
parts.joinToString("/")
} else {
- parts.joinToString("/") + (if (parts.none()) "" else "/") + fileName
+ parts.joinToString("/") + (if (parts.none()) "" else "/") + "index"
}
}
diff --git a/core/src/main/kotlin/Locations/LocationService.kt b/core/src/main/kotlin/Locations/LocationService.kt
index e2e9f0a..39f5942 100644
--- a/core/src/main/kotlin/Locations/LocationService.kt
+++ b/core/src/main/kotlin/Locations/LocationService.kt
@@ -44,15 +44,13 @@
interface LocationService {
fun withExtension(newExtension: String) = this
- fun location(node: DocumentationNode, fileName: String = "index"): Location =
- location(node.path.map { it.name }, node.members.any(), fileName)
+ fun location(node: DocumentationNode): Location = location(node.path.map { it.name }, node.members.any())
/**
* Calculates a location corresponding to the specified [qualifiedName].
* @param hasMembers if true, the node for which the location is calculated has member nodes.
*/
- fun location(qualifiedName: List<String>, hasMembers: Boolean,
- fileName: String = "index"): Location
+ fun location(qualifiedName: List<String>, hasMembers: Boolean): Location
val root: Location
}
@@ -61,9 +59,8 @@
interface FileLocationService: LocationService {
override fun withExtension(newExtension: String): FileLocationService = this
- override fun location(node: DocumentationNode, fileName: String): FileLocation =
- location(node.path.map { it.name }, node.members.any(), fileName)
- override fun location(qualifiedName: List<String>, hasMembers: Boolean, fileName: String): FileLocation
+ override fun location(node: DocumentationNode): FileLocation = location(node.path.map { it.name }, node.members.any())
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation
}
diff --git a/core/src/main/kotlin/Locations/SingleFolderLocationService.kt b/core/src/main/kotlin/Locations/SingleFolderLocationService.kt
index 456fd6c..1b4fdc2 100644
--- a/core/src/main/kotlin/Locations/SingleFolderLocationService.kt
+++ b/core/src/main/kotlin/Locations/SingleFolderLocationService.kt
@@ -10,7 +10,7 @@
override fun withExtension(newExtension: String): FileLocationService =
SingleFolderLocationService(rootFile, newExtension)
- override fun location(qualifiedName: List<String>, hasMembers: Boolean, fileName: String): FileLocation {
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean): FileLocation {
val filename = qualifiedName.map { identifierToFilename(it) }.joinToString("-")
return FileLocation(File(rootFile, filename).appendExtension(extension))
}
diff --git a/core/src/main/kotlin/Utilities/DokkaModules.kt b/core/src/main/kotlin/Utilities/DokkaModules.kt
index 0d3ac58..28c5dc4 100644
--- a/core/src/main/kotlin/Utilities/DokkaModules.kt
+++ b/core/src/main/kotlin/Utilities/DokkaModules.kt
@@ -76,9 +76,7 @@
descriptor.formatServiceClass?.let { clazz ->
binder.bind(FormatService::class.java).to(clazz.java)
}
- descriptor.extraOutlineServices?.let { clazz ->
- binder.bind(ExtraOutlineServices::class.java).to(clazz.java)
- }
+
binder.bind<Generator>().to(descriptor.generatorServiceClass.java)
descriptor.packageListServiceClass?.let { binder.bind<PackageListService>().to(it.java) }
diff --git a/core/src/main/kotlin/javadoc/dokka-adapters.kt b/core/src/main/kotlin/javadoc/dokka-adapters.kt
index 2de7b52..9555aeb 100644
--- a/core/src/main/kotlin/javadoc/dokka-adapters.kt
+++ b/core/src/main/kotlin/javadoc/dokka-adapters.kt
@@ -26,9 +26,6 @@
override fun buildPackageList(nodes: Iterable<DocumentationNode>) {
// handled by javadoc itself
}
-
- override fun buildExtraOutlines(nodes: Iterable<DocumentationNode>) {
- }
}
class JavadocFormatDescriptor : FormatDescriptor {
@@ -39,5 +36,4 @@
override val javaDocumentationBuilderClass = JavaPsiDocumentationBuilder::class
override val sampleProcessingService = DefaultSampleProcessingService::class
override val packageListServiceClass: KClass<out PackageListService>? = null
- override val extraOutlineServices: KClass<out ExtraOutlineServices>? = null
}
diff --git a/core/src/test/kotlin/TestAPI.kt b/core/src/test/kotlin/TestAPI.kt
index d6b1a90..4799cd9 100644
--- a/core/src/test/kotlin/TestAPI.kt
+++ b/core/src/test/kotlin/TestAPI.kt
@@ -253,8 +253,8 @@
}
object InMemoryLocationService: LocationService {
- override fun location(qualifiedName: List<String>, hasMembers: Boolean, fileName: String) =
- InMemoryLocation(relativePathToNode(qualifiedName, hasMembers, fileName))
+ override fun location(qualifiedName: List<String>, hasMembers: Boolean) =
+ InMemoryLocation(relativePathToNode(qualifiedName, hasMembers))
override val root: Location
get() = InMemoryLocation("")