Skip to content

Commit

Permalink
automatically reference right scalaVersion in RST
Browse files Browse the repository at this point in the history
using epilog_rst configuration variable in sphinx, which reads
akka-docs/epilog_rst, which is written in sphinx-scala-version task by
SBT, which is referenced by the other docs tasks as a dependency
  • Loading branch information
rkuhn committed Aug 16, 2012
1 parent b9e91d6 commit d41160f
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ multiverse.log
.eprj
.*.swp
akka-docs/_build/
akka-docs/epilog_rst
*.pyc
akka-docs/exts/
_akka_cluster/
Expand Down
4 changes: 4 additions & 0 deletions akka-docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
add_function_parentheses = False
show_authors = True

f = open('epilog_rst', 'U')
rst_epilog = "\n" + f.read()
f.close()

# -- Options for HTML output ---------------------------------------------------

html_theme = 'akka'
Expand Down
6 changes: 4 additions & 2 deletions akka-docs/dev/multi-jvm-testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ You can add it as a plugin by adding the following to your project/plugins.sbt::

You can then add multi-JVM testing to ``project/Build.scala`` by including the ``MultiJvm``
settings and config. For example, here is how the akka-remote project adds
multi-JVM testing::
multi-JVM testing:

.. parsed-literal::
import sbt._
import Keys._
Expand All @@ -47,7 +49,7 @@ multi-JVM testing::
lazy val buildSettings = Defaults.defaultSettings ++ Seq(
organization := "com.typesafe.akka",
version := "2.1-SNAPSHOT",
scalaVersion := "2.10.0-M6",
scalaVersion := "|scalaVersion|",
crossPaths := false
)
Expand Down
4 changes: 2 additions & 2 deletions akka-docs/general/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ when you are uncertain of what configuration is used.
If in doubt, you can also easily and nicely inspect configuration objects
before or after using them to construct an actor system:

.. code-block:: scala
.. parsed-literal::
Welcome to Scala version 2.10.0-M6 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
Welcome to Scala version |scalaVersion| (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
Expand Down
6 changes: 4 additions & 2 deletions akka-docs/intro/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ Summary of the essential parts for using Akka with SBT:

SBT installation instructions on `https://github.com/harrah/xsbt/wiki/Setup <https://github.com/harrah/xsbt/wiki/Setup>`_

``build.sbt`` file::
``build.sbt`` file:

.. parsed-literal::
name := "My Project"
version := "1.0"
scalaVersion := "2.10.0-M6"
scalaVersion := "|scalaVersion|"
resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
Expand Down
2 changes: 1 addition & 1 deletion akka-docs/scala/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ After extracting data from a ``ByteIterator``, the remaining content can also be
.. includecode:: code/akka/docs/io/BinaryCoding.scala
:include: rest-to-seq

with no copying from bytes to rest involved. In general, conversions from ByteString to ByteIterator and vice versa are O(1) for non-chunked ``ByteString``s and (at worst) O(nChunks) for chunked ByteStrings.
with no copying from bytes to rest involved. In general, conversions from ByteString to ByteIterator and vice versa are O(1) for non-chunked ``ByteString`` and (at worst) O(nChunks) for chunked ByteStrings.


Encoding of data also is very natural, using ``ByteStringBuilder``
Expand Down
10 changes: 9 additions & 1 deletion project/Sphinx.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import java.io.File
object Sphinx {
val sphinxDocs = SettingKey[File]("sphinx-docs")
val sphinxTarget = SettingKey[File]("sphinx-target")
val sphinxScalaVersion = TaskKey[String]("sphinx-scala-version")
val sphinxPygmentsDir = SettingKey[File]("sphinx-pygments-dir")
val sphinxTags = SettingKey[Seq[String]]("sphinx-tags")
val sphinxPygments = TaskKey[File]("sphinx-pygments", "Sphinx: install pygments styles")
Expand All @@ -22,6 +23,7 @@ object Sphinx {
lazy val settings = Seq(
sphinxDocs <<= baseDirectory,
sphinxTarget <<= crossTarget / "sphinx",
sphinxScalaVersion <<= scalaVersionTask,
sphinxPygmentsDir <<= sphinxDocs { _ / "_sphinx" / "pygments" },
sphinxTags in sphinxHtml := Seq.empty,
sphinxTags in sphinxLatex := Seq.empty,
Expand All @@ -32,6 +34,12 @@ object Sphinx {
sphinx <<= sphinxTask
)

def scalaVersionTask = (scalaVersion, streams) map { (v, s) =>
s.log.info("writing version file")
IO.write(file("akka-docs/epilog_rst"), ".. |scalaVersion| replace:: " + v + "\n")
v
}

def pygmentsTask = (sphinxDocs, sphinxPygmentsDir, sphinxTarget, streams) map {
(cwd, pygments, baseTarget, s) => {
val target = baseTarget / "site-packages"
Expand All @@ -50,7 +58,7 @@ object Sphinx {
}
target
}
}
} dependsOn sphinxScalaVersion

def buildTask(builder: String, tagsKey: SettingKey[Seq[String]]) = {
(cacheDirectory, sphinxDocs, sphinxTarget, sphinxPygments, tagsKey, streams) map {
Expand Down

0 comments on commit d41160f

Please sign in to comment.