Skip to content

Instantly share code, notes, and snippets.

@jodersky
Created March 6, 2021 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jodersky/5526fac8dc0251b446835fdb6b759581 to your computer and use it in GitHub Desktop.
Save jodersky/5526fac8dc0251b446835fdb6b759581 to your computer and use it in GitHub Desktop.
Combining scaladoc from multiple sources in mill
// This module isn't really a ScalaModule, but we use it to generate
// consolidated documentation using the Scaladoc tool.
object docs extends ScalaModule {
def scalaVersion = "3.0.0-M3"
def docSource = T.source(millSourcePath)
def moduleDeps = Seq(
...
)
// generate the static website
def site = T {
import mill.eval.Result
for {
child <- os.walk(docSource().path)
if os.isFile(child)
} {
os.copy.over(child, T.dest / child.subRelativeTo(docSource().path), createFolders = true)
}
val files: Seq[os.Path] = T.traverse(moduleDeps)(_.allSourceFiles)().flatten.map(_.path)
// format: off
val options = Seq(
"-classpath", compileClasspath().map(_.path).mkString(":"),
"-siteroot", T.dest.toString,
"-project-url", "<url>",
"-project-logo", "logo.svg",
"-project-version", "<version>",
"-project", "<name>"
) ++ scalaDocPluginClasspath().map(pluginPathRef => s"-Xplugin:${pluginPathRef.path}")
// format: on
zincWorker.worker().docJar(
scalaVersion(),
scalaOrganization(),
scalaDocClasspath().map(_.path),
scalacPluginClasspath().map(_.path),
files.map(_.toString) ++ options
) match{
case true =>
Result.Success(PathRef(T.dest / "_site"))
case false =>
Result.Failure("doc generation failed")
}
}
// preview the site locally
def serve() = T.command{
os.proc("python3", "-m", "http.server", "--directory", site().path).call()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment