QuickDoc: Show sample code containing type parameters correctly

#KT-20777 Fixed
This commit is contained in:
scache
2017-10-19 02:45:16 +09:00
committed by Simon Ogorodnik
parent 2ef575d94e
commit 9062f4229b
7 changed files with 46 additions and 1 deletions
@@ -124,7 +124,7 @@ object KDocRenderer {
if (target == null)
to.append("// Unresolved")
else {
to.append(trimCommonIndent(target.extractExampleText()))
to.append(trimCommonIndent(target.extractExampleText()).htmlEscape())
}
}
}
@@ -0,0 +1,11 @@
/**
* @sample samples.nestedTypeParameter
*/
fun some<caret>() {
}
//INFO: <div class='definition'><pre><font color="808080"><i>usageNestedTypeParameters.kt</i></font><br>public fun <b>some</b>(): Unit</pre></div><div class='content'></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td valign='top'><p><a href="psi_element://samples.nestedTypeParameter"><code>samples.nestedTypeParameter</code></a><pre><code>
//INFO: val m = mapOf&lt;String, Pair&lt;Int, Long&gt;&gt;()
//INFO: println(m)
//INFO: </code></pre></td></table>
@@ -0,0 +1,11 @@
/**
* @sample samples.singleTypeParameter
*/
fun some<caret>() {
}
//INFO: <div class='definition'><pre><font color="808080"><i>usageSingleTypeParameter.kt</i></font><br>public fun <b>some</b>(): Unit</pre></div><div class='content'></div><table class='sections'><tr><td valign='top' class='section'><p>Samples:</td><td valign='top'><p><a href="psi_element://samples.singleTypeParameter"><code>samples.singleTypeParameter</code></a><pre><code>
//INFO: val l = listOf&lt;String&gt;()
//INFO: println(l)
//INFO: </code></pre></td></table>
@@ -0,0 +1,6 @@
package samples
fun nestedTypeParameter() {
val m = mapOf<String, Pair<Int, Long>>()
println(m)
}
@@ -0,0 +1,6 @@
package samples
fun singleTypeParameter() {
val l = listOf<String>()
println(l)
}
@@ -58,6 +58,17 @@ class KDocSampleTest : AbstractMultiModuleTest() {
doResolveTest("fqName/code/usage.kt", "samplez.a.b.c.Samplez")
}
fun testTypeParameters() {
val code = module("code")
val samples = module("samples", hasTestRoot = true)
samples.addDependency(code)
doInfoTest("typeParameters/code/usageSingleTypeParameter.kt")
doInfoTest("typeParameters/code/usageNestedTypeParameters.kt")
}
fun doResolveTest(path: String, link: String) {
configureByFile(path)