Scaladoc inherit with notice

178 Views Asked by At

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 = ???
}
1

There are 1 best solutions below

0
On BEST ANSWER

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.