kdoc now has working interactive search of classes, functions, properties e.g. "map()" or "fun map" or "class Foo" etc
This commit is contained in:
@@ -13,7 +13,7 @@ $(function(){
|
|||||||
success: function( xmlResponse ) {
|
success: function( xmlResponse ) {
|
||||||
var data = $( "search", xmlResponse ).map(function() {
|
var data = $( "search", xmlResponse ).map(function() {
|
||||||
return {
|
return {
|
||||||
value: $( "name", this ).text(),
|
value: $( "kind", this ).text() + " " + $( "name", this ).text(),
|
||||||
id: $( "href", this ).text()
|
id: $( "href", this ).text()
|
||||||
};
|
};
|
||||||
}).get();
|
}).get();
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
|
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat; }
|
||||||
|
|
||||||
.ui-autocomplete {
|
.ui-autocomplete {
|
||||||
max-height: 100px;
|
max-height: 500px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
/* prevent horizontal scrollbar */
|
/* prevent horizontal scrollbar */
|
||||||
overflow-x: hidden;
|
overflow-x: hidden;
|
||||||
@@ -88,7 +88,7 @@
|
|||||||
* we use height instead, but this forces the menu to always be this tall
|
* we use height instead, but this forces the menu to always be this tall
|
||||||
*/
|
*/
|
||||||
* html .ui-autocomplete {
|
* html .ui-autocomplete {
|
||||||
height: 100px;
|
height: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.NavBarCell1 label {
|
.NavBarCell1 label {
|
||||||
|
|||||||
@@ -691,15 +691,14 @@ class TemplateLinkRenderer(val annotated: KAnnotated, val template: KDocTemplate
|
|||||||
|
|
||||||
// TODO really dirty hack alert!!!
|
// TODO really dirty hack alert!!!
|
||||||
// until the resolver is working, lets try adding a few prefixes :)
|
// until the resolver is working, lets try adding a few prefixes :)
|
||||||
for (prefix in arrayList("java.lang", "java.util", "java.util.regex", "java.io", "jet"))
|
for (prefix in arrayList("java.lang", "java.util", "java.util.regex", "java.io", "jet")) {
|
||||||
if (href == null) {
|
if (href == null) {
|
||||||
href = resolveClassNameLink(prefix + "." + qualified)
|
href = resolveClassNameLink(prefix + "." + qualified)
|
||||||
|
if (href != null) {
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/** TODO use break when KT-1523 is fixed
|
|
||||||
if (href != null) {
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
if (href != null) {
|
if (href != null) {
|
||||||
answer.href = href
|
answer.href = href
|
||||||
@@ -1129,6 +1128,8 @@ class KProperty(val owner: KClassOrPackage, val descriptor: PropertyDescriptor,
|
|||||||
|
|
||||||
fun isVar(): Boolean = descriptor.isVar()
|
fun isVar(): Boolean = descriptor.isVar()
|
||||||
|
|
||||||
|
fun kind(): String = if (isVar()) "var" else "val"
|
||||||
|
|
||||||
fun toString() = "property $name"
|
fun toString() = "property $name"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -53,6 +53,10 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
return "${extensionsHref(pkg, c)}#${f.link}"
|
return "${extensionsHref(pkg, c)}#${f.link}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun extensionsHref(pkg: KPackage, c: KClass, f: KProperty): String {
|
||||||
|
return "${extensionsHref(pkg, c)}#${f.link}"
|
||||||
|
}
|
||||||
|
|
||||||
open fun sourceHref(klass: KClass): String {
|
open fun sourceHref(klass: KClass): String {
|
||||||
if (klass.isLinkToSourceRepo()) {
|
if (klass.isLinkToSourceRepo()) {
|
||||||
return klass.sourceLink()
|
return klass.sourceLink()
|
||||||
@@ -160,7 +164,7 @@ abstract class KDocTemplate() : TextTemplate() {
|
|||||||
fun searchBox(): String =
|
fun searchBox(): String =
|
||||||
""" <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1" ALIGN="right">
|
""" <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1" ALIGN="right">
|
||||||
<label for="searchBox">Search: </label>
|
<label for="searchBox">Search: </label>
|
||||||
<input id="searchBox" class="ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true" data-url="${relativePrefix()}search.xml">
|
<input id="searchBox" class="ui-autocomplete-input" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true" size="50" data-url="${relativePrefix()}search.xml">
|
||||||
</TD>"""
|
</TD>"""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Vendored
+53
-6
@@ -5,19 +5,66 @@ import org.jetbrains.kotlin.template.*
|
|||||||
import kotlin.io.*
|
import kotlin.io.*
|
||||||
import kotlin.util.*
|
import kotlin.util.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import org.jetbrains.kotlin.doc.model.KModel
|
import org.jetbrains.kotlin.doc.model.*
|
||||||
|
|
||||||
|
class SearchXmlTemplate(val model: KModel): KDocTemplate() {
|
||||||
|
|
||||||
|
class Search(val name: String, val href: String, val kind: String) {
|
||||||
|
fun toString() = "Search($name, $href, $kind)"
|
||||||
|
}
|
||||||
|
|
||||||
class SearchXmlTemplate(val model: KModel) : KDocTemplate() {
|
|
||||||
override fun render() {
|
override fun render() {
|
||||||
|
val map = TreeMap<String, Search>()
|
||||||
|
|
||||||
|
fun add(name: String, href: String, kind: String): Unit {
|
||||||
|
val search = Search(name, href, kind)
|
||||||
|
if (!map.containsKey(name)) {
|
||||||
|
map.put(name, search)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun add(owner: KClass, c: KFunction, href: String): Unit {
|
||||||
|
add("${c.name}() [${owner.name}]", href, "fun")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun add(owner: KClass, c: KProperty, href: String): Unit {
|
||||||
|
add("${c.name} [${owner.name}]", href, c.kind())
|
||||||
|
}
|
||||||
|
|
||||||
|
for (c in model.classes) {
|
||||||
|
add("${c.simpleName} [${c.pkg.name}]", "${c.nameAsPath}.html", c.kind)
|
||||||
|
|
||||||
|
c.functions.forEach{ add(c, it, href(it)) }
|
||||||
|
c.properties.forEach{ add(c, it, href(it)) }
|
||||||
|
}
|
||||||
|
|
||||||
|
for (p in model.packages) {
|
||||||
|
val map = inheritedExtensionFunctions(p.functions)
|
||||||
|
val pmap = inheritedExtensionProperties(p.properties)
|
||||||
|
val classes = hashSet<KClass>()
|
||||||
|
classes.addAll(map.keySet())
|
||||||
|
classes.addAll(pmap.keySet())
|
||||||
|
for (c in classes) {
|
||||||
|
if (c != null) {
|
||||||
|
val functions = map.get(c).orEmpty()
|
||||||
|
val properties = pmap.get(c).orEmpty()
|
||||||
|
|
||||||
|
functions.forEach{ add(c, it, p.nameAsPath + "/" + extensionsHref(p, c, it)) }
|
||||||
|
functions.forEach{ add(c, it, p.nameAsPath + "/" + extensionsHref(p, c, it)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
println("""<?xml version="1.0" encoding="UTF-8"?>
|
println("""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<searches>""")
|
<searches>""")
|
||||||
for (c in model.classes) {
|
for (s in map.values()!!) {
|
||||||
println("""<search>
|
println("""<search>
|
||||||
<href>${c.nameAsPath}.html</href>
|
<href>${s.href}</href>
|
||||||
<name>${c.name}</name>
|
<name>${s.name}</name>
|
||||||
<kind>${c.kind}</kind>
|
<kind>${s.kind}</kind>
|
||||||
</search>""")
|
</search>""")
|
||||||
}
|
}
|
||||||
println("""</searches>""")
|
println("""</searches>""")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user