scala_doc

February 28, 2025 ยท View on GitHub

scala_doc(
    name,
    deps,
)

scala_doc generates Scaladoc for sources for targets, including sources from upstream deps. Readily hostable HTML is written to a name.html output folder.

Scaladoc can be somewhat slow to build. In that case, you can tell Bazel to build this target manually, i.e. only when named explicitly and not through wildcards: tags = ["manual"].

Example

scala_doc(
    name = "scala_docs",
    tags = ["manual"],
    deps = [
        ":target1",
        ":target2",
        ":anothertarget",
    ],
    scalacopts = [
        "-Ypartial-unification",
        "-Ywarn-unused-import",
    ],
)

# Use pkg_tar to tarball up
# https://docs.bazel.build/versions/master/be/pkg.html#pkg_tar
pkg_tar(
    name = "scala_docs_archive",
    srcs = [":scala_docs"],
    extension = "tar.gz",
)

Attributes

Attribute nameDescription
nameName, required
A unique name for this target.
depsList of labels, optional
Labels for which you want to create scaladoc.
scalacoptsList of strings, optional
Extra compiler options for this library to be passed to scalac.