added support for public properties at the package level to kdoc
This commit is contained in:
@@ -1018,6 +1018,8 @@ class KPackage(model: KModel, val descriptor: NamespaceDescriptor,
|
||||
}
|
||||
|
||||
fun packageFunctions() = functions.filter{ it.extensionClass == null }
|
||||
|
||||
fun packageProperties() = properties.filter{ it.extensionClass == null && it.isPublic() }
|
||||
}
|
||||
|
||||
class KType(val jetType: JetType, model: KModel, val klass: KClass?, val arguments: List<KType> = ArrayList<KType>())
|
||||
@@ -1175,6 +1177,11 @@ class KProperty(val owner: KClassOrPackage, val descriptor: PropertyDescriptor,
|
||||
|
||||
fun kind(): String = if (isVar()) "var" else "val"
|
||||
|
||||
fun isPublic(): Boolean {
|
||||
val visibility = descriptor.getVisibility()
|
||||
return visibility.isPublicAPI()
|
||||
}
|
||||
|
||||
fun toString() = "property $name"
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -36,6 +36,13 @@ abstract class KDocTemplate() : TextTemplate() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a link to a package level property
|
||||
*/
|
||||
open fun href(pkg: KPackage, p: KProperty): String {
|
||||
return "${href(pkg)}#${p.link}"
|
||||
}
|
||||
|
||||
open fun href(f: KProperty): String {
|
||||
return if (f.owner is KClass) {
|
||||
"${href(f.owner)}#${f.link}"
|
||||
|
||||
Vendored
+19
@@ -38,6 +38,7 @@ ${stylesheets()}
|
||||
printClasses("enum", "Enums")
|
||||
printClasses("annotation", "Annotations")
|
||||
printClasses("exception", "Exceptions")
|
||||
printPackageProperties()
|
||||
printFunctions()
|
||||
printExtensionFunctions()
|
||||
|
||||
@@ -104,6 +105,24 @@ ${stylesheets()}
|
||||
}
|
||||
}
|
||||
println("""</TR>
|
||||
</TABLE>""")
|
||||
}
|
||||
}
|
||||
protected fun printPackageProperties(): Unit {
|
||||
val list = pkg.packageProperties()
|
||||
if (list.notEmpty()) {
|
||||
println("""<TABLE BORDER="0" WIDTH="100%" SUMMARY="">
|
||||
<TR>
|
||||
<TD NOWRAP><FONT size="+1" CLASS="FrameHeadingFont">Properties</FONT>
|
||||
<FONT CLASS="FrameItemFont">
|
||||
<BR>""")
|
||||
for (c in list) {
|
||||
if (c != null) {
|
||||
println("""<A HREF="${href(pkg, c)}" title="property from ${pkg.name}" target="classFrame"><I>${c.name}</I></A>
|
||||
<BR>""")
|
||||
}
|
||||
}
|
||||
println("""</TR>
|
||||
</TABLE>""")
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-1
@@ -121,8 +121,9 @@ ${pkg.description(this)}
|
||||
printClasses("annotation", "Annotations")
|
||||
printClasses("exception", "Exceptions")
|
||||
|
||||
printPropertySummary(pkg.packageProperties())
|
||||
printFunctionSummary(pkg.packageFunctions())
|
||||
//printFunctions()
|
||||
|
||||
printExtensionFunctions()
|
||||
|
||||
println("""<A NAME="package_description"><!-- --></A><H2>
|
||||
|
||||
Reference in New Issue
Block a user