Skip to content

Commit

Permalink
Tweak kws html format to match output of old format
Browse files Browse the repository at this point in the history
  • Loading branch information
semoro committed Apr 10, 2017
1 parent e13d38a commit f65fbf5
Show file tree
Hide file tree
Showing 28 changed files with 134 additions and 93 deletions.
2 changes: 1 addition & 1 deletion core/src/main/kotlin/Formats/HtmlFormatService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ 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 appendSoftParagraph(body: () -> Unit) = body()

override fun appendLine() {
to.appendln("<br/>")
Expand Down
19 changes: 11 additions & 8 deletions core/src/main/kotlin/Formats/KotlinWebsiteHtmlFormatService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,6 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,

override fun appendLink(href: String, body: () -> Unit) = wrap("<a href=\"$href\">", "</a>", body)

override fun appendHeader(level: Int, body: () -> Unit) {
if (insideDiv > 0) {
wrapInTag("p", body, newlineAfterClose = true)
} else {
super.appendHeader(level, body)
}
}

override fun appendTable(vararg columns: String, body: () -> Unit) {
to.appendln("<table class=\"api-docs-table\">")
body()
Expand Down Expand Up @@ -164,6 +156,17 @@ open class KotlinWebsiteHtmlOutputBuilder(to: StringBuilder,
}
}
}

override fun appendSoftParagraph(body: () -> Unit) = appendParagraph(body)


override fun appendSectionWithTag(section: ContentSection) {
appendParagraph {
appendStrong { appendText(section.tag) }
appendText(" ")
appendContent(section)
}
}
}

class KotlinWebsiteHtmlFormatService @Inject constructor(locationService: LocationService,
Expand Down
38 changes: 22 additions & 16 deletions core/src/main/kotlin/Formats/StructuredFormatService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}
}

open fun appendSectionWithTag(section: ContentSection) {
appendParagraph {
appendStrong { appendText(section.tag) }
appendLine()
appendContent(section)
}
}

open fun appendSymbol(text: String) {
appendText(text)
}
Expand Down Expand Up @@ -294,11 +302,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
formatOverloadGroup(breakdownBySummary.values.single())
} else {
for ((_, items) in breakdownBySummary) {
appendSoftParagraph {
appendAsOverloadGroup(to, platformsOfItems(items)) {
formatOverloadGroup(items)
}

appendAsOverloadGroup(to, platformsOfItems(items)) {
formatOverloadGroup(items)
}

}
}
}
Expand Down Expand Up @@ -408,11 +416,7 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}

for (section in content.sections.filter { it.subjectName == null }) {
appendParagraph {
appendStrong { appendText(section.tag) }
appendLine()
appendContent(section)
}
appendSectionWithTag(section)
}
}

Expand Down Expand Up @@ -450,11 +454,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
}

for (member in node.members.sortedBy(DocumentationNode::priority)) {
appendSoftParagraph {
appendAsOverloadGroup(to, platformsOfItems(listOf(member))) {
formatSubNodeOfGroup(member)
}

appendAsOverloadGroup(to, platformsOfItems(listOf(member))) {
formatSubNodeOfGroup(member)
}

}
}

Expand Down Expand Up @@ -559,9 +563,11 @@ abstract class StructuredOutputBuilder(val to: StringBuilder,
elementPlatforms
appendIndexRow(platforms) {
appendTableCell {
appendLink(memberLocation)
if (members.singleOrNull()?.kind != NodeKind.ExternalClass) {
appendPlatforms(platforms)
appendParagraph {
appendLink(memberLocation)
if (members.singleOrNull()?.kind != NodeKind.ExternalClass) {
appendPlatforms(platforms)
}
}
}
appendTableCell {
Expand Down
2 changes: 2 additions & 0 deletions core/src/test/kotlin/format/KotlinWebSiteFormatTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package org.jetbrains.dokka.tests

import org.jetbrains.dokka.*
import org.jetbrains.kotlin.utils.addToStdlib.singletonOrEmptyList
import org.junit.Ignore
import org.junit.Test

@Ignore
class KotlinWebSiteFormatTest {
private val kwsService = KotlinWebsiteFormatService(InMemoryLocationService, KotlinLanguageService(), listOf(), DokkaConsoleLogger)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.DokkaConsoleLogger
import org.jetbrains.dokka.KotlinLanguageService
import org.jetbrains.dokka.KotlinWebsiteRunnableSamplesFormatService
import org.junit.Ignore
import org.junit.Test

@Ignore
class KotlinWebSiteRunnableSamplesFormatTest {
private val kwsService = KotlinWebsiteRunnableSamplesFormatService(InMemoryLocationService, KotlinLanguageService(), listOf(), DokkaConsoleLogger)

Expand Down
9 changes: 6 additions & 3 deletions core/testdata/format/classWithCompanionObject.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-klass/-init-">&lt;init&gt;</a></td>
<p><a href="test/-klass/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Klass</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
</tr>
Expand All @@ -24,7 +25,8 @@ <h3>Companion Object Properties</h3>
<tbody>
<tr>
<td>
<a href="test/-klass/x">x</a></td>
<p><a href="test/-klass/x">x</a></p>
</td>
<td>
<code><span class="keyword">val </span><span class="identifier">x</span><span class="symbol">: </span><span class="identifier">Int</span></code></td>
</tr>
Expand All @@ -35,7 +37,8 @@ <h3>Companion Object Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-klass/foo">foo</a></td>
<p><a href="test/-klass/foo">foo</a></p>
</td>
<td>
<code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
6 changes: 4 additions & 2 deletions core/testdata/format/crossLanguage/kotlinExtendsJava/Bar.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/test/-bar/-init-">&lt;init&gt;</a></td>
<p><a href="test/test/-bar/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code>
<p>See <a href="test/test/-foo/xyzzy">xyzzy</a></p>
Expand All @@ -27,7 +28,8 @@ <h3>Inherited Functions</h3>
<tbody>
<tr>
<td>
<a href="test/test/-foo/xyzzy">xyzzy</a></td>
<p><a href="test/test/-foo/xyzzy">xyzzy</a></p>
</td>
<td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">xyzzy</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
9 changes: 6 additions & 3 deletions core/testdata/format/deprecated.package.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ <h3>Types</h3>
<tbody>
<tr>
<td>
<a href="test/-c/index">C</a></td>
<p><a href="test/-c/index">C</a></p>
</td>
<td>
<code><span class="keyword">class </span><s><span class="identifier">C</span></s></code></td>
</tr>
Expand All @@ -23,7 +24,8 @@ <h3>Properties</h3>
<tbody>
<tr>
<td>
<a href="test/p">p</a></td>
<p><a href="test/p">p</a></p>
</td>
<td>
<code><span class="keyword">val </span><s><span class="identifier">p</span></s><span class="symbol">: </span><span class="identifier">Int</span></code></td>
</tr>
Expand All @@ -34,7 +36,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/f">f</a></td>
<p><a href="test/f">f</a></p>
</td>
<td>
<code><span class="keyword">fun </span><s><span class="identifier">f</span></s><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion core/testdata/format/entity.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-bar/-init-">&lt;init&gt;</a></td>
<p><a href="test/-bar/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code>
<p>Copyright &copy; JetBrains 2015 &#x22;</p>
Expand Down
6 changes: 4 additions & 2 deletions core/testdata/format/javaLinkTag.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-foo/-init-">&lt;init&gt;</a></td>
<p><a href="test/-foo/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Foo</span><span class="symbol">(</span><span class="symbol">)</span></code>
<p>Call <code><a href="test/-foo/bar">#bar()</a></code> to do the job.</p>
Expand All @@ -27,7 +28,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-foo/bar">bar</a></td>
<p><a href="test/-foo/bar">bar</a></p>
</td>
<td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
6 changes: 4 additions & 2 deletions core/testdata/format/javaLinkTagWithLabel.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-foo/-init-">&lt;init&gt;</a></td>
<p><a href="test/-foo/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Foo</span><span class="symbol">(</span><span class="symbol">)</span></code>
<p>Call <code><a href="test/-foo/bar">this wonderful method</a></code> to do the job.</p>
Expand All @@ -27,7 +28,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-foo/bar">bar</a></td>
<p><a href="test/-foo/bar">bar</a></p>
</td>
<td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
6 changes: 4 additions & 2 deletions core/testdata/format/javaSeeTag.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-foo/-init-">&lt;init&gt;</a></td>
<p><a href="test/-foo/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Foo</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
</tr>
Expand All @@ -26,7 +27,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-foo/bar">bar</a></td>
<p><a href="test/-foo/bar">bar</a></p>
</td>
<td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">bar</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
6 changes: 4 additions & 2 deletions core/testdata/format/javaSupertype.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-c/-bar/-init-">&lt;init&gt;</a></td>
<p><a href="test/-c/-bar/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code></td>
</tr>
Expand All @@ -24,7 +25,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-c/-bar/return-foo">returnFoo</a></td>
<p><a href="test/-c/-bar/return-foo">returnFoo</a></p>
</td>
<td>
<code><span class="keyword">open</span> <span class="keyword">fun </span><span class="identifier">returnFoo</span><span class="symbol">(</span><span class="identifier" id="C.Bar$returnFoo(C.Foo)/foo">foo</span><span class="symbol">:</span>&nbsp;<a href="test/-c/-foo/index"><span class="identifier">Foo</span></a><span class="symbol">)</span><span class="symbol">: </span><a href="test/-c/-foo/index"><span class="identifier">Foo</span></a></code></td>
</tr>
Expand Down
6 changes: 4 additions & 2 deletions core/testdata/format/linkWithLabel.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-bar/-init-">&lt;init&gt;</a></td>
<p><a href="test/-bar/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code>
<p>Use <a href="test/-bar/foo">this method</a> for best results.</p>
Expand All @@ -27,7 +28,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-bar/foo">foo</a></td>
<p><a href="test/-bar/foo">foo</a></p>
</td>
<td>
<code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion core/testdata/format/linkWithStarProjection.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/-k-class-loader/foo">foo</a></td>
<p><a href="test/-k-class-loader/foo">foo</a></p>
</td>
<td>
<code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="identifier" id="KClassLoader$foo(kotlin.Enum(()))/c">c</span><span class="symbol">:</span>&nbsp;<span class="identifier">Enum</span><span class="symbol">&lt;</span><span class="identifier">*</span><span class="symbol">&gt;</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion core/testdata/format/orderedList.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ <h3>Constructors</h3>
<tbody>
<tr>
<td>
<a href="test/-bar/-init-">&lt;init&gt;</a></td>
<p><a href="test/-bar/-init-">&lt;init&gt;</a></p>
</td>
<td>
<code><span class="identifier">Bar</span><span class="symbol">(</span><span class="symbol">)</span></code>
<p>Usage instructions:</p>
Expand Down
3 changes: 2 additions & 1 deletion core/testdata/format/overloads.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ <h3>Functions</h3>
<tbody>
<tr>
<td>
<a href="test/f">f</a></td>
<p><a href="test/f">f</a></p>
</td>
<td>
<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><br/>
<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>
Expand Down
4 changes: 2 additions & 2 deletions core/testdata/format/overloadsWithDescription.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h1>f</h1>
<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.</p>
<a name="x"></a>
<code>x</code> - the value to perform the action on.
</BODY>
</HTML>
13 changes: 5 additions & 8 deletions core/testdata/format/overloadsWithDifferentDescriptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,18 @@
<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>
<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.</p>
</p>
<p><a name="$f(kotlin.String)"></a>
<a name="x"></a>
<code>x</code> - the int value to perform the action on.<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.</p>
</p>
<a name="x"></a>
<code>x</code> - the string value to perform the action on.
</BODY>
</HTML>
Loading

0 comments on commit f65fbf5

Please sign in to comment.