Hi,
Is there a way to specify the order in which (type and value) members are listed in the scaladoc?
Using @group annotations already helps a lot structuring a scaladoc.
But inside a given group, members are listed alphabetically (first types, and then values).
Instead, I would like them to be listed in the same order as in the source code.
Is there any (maybe undocumented) option to pass to scaladoc (sbt doc) to achieve this?
I couldn’t find such a thing in the “Scaladoc for Library Authors” guide.
The typical usecase is the scaladoc of a sealed trait + case classes and objects. I would like the trait to appear before all subclasses and objects.
Thanks
I found a workaround.
It is not fully satisfactory, but I choose to share it here anyway, in case someone faces the same problem.
Better solutions and suggestions still welcome!
The trick is to use “phantom groups” – just made the term up – to create sub-groups.
A phantom group has a @groupname that is not visible in the scaladoc. For instance, the unicode ‘ZERO WIDTH SPACE’ character.
Then, use @groupdesc of a phantom group to explain what is the purpose of this sub-group.
Finally, use @groupprio to choose the order in which the groups and phantom groups will be displayed.
Complete working example is here (a preview is given below):
package example
/**
* @groupname t The type
* @groupdesc t I want to display:
* - the trait first,
* - then (base objects),
* - and then classes organized in categories
* @groupprio t 1
*
* @groupname cat1 \u200B
* @groupdesc cat1 A base object extending that trait.
* @groupprio cat1 2
*
* @groupname cat2 \u200B
* @groupdesc cat2 Then the first category of classes
* @groupprio cat2 3
*
* @groupname cat3 \u200B
* @groupdesc cat3 Then the second category of classes
* @groupprio cat3 4
*
* @groupname t2 Another type -- for which I don't care
* @groupprio t2 30
*
*/
package object docPhantomGroups {
/** @group t */
sealed trait MyType
/** @group cat1 */
final case object BaseObject extends MyType
/** @group cat2 */
final case class Class(x: Int) extends MyType
/** @group cat2 */
final case class SimilarClass(x: Int) extends MyType
/** @group cat3 */
final case class AnotherClass(x: Int) extends MyType
/** @group cat3 */
final case class YetAnotherClass(x: Int) extends MyType
/** @group t2 */
sealed trait AnotherType
}