Defining scaladoc macros for reuse in companion object

360 Views Asked by At

I am trying to understand how scaladoc macros work. E.g.

/** $DESCR
  *
  * @define DESCR
  * A `Consumer` simplifies resource management...
  *
  * @define KEY
  * the key type
  *
  * @define VALUE
  * the value type
  */
object Consumer {
  /** Creates a new consumer
    *
    * @tparam A       $KEY
    * @tparam B       $VALUE
    */
  def apply[A, B](): Consumer[A, B] = ???
}

/** $DESCR
  *
  * @tparam A $KEY
  * @tparam B $VALUE
  */
trait Consumer[-A, +B]

I was under the impression that this should produce a documentation which has both for trait and companion object the description A Consumer simplifies resource management..., and also shows the two type parameter descriptions in the apply method and the trait.

But the macros seem to be unavailable in the trait. While the object is correctly documented, the trait doc just shows the macro names $DESCR, $KEY, $VALUE.

0

There are 0 best solutions below