How do I insert a code snippet in KDoc, Kotlin's default documentation tool?
In Java, I can use the following:
/** * Example usage: * * <pre> * <code>@JavaAnnotation * public void foo() { * // Code * } * </code> * </pre> */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface JavaAnnotation {}
There seems to be no equivalent in Kotlin. I tried using Markdown, but inserting 2 spaces after line end does not line-break.
You can use triple backticks:
/** * Example usage: * * ``` * @JavaAnnotation * public void foo() { * // Code * } * ``` */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With