Scaladoc fails to generate links for inner classes in method and class signatures
Asked Answered
S

1

6

I have a top level trait that contains a number of classes and traits like:

trait Trees { self: Types =>
  trait Tree
  trait IdentifiedTree extends Tree
  trait Empty extends Tree

  /** The factory for [[TypeUse]] instances */
  trait TypeUse extends Tree
  /** AST tree to represent erroneous trees */
  object BadTree extends IdentifiedTree
  /** AST tree for empty statements and trees */
  val Empty: Empty = new Empty {}
}

trait Types

When I generate the documentation for it, using scaladoc I can link to the inner classes, using [[CLASS_NAME]], but scaladoc fails to create links for trees both in signatures and extends.

I use sbt to generate the scaladoc, and I use the following flags:

scalacOptions in (Compile, doc) ++= Seq("-groups", "-implicits",
     "-diagrams", "-no-prefixes", "-author", "-explaintypes",
     "-language:implicitConversions,higherKinds")

To give you a better idea, the api for the above definition is as follows (please note the missing links):

enter image description here

Can you tell me what am I doing wrong, please?

Seda answered 28/5, 2015 at 15:50 Comment(2)
Not sure if this helps, but my sbt configuration is a multi-project oneSeda
I just tried it with a single-project sbt setup, and the same thing is still there.Seda
F
3

I think the problem with the nested traits is that the inner traits do not even exists outside of an instantiation of the top level trait. This post might be of some help.

Changing the top level Trees to be an Object solved the problem for me. However, I am not sure if this makes sense for your use case.

object Trees {
    trait Tree
    trait IdentifiedTree extends Tree
    trait Empty extends Tree
    ...
}
Fictive answered 31/5, 2015 at 15:39 Comment(4)
Unfortunately this is not much of option, I need path dependent types (hence cake pattern in the tags). But if you look at the Scala compiler API they have the same path dependent types as I do, and still active links: dropbox.com/s/svpseqa37nn1px3/…Seda
I see what you mean. I was wondering if you really need the nested types? You can keep the Trees trait as is (hence supporting the cake pattern you need) and pull the other traits (Tree, IdentifiedTree, etc) outside.Fictive
I wished that was possible, but the nature of the framework that I'm dealing with makes this refactoring hard. Anyways, Scala types are all inner types and still clickable, therefore it should be possible to be done, but I just don't know howSeda
After a bit of research I realized even the Scala API has the same problem at some cases, so I think you deserve the bounty points. Thanks for the answer againSeda

© 2022 - 2024 — McMap. All rights reserved.