aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Formats/HtmlFormatService.kt6
-rw-r--r--core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt30
-rw-r--r--core/src/main/kotlin/Formats/StructuredFormatService.kt32
-rw-r--r--core/testdata/format/overloadsWithDescription.html3
-rw-r--r--core/testdata/format/overloadsWithDifferentDescriptions.html9
-rw-r--r--core/testdata/format/parameterAnchor.html3
6 files changed, 37 insertions, 46 deletions
diff --git a/core/src/main/kotlin/Formats/HtmlFormatService.kt b/core/src/main/kotlin/Formats/HtmlFormatService.kt
index 6819e652..12d39af3 100644
--- a/core/src/main/kotlin/Formats/HtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/HtmlFormatService.kt
@@ -46,6 +46,8 @@ open class HtmlOutputBuilder(to: StringBuilder,
override fun appendParagraph(body: () -> Unit) =
wrapInTag("p", body, newlineBeforeOpen = true, newlineAfterClose = true)
+ override fun appendSoftParagraph(body: () -> Unit) = appendParagraph(body)
+
override fun appendLine() {
to.appendln("<br/>")
}
@@ -89,9 +91,7 @@ open class HtmlOutputBuilder(to: StringBuilder,
}
override fun ensureParagraph() {
- if (!to.endsWith("<p>") && !to.endsWith("</p>")) {
- to.append("\n<p>")
- }
+
}
}
diff --git a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
index d2962911..7b9279b2 100644
--- a/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
+++ b/core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
@@ -7,14 +7,10 @@ import org.jetbrains.kotlin.utils.addToStdlib.ifNotEmpty
import java.nio.file.Path
-private object EmptyHtmlTemplateServie : HtmlTemplateService {
- override fun appendFooter(to: StringBuilder) {
+private object EmptyHtmlTemplateService : HtmlTemplateService {
+ override fun appendFooter(to: StringBuilder) {}
- }
-
- override fun appendHeader(to: StringBuilder, title: String?, basePath: Path) {
-
- }
+ override fun appendHeader(to: StringBuilder, title: String?, basePath: Path) {}
}
@@ -24,13 +20,11 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,
languageService: LanguageService,
extension: String,
impliedPlatforms: List<String>)
- : HtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms, EmptyHtmlTemplateServie) {
+ : HtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms, EmptyHtmlTemplateService) {
private var needHardLineBreaks = false
private var insideDiv = 0
- override fun appendLine() {
-
- }
+ override fun appendLine() {}
override fun appendBreadcrumbs(path: Iterable<FormatLink>) {
if (path.count() > 1) {
@@ -42,8 +36,6 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,
override fun appendCode(body: () -> Unit) = wrapIfNotEmpty("<code>", "</code>", body)
- override fun appendStrikethrough(body: () -> Unit) = wrapInTag("s", body)
-
protected fun div(to: StringBuilder, cssClass: String, otherAttributes: String = "", block: () -> Unit) {
to.append("<div class=\"$cssClass\"$otherAttributes")
to.append(">")
@@ -68,9 +60,7 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,
override fun appendAsOverloadGroup(to: StringBuilder, platforms: Set<String>, block: () -> Unit) {
div(to, "overload-group", calculateDataAttributes(platforms)) {
- ensureParagraph()
block()
- ensureParagraph()
}
}
@@ -158,9 +148,7 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,
appendTableRow(block)
}
- override fun appendPlatforms(platforms: Set<String>) {
-
- }
+ override fun appendPlatforms(platforms: Set<String>) {}
override fun appendBreadcrumbSeparator() {
to.append(" / ")
@@ -181,11 +169,9 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,
class KotlinWebsiteHtmlFormatService @Inject constructor(locationService: LocationService,
signatureGenerator: LanguageService,
@Named(impliedPlatformsName) impliedPlatforms: List<String>)
- : HtmlFormatService(locationService, signatureGenerator, EmptyHtmlTemplateServie, impliedPlatforms) {
+ : HtmlFormatService(locationService, signatureGenerator, EmptyHtmlTemplateService, impliedPlatforms) {
- override fun enumerateSupportFiles(callback: (String, String) -> Unit) {
-
- }
+ override fun enumerateSupportFiles(callback: (String, String) -> Unit) {}
override fun createOutputBuilder(to: StringBuilder, location: Location) =
KotlinWebsiteHtmlOutputBuilder(to, location, locationService, languageService, extension, impliedPlatforms)
diff --git a/core/src/main/kotlin/Formats/StructuredFormatService.kt b/core/src/main/kotlin/Formats/StructuredFormatService.kt
index 743a6ac8..961c2c26 100644
--- a/core/src/main/kotlin/Formats/StructuredFormatService.kt
+++ b/core/src/main/kotlin/Formats/StructuredFormatService.kt
@@ -50,6 +50,12 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
abstract fun appendBlockCode(language: String, body: () -> Unit)
abstract fun appendHeader(level: Int = 1, body: () -> Unit)
abstract fun appendParagraph(body: () -> Unit)
+
+ open fun appendSoftParagraph(body: () -> Unit) {
+ ensureParagraph()
+ body()
+ }
+
abstract fun appendLine()
abstract fun appendAnchor(anchor: String)
@@ -288,9 +294,10 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
formatOverloadGroup(breakdownBySummary.values.single())
} else {
for ((_, items) in breakdownBySummary) {
- ensureParagraph()
- appendAsOverloadGroup(to, platformsOfItems(items)) {
- formatOverloadGroup(items)
+ appendSoftParagraph {
+ appendAsOverloadGroup(to, platformsOfItems(items)) {
+ formatOverloadGroup(items)
+ }
}
}
}
@@ -414,12 +421,12 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
subjectSections.forEach {
val subjectName = it.subjectName
if (subjectName != null) {
- ensureParagraph()
-
- appendAnchor(subjectName)
- appendCode { to.append(subjectName) }
- to.append(" - ")
- appendContent(it)
+ appendSoftParagraph {
+ appendAnchor(subjectName)
+ appendCode { to.append(subjectName) }
+ to.append(" - ")
+ appendContent(it)
+ }
}
}
}
@@ -443,9 +450,10 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
for (member in node.members.sortedBy(DocumentationNode::priority)) {
- ensureParagraph()
- appendAsOverloadGroup(to, platformsOfItems(listOf(member))) {
- formatSubNodeOfGroup(member)
+ appendSoftParagraph {
+ appendAsOverloadGroup(to, platformsOfItems(listOf(member))) {
+ formatSubNodeOfGroup(member)
+ }
}
}
}
diff --git a/core/testdata/format/overloadsWithDescription.html b/core/testdata/format/overloadsWithDescription.html
index 09b92e66..fe98b8fe 100644
--- a/core/testdata/format/overloadsWithDescription.html
+++ b/core/testdata/format/overloadsWithDescription.html
@@ -14,8 +14,7 @@
<p>Performs an action on <a href="test/f#$f(kotlin.Int)/x">x</a>.</p>
<p>This is a long description.</p>
<h3>Parameters</h3>
-
<p><a name="x"></a>
-<code>x</code> - the value to perform the action on.
+<code>x</code> - the value to perform the action on.</p>
</BODY>
</HTML>
diff --git a/core/testdata/format/overloadsWithDifferentDescriptions.html b/core/testdata/format/overloadsWithDifferentDescriptions.html
index 4d621d33..947c72d6 100644
--- a/core/testdata/format/overloadsWithDifferentDescriptions.html
+++ b/core/testdata/format/overloadsWithDifferentDescriptions.html
@@ -7,22 +7,21 @@
<a href="test/index">test</a>&nbsp;/&nbsp;<a href="test/f">f</a><br/>
<br/>
<h1>f</h1>
-
<p><a name="$f(kotlin.Int)"></a>
<code><span class="keyword">fun </span><span class="identifier">f</span><span class="symbol">(</span><span class="identifier" id="$f(kotlin.Int)/x">x</span><span class="symbol">:</span>&nbsp;<span class="identifier">Int</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code>
<p>Performs an action on x.</p>
<p>This is a long description.</p>
<h3>Parameters</h3>
-
<p><a name="x"></a>
-<code>x</code> - the int value to perform the action on.
+<code>x</code> - the int value to perform the action on.</p>
+</p>
<p><a name="$f(kotlin.String)"></a>
<code><span class="keyword">fun </span><span class="identifier">f</span><span class="symbol">(</span><span class="identifier" id="$f(kotlin.String)/x">x</span><span class="symbol">:</span>&nbsp;<span class="identifier">String</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code>
<p>Performs an action on x.</p>
<p>This is a long description.</p>
<h3>Parameters</h3>
-
<p><a name="x"></a>
-<code>x</code> - the string value to perform the action on.
+<code>x</code> - the string value to perform the action on.</p>
+</p>
</BODY>
</HTML>
diff --git a/core/testdata/format/parameterAnchor.html b/core/testdata/format/parameterAnchor.html
index 15532a6d..ecb89fe6 100644
--- a/core/testdata/format/parameterAnchor.html
+++ b/core/testdata/format/parameterAnchor.html
@@ -11,8 +11,7 @@
<code><span class="keyword">fun </span><span class="symbol">&lt;</span><span class="identifier">T</span><span class="symbol">&gt;</span> <span class="identifier">processFiles</span><span class="symbol">(</span><span class="identifier" id="$processFiles(kotlin.Function0((processFiles.T)))/processor">processor</span><span class="symbol">:</span>&nbsp;<span class="symbol">(</span><span class="symbol">)</span>&nbsp;<span class="symbol">-&gt;</span>&nbsp;<span class="identifier">T</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">List</span><span class="symbol">&lt;</span><span class="identifier">T</span><span class="symbol">&gt;</span></code>
<p>Runs <a href="test/process-files#$processFiles(kotlin.Function0((processFiles.T)))/processor">processor</a> for each file and collects its results into single list</p>
<h3>Parameters</h3>
-
<p><a name="processor"></a>
-<code>processor</code> - function to receive context for symbol resolution and file for processing
+<code>processor</code> - function to receive context for symbol resolution and file for processing</p>
</BODY>
</HTML>