Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Generating Dash Documentation

Jonathan Ruckwood edited this page Jul 9, 2014 · 4 revisions

Dash is a documentation browser. To create docset files for summingbird and other related twitter repositories, you can run the script below in a temp directory.

#!/bin/sh
exec scala -savecompiled "$0" "$@"
!#
import scala.sys.process._

// run in an temp directory
// you need git, mercurial and sbt
// also had to add this to ~/.sbtconfig to avoid out of memory errors
// SBT_OPTS="-XX:+UseConcMarkSweepGC -XX:+CMSClassUnloadingEnabled -XX:PermSize=1024M -XX:MaxPermSize=1024M -Xmx1024m"

case class Repo(name: String, sbtdoc: String = "unidoc", docpath: String = "target/site/")

val twitterRepos = Set(
  Repo("algebird"),
  Repo("bijection"),
  Repo("chill"),
  Repo("finagle", docpath = "/target/scala-2.9.2/unidoc"),
  Repo("scalding"),
  Repo("scrooge"),
  Repo("storehaus"),
  Repo("summingbird"),
  Repo("tormenta"),
  Repo("util", sbtdoc = "doc", docpath = "target/scala-2.9.2/api")
  )

def installDashTool: ProcessBuilder = {
  val clone = "hg clone https://bitbucket.org/inkytonik/mkscaladocset"
  val make = Process("make", Some(new java.io.File("mkscaladocset")))
  (clone #&& make) #|| "echo mkscaladocset already installed?"
}

installDashTool.!

twitterRepos.map { repo =>

  def cloneOrPull: ProcessBuilder = {
      val clone = "git clone git://github.com/twitter/%s".format(repo.name)
      val pull = Process("git pull", Some(new java.io.File(repo.name)))
      (clone #|| pull)
  }
  def unidoc: ProcessBuilder = Process("./sbt %s".format(repo.sbtdoc), Some(new java.io.File(repo.name)))
  def docSet: ProcessBuilder =  "./mkscaladocset/mkScalaDocset %s %s/%s".format(repo.name, repo.name, repo.docpath)

  (cloneOrPull #&& unidoc #&& docSet #|| "echo DocSet for %s failed".format(repo.name)).!
}