From f725dd6c65f60f5d0f637354df0f815df2d0ced1 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Fri, 16 Aug 2013 14:22:46 -0400 Subject: [PATCH] Docs: pass build values to sphinx/conf.py via environment variables to reduce duplication. --- project/Docs.scala | 18 ++++++++++++++++++ project/p.sbt | 2 +- src/sphinx/conf.py | 10 +++++----- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/project/Docs.scala b/project/Docs.scala index 459af3d13..dfede58d4 100644 --- a/project/Docs.scala +++ b/project/Docs.scala @@ -27,6 +27,7 @@ object Docs // siteIncludeSxr("sxr") ++ ghPagesSettings ++ Seq( + SphinxSupport.sphinxEnv in SphinxSupport.Sphinx <<= sphinxEnvironmentVariables, SphinxSupport.sphinxIncremental in SphinxSupport.Sphinx := true, // TODO: set to true with newer sphinx plugin release SphinxSupport.enableOutput in SphinxSupport.generatePdf := false @@ -44,6 +45,23 @@ object Docs site.addMappingsToSiteDir(mappings in sxr, prefix) ) + def sphinxEnvironmentVariables = (scalaVersion, version) map { (scalaV, sbtV) => + // major.minor + def release(v: String): String = CrossVersion.partialVersion(v) match { + case Some((major,minor)) => major + "." + minor + case None => v + } + Map[String,String]( + "sbt.full.version" -> sbtV, + "sbt.partial.version" -> release(sbtV), + "sbt.site.version" -> sbtV.takeWhile(_ != '-'), + "sbt.binary.version" -> CrossVersion.binarySbtVersion(sbtV), + "scala.full.version" -> scalaV, + "scala.partial.version" -> release(scalaV), + "scala.binary.version" -> CrossVersion.binaryScalaVersion(scalaV) + ) + } + def synchLocalImpl = (ghkeys.privateMappings, ghkeys.updatedRepository, version, isSnapshot, streams, cnameFile) map { (mappings, repo, v, snap, s, cname) => val versioned = repo / v if(snap) diff --git a/project/p.sbt b/project/p.sbt index f2bd8b90e..516f53f93 100644 --- a/project/p.sbt +++ b/project/p.sbt @@ -3,7 +3,7 @@ libraryDependencies ++= Seq( "org.jsoup" % "jsoup" % "1.7.1" ) -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.7.1") resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven" diff --git a/src/sphinx/conf.py b/src/sphinx/conf.py index 4e465afc9..293080816 100644 --- a/src/sphinx/conf.py +++ b/src/sphinx/conf.py @@ -8,11 +8,11 @@ extensions = ['sphinxcontrib.issuetracker', 'sphinx.ext.extlinks', 'howto', 'cod # Project variables project = 'sbt' -version = '0.13' -site_version = '0.13.0' -release = "0.13.0-SNAPSHOT" -scalaVersion = "2.10" -scalaRelease = "2.10.2" +version = os.environ['sbt.partial.version'] +site_version = os.environ['sbt.site.version'] +release = os.environ['sbt.full.version'] +scalaVersion = os.environ['scala.binary.version'] +scalaRelease = os.environ['scala.full.version'] # General settings