2

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 = ???
}
Andrii Abramov
  • 10,019
  • 9
  • 74
  • 96

1 Answers1

1

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.

Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35