Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KDoc: Insert code snippet

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>&#64;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.

like image 678
F. George Avatar asked Nov 03 '16 11:11

F. George


1 Answers

You can use triple backticks:

/**  * Example usage:  *  * ```  * @JavaAnnotation  * public void foo() {  *     // Code  * }  * ```  */ 
like image 81
yole Avatar answered Sep 22 '22 08:09

yole