aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Vogt <oss.nsp@cvogt.org>2017-04-02 15:08:27 -0400
committerChristopher Vogt <oss.nsp@cvogt.org>2017-04-02 15:11:10 -0400
commitd7d924c50758aa190762672723d2b708b18911ba (patch)
tree009c1762f99586936870e306d584af253498d422
parenta40300405524c0b4f8bf5959ec06e3fe1e93837f (diff)
downloadcbt-d7d924c50758aa190762672723d2b708b18911ba.tar.gz
cbt-d7d924c50758aa190762672723d2b708b18911ba.tar.bz2
cbt-d7d924c50758aa190762672723d2b708b18911ba.zip
Add Tut plugin
-rw-r--r--build/build.scala1
-rw-r--r--examples/tut/Readme.md1
-rw-r--r--examples/tut/build/build.scala3
-rw-r--r--examples/tut/tut/example.md7
-rw-r--r--stage2/plugins/Tut.scala38
5 files changed, 50 insertions, 0 deletions
diff --git a/build/build.scala b/build/build.scala
index cf2527a..4635159 100644
--- a/build/build.scala
+++ b/build/build.scala
@@ -26,6 +26,7 @@ class Build(val context: Context) extends Shared with Scalariform with PublishLo
context.cbtHome / "stage2" / "LazyDependency.scala",
context.cbtHome / "stage2" / "plugins" / "ScalaTest.scala",
context.cbtHome / "stage2" / "plugins" / "Scalatex.scala",
+ context.cbtHome / "stage2" / "plugins" / "Tut.scala",
context.cbtHome / "stage2" / "libraries.scala",
context.cbtHome / "stage2" / "plugins.scala",
context.cbtHome / "stage2" / "ports.scala"
diff --git a/examples/tut/Readme.md b/examples/tut/Readme.md
new file mode 100644
index 0000000..27568f0
--- /dev/null
+++ b/examples/tut/Readme.md
@@ -0,0 +1 @@
+Tut files need to be in tut/. Generated files go to target/tut/. \ No newline at end of file
diff --git a/examples/tut/build/build.scala b/examples/tut/build/build.scala
new file mode 100644
index 0000000..b9d00c2
--- /dev/null
+++ b/examples/tut/build/build.scala
@@ -0,0 +1,3 @@
+package tut_build
+import cbt._
+class Build(val context: Context) extends Tut
diff --git a/examples/tut/tut/example.md b/examples/tut/tut/example.md
new file mode 100644
index 0000000..55fa85b
--- /dev/null
+++ b/examples/tut/tut/example.md
@@ -0,0 +1,7 @@
+
+This is a tut doc.
+
+```tut
+1 + 1
+```
+
diff --git a/stage2/plugins/Tut.scala b/stage2/plugins/Tut.scala
new file mode 100644
index 0000000..f2fee14
--- /dev/null
+++ b/stage2/plugins/Tut.scala
@@ -0,0 +1,38 @@
+package cbt
+trait Tut extends BaseBuild {
+ def tut = Tut.apply( lib, context.cbtLastModified, context.paths.mavenCache, scalaMajorVersion ).config(
+ projectDirectory / "tut", target / "tut", classpath, scalacOptions
+ )
+}
+
+import java.io.File
+object Tut {
+ case class apply(
+ lib: Lib, cbtLastModified: Long, mavenCache: File, scalaMajorVersion: String
+ )(
+ implicit
+ logger: Logger, transientCache: java.util.Map[AnyRef, AnyRef], classLoaderCache: ClassLoaderCache
+ ) {
+ case class config(
+ sourceDirectory: File,
+ targetDirectory: File,
+ classpath: ClassPath,
+ scalacOptions: Seq[String],
+ fileExtensionRegex: String = """.*\.(md|txt|htm|html)""",
+ version: String = "0.4.8"
+ ) {
+ def apply =
+ lib.redirectOutToErr {
+ tut( version ).runMain(
+ "tut.TutMain",
+ Seq(
+ sourceDirectory.string, targetDirectory.string, fileExtensionRegex, "-cp", classpath.string
+ ) ++ scalacOptions
+ )
+ }
+ }
+ def tut( version: String ) = MavenResolver( cbtLastModified, mavenCache, bintray( "tpolecat" ), mavenCentral ).bindOne(
+ MavenDependency( "org.tpolecat", "tut-core_" ~ scalaMajorVersion, version )
+ )
+ }
+}