2011-12-09 21:55:49 +13:00
|
|
|
package akka
|
|
|
|
|
|
|
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
|
|
object Rstdoc {
|
|
|
|
|
val rstdocDirectory = SettingKey[File]("rstdoc-directory")
|
|
|
|
|
val rstdocTarget = SettingKey[File]("rstdoc-target")
|
|
|
|
|
val rstdoc = TaskKey[File]("rstdoc", "Build the reStructuredText documentation.")
|
|
|
|
|
|
|
|
|
|
lazy val settings = Seq(
|
|
|
|
|
rstdocDirectory <<= baseDirectory / "akka-docs",
|
|
|
|
|
rstdocTarget <<= crossTarget / "rstdoc",
|
|
|
|
|
rstdoc <<= rstdocTask
|
|
|
|
|
)
|
|
|
|
|
|
2011-12-13 14:40:21 +13:00
|
|
|
def rstdocTask = (cacheDirectory, rstdocDirectory, rstdocTarget, streams) map {
|
|
|
|
|
(cacheDir, dir, target, s) => {
|
|
|
|
|
val cache = cacheDir / "rstdoc"
|
|
|
|
|
val cached = FileFunction.cached(cache)(FilesInfo.hash, FilesInfo.exists) { (in, out) =>
|
|
|
|
|
val changes = in.modified
|
|
|
|
|
if (!changes.isEmpty) {
|
|
|
|
|
s.log.info("Building reStructuredText documentation...")
|
|
|
|
|
changes.foreach(file => s.log.debug("Changed documentation source: " + file))
|
|
|
|
|
val logger = new ProcessLogger {
|
|
|
|
|
def info(o: => String): Unit = s.log.debug(o)
|
|
|
|
|
def error(e: => String): Unit = s.log.debug(e)
|
|
|
|
|
def buffer[T](f: => T): T = f
|
|
|
|
|
}
|
|
|
|
|
val exitCode = Process(List("make", "clean", "html", "pdf"), dir) ! logger
|
|
|
|
|
if (exitCode != 0) sys.error("Failed to build docs.")
|
|
|
|
|
s.log.info("Creating reStructuredText documentation successful.")
|
|
|
|
|
IO.copyDirectory(dir / "_build" / "html", target)
|
|
|
|
|
IO.copyFile(dir / "_build" / "latex" / "Akka.pdf", target / "Akka.pdf")
|
|
|
|
|
target.descendentsExcept("*", "").get.toSet
|
|
|
|
|
} else Set.empty
|
2011-12-09 21:55:49 +13:00
|
|
|
}
|
2011-12-13 14:40:21 +13:00
|
|
|
val toplevel = dir * ("*" - ".*" - "_sphinx" - "_build" - "disabled" - "target")
|
|
|
|
|
val inputs = toplevel.descendentsExcept("*", "").get.toSet
|
|
|
|
|
cached(inputs)
|
2011-12-09 21:55:49 +13:00
|
|
|
target
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|