aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-02-02 21:41:03 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2018-02-02 21:41:03 +0300
commit9805daba82a223d43bbc2aa2548d76ae01f23266 (patch)
tree57aba71b51afa25b074a401d47c6b46d70e112a1 /core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
parent4d0496a1ddca7e62f40737fffa1d2f94c85d197c (diff)
downloaddokka-9805daba82a223d43bbc2aa2548d76ae01f23266.tar.gz
Refactor sections, add missing testData for sections
Diffstat (limited to 'core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt')
-rw-r--r--core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt89
1 files changed, 54 insertions, 35 deletions
diff --git a/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt b/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
index ba662831f..0878f52cf 100644
--- a/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
+++ b/core/src/main/kotlin/Formats/JavaLayoutHtml/JavaLayoutHtmlFormatOutputBuilder.kt
@@ -614,6 +614,59 @@ open class JavaLayoutHtmlFormatOutputBuilder(
}
}
+ protected open fun FlowContent.seeAlsoSection(links: List<List<ContentNode>>) {
+ p { b { +"See Also" } }
+ ul {
+ links.forEach { linkParts ->
+ li { code { metaMarkup(linkParts) } }
+ }
+ }
+ }
+
+ protected open fun FlowContent.regularSection(name: String, entries: List<ContentSection>) {
+ table {
+ thead {
+ tr {
+ th {
+ colSpan = "2"
+ +name
+ }
+ }
+ }
+ tbody {
+ entries.forEach {
+ tr {
+ if (it.subjectName != null) {
+ td { +it.subjectName }
+ }
+ td {
+ metaMarkup(it.children)
+ }
+ }
+ }
+ }
+ }
+ }
+
+ protected open fun FlowContent.section(name: String, sectionParts: List<ContentSection>) {
+ when(name) {
+ ContentTags.SeeAlso -> seeAlsoSection(sectionParts.map { it.children.flatMap { (it as ContentParagraph).children } })
+ else -> regularSection(name, sectionParts)
+ }
+ }
+
+ protected open fun FlowContent.sections(content: Content) {
+ val sectionsByTag = content.sections.groupByTo(mutableMapOf()) { it.tag }
+
+ val seeAlso = sectionsByTag.remove(ContentTags.SeeAlso)
+
+ for ((name, entries) in sectionsByTag) {
+ section(name, entries)
+ }
+
+ seeAlso?.let { section(ContentTags.SeeAlso, it) }
+ }
+
protected open fun FlowContent.fullMemberDocs(node: DocumentationNode) {
div {
id = node.signatureForAnchor(logger)
@@ -627,41 +680,7 @@ open class JavaLayoutHtmlFormatOutputBuilder(
}
}
- val sectionsByTag = node.content.sections.groupByTo(mutableMapOf()) { it.tag }
-
- sectionsByTag.remove(ContentTags.SeeAlso)?.let { subjects ->
- p { b { +"See Also" } }
- ul {
- subjects.forEach {
- li { code { metaMarkup(it.children.flatMap { (it as ContentParagraph).children }) } }
- }
- }
- }
-
- for ((name, sections) in sectionsByTag) {
- table {
- thead {
- tr {
- th {
- colSpan = "2"
- +name
- }
- }
- }
- tbody {
- sections.forEach {
- tr {
- if (it.subjectName != null) {
- td { +it.subjectName }
- }
- td {
- metaMarkup(it.children)
- }
- }
- }
- }
- }
- }
+ sections(node.content)
}
}