Search code examples
scalascaladoc

Link Scala annotation in ScalaDoc


In ScalaDoc I want to have a link to an annotation from a library: discriminator.

My ScalaDoc:

/** Trait must be marked with [[json.schema.discriminator]] annotation. */

But ScalaDoc generation fails with the following error:

Could not find any member to link for "json.schema.discriminator".

UPD: It appeared that errors were because of -Xfatal-warnings scalac option.

Once it got clear I found sbt-api-mappings SBT plugin which resolves all external references with javadoc.io.


Solution

  • You probably don't find it because you don't import the correct package. Please note that the json.schema.discriminator class is part of the "scala-jsonschema-core" package.

    Therefore you need to add to your build.sbt:

    name := "StackOverflow"
    version := "0.1"
    scalaVersion := "2.13.6"
    
    libraryDependencies += "com.github.andyglow" %% "scala-jsonschema-core" % "0.7.6"
    libraryDependencies += "com.github.andyglow" %% "scala-jsonschema-core" % "0.7.6" classifier "javadoc"
    

    Then you can use it the same as you tried:

    /** Trait must be marked with [[json.schema.discriminator]] annotation. */
    

    enter image description here

    Then sbt doc works:

    enter image description here