Adding code examples in scaladoc
Asked Answered
C

1

5

What is the standard convention (or tag) to add code examples in ScalaDoc? Example in the code below, I want to provide coding example to demonstrate it's usage:

/**
 * Adds a filter on DB Table Query if value is defined. Example:
 *
 * {code}
 * val startIncluded: Option[Timestamp] = _
 * tableQuery.filter(startIncluded)(startTime => _.start >= startTime)
 * {code}
 *
 * ... other doc ...
 */
def filter (value: Option[T])(condition: T => Table => Option[Boolean]) = {

Like in javadocs, @code is used.

Cogan answered 31/8, 2015 at 18:26 Comment(1)
wiki.scala-lang.org/display/SW/SyntaxSonnier
C
15

You can use {{{ }}} to delimit code blocks:

/**
 * This is a comment.
 * 
 * {{{
 * this.is(example.code)
 * }}}
 */
 def is(some: Code): Unit
Cuomo answered 31/8, 2015 at 18:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.