Andrii Abramov
Andrii Abramov

Reputation: 10751

Scaladoc inherit with notice

Is it possible to inherit scaladoc from parent type and add custom notice?

For example:

trait Parent {
  
  /** Add arbitrary number of key-value pairs to entity. */
  def addFields(fields: (String, String)*): this.type
}

class Child extends Parent {

   /** 
    * {@inheritdoc }
    *
    * @note Previously existing keys would be overwritten 
    */
  def addFields(fields: (String, String)*): this.type = ???
}

I am expecting to have the following scaladoc output:

class Child extends Parent {

   /** 
    * Add arbitrary number of key-value pairs to entity.
    *
    * @note Previously existing keys would be overwritten 
    */
  def addFields(fields: (String, String)*): this.type = ???
}

Upvotes: 2

Views: 184

Answers (1)

Tomer Shetah
Tomer Shetah

Reputation: 8529

Actually you have the solution in hand already. Unlike java, you just don't need to wrap @inheritdoc with curly braces. So the following will create the desired output:

trait Parent {
  
  /** Add arbitrary number of key-value pairs to entity. */
  def addFields(fields: (String, String)*): this.type
}

class Child extends Parent {

   /** 
    * @inheritdoc
    *
    * @note Previously existing keys would be overwritten 
    */
  override def addFields(fields: (String, String)*): this.type = ???
}

I've attached a screenshot to show the final result.

More can be read at Generate API documentation by sbt and at SCALADOC FOR LIBRARY AUTHORS.

Upvotes: 1

Related Questions