add export from kotlin into swift of simple documentation comment #KT-65913 fixed
Merge-request: KT-MR-14622 Merged-by: Artem Olkov <artem.olkov@jetbrains.com>
This commit is contained in:
@@ -42,6 +42,7 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
|
||||
override fun visitClass(klass: SirClass): Unit = with(printer) {
|
||||
printDocumentation(klass)
|
||||
printVisibility(klass)
|
||||
println(
|
||||
"class ",
|
||||
@@ -55,6 +56,7 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
|
||||
override fun visitVariable(variable: SirVariable): Unit = with(printer) {
|
||||
printDocumentation(variable)
|
||||
printVisibility(variable)
|
||||
printCallableKind(variable.kind)
|
||||
print(
|
||||
@@ -94,7 +96,7 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
|
||||
override fun visitFunction(function: SirFunction): Unit = with(printer) {
|
||||
function.documentation?.let { println(it) }
|
||||
printDocumentation(function)
|
||||
printVisibility(function)
|
||||
printCallableKind(function.kind)
|
||||
print(
|
||||
@@ -118,7 +120,7 @@ public class SirAsSwiftSourcesPrinter(private val printer: SmartPrinter) : SirVi
|
||||
}
|
||||
|
||||
override fun visitInit(init: SirInit): Unit = with(printer) {
|
||||
init.documentation?.let { println(it) }
|
||||
printDocumentation(init)
|
||||
printVisibility(init)
|
||||
printInitKind(init.initKind)
|
||||
print("init")
|
||||
@@ -192,6 +194,10 @@ internal fun SmartPrinter.printVisibility(decl: SirDeclaration) {
|
||||
)
|
||||
}
|
||||
|
||||
internal fun SmartPrinter.printDocumentation(decl: SirDeclaration) {
|
||||
decl.documentation?.lines()?.forEach { println(it.trimIndent()) }
|
||||
}
|
||||
|
||||
internal fun SmartPrinter.printInitKind(decl: SirInitializerKind) {
|
||||
print(
|
||||
when (decl) {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
/// Function foo description.
|
||||
/// - Parameters:
|
||||
/// - p: first Integer to consume
|
||||
/// - Returns: Bool
|
||||
public class Foo {
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
public enum NAMESPACE {
|
||||
/**
|
||||
* demo comment for
|
||||
* NAMESPACED_CLASS
|
||||
*/
|
||||
public class Foo {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
|
||||
/// Function foo description.
|
||||
/// - Parameters:
|
||||
/// - p: first Integer to consume
|
||||
/// - Returns: Bool
|
||||
public var myVariable: Swift.Bool {
|
||||
get
|
||||
}
|
||||
+84
-1
@@ -270,7 +270,7 @@ class SirAsSwiftSourcesPrinterTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should print DocC comment`() {
|
||||
fun `should print DocC comment on function`() {
|
||||
|
||||
val module = buildModule {
|
||||
name = "Test"
|
||||
@@ -303,6 +303,89 @@ class SirAsSwiftSourcesPrinterTests {
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should print DocC comment on class`() {
|
||||
|
||||
val module = buildModule {
|
||||
name = "Test"
|
||||
declarations.add(
|
||||
buildClass {
|
||||
origin = SirOrigin.Unknown
|
||||
visibility = SirVisibility.PUBLIC
|
||||
name = "Foo"
|
||||
documentation = """
|
||||
/// Function foo description.
|
||||
/// - Parameters:
|
||||
/// - p: first Integer to consume
|
||||
/// - Returns: Bool
|
||||
""".trimIndent()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
runTest(
|
||||
module,
|
||||
"testData/commented_class"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should print DocC comment on namespaced class`() {
|
||||
|
||||
val module = buildModule {
|
||||
name = "Test"
|
||||
declarations.add(
|
||||
buildEnum {
|
||||
name = "NAMESPACE"
|
||||
declarations += buildClass {
|
||||
origin = SirOrigin.Unknown
|
||||
visibility = SirVisibility.PUBLIC
|
||||
name = "Foo"
|
||||
documentation = """
|
||||
/**
|
||||
* demo comment for
|
||||
* NAMESPACED_CLASS
|
||||
*/
|
||||
""".trimIndent()
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
runTest(
|
||||
module,
|
||||
"testData/commented_namespaced_class"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should print DocC comment on variable`() {
|
||||
|
||||
val module = buildModule {
|
||||
name = "Test"
|
||||
declarations.add(
|
||||
buildVariable {
|
||||
name = "myVariable"
|
||||
type = SirNominalType(SirSwiftModule.bool)
|
||||
getter = buildGetter {
|
||||
kind = SirCallableKind.INSTANCE_METHOD
|
||||
}
|
||||
documentation = """
|
||||
/// Function foo description.
|
||||
/// - Parameters:
|
||||
/// - p: first Integer to consume
|
||||
/// - Returns: Bool
|
||||
""".trimIndent()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
runTest(
|
||||
module,
|
||||
"testData/commented_variable"
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `should print empty class`() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user