Skip to content

Commit

Permalink
Merge pull request #24 from laughedelic/24/update
Browse files Browse the repository at this point in the history
Update the build
  • Loading branch information
laughedelic authored Oct 15, 2017
2 parents afa9c24 + 3b2d033 commit d1ad0bb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 35 deletions.
24 changes: 10 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
Nice.scalaProject

name := "literator"
description := "An sbt plugin which converts sources to markdown"
name := "literator"
description := "An sbt plugin which converts sources to markdown"
organization := "laughedelic"

sbtPlugin := true
scalaVersion := "2.10.5"
publishBucketSuffix := "era7.com"
sbtVersion := "0.13.16"
scalaVersion := "2.10.6"

libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.4" % Test
)

libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.5" % Test
bintrayReleaseOnPublish := !isSnapshot.value
bintrayPackageLabels := Seq("sbt", "sbt-plugin", "documentation", "literate-programming")

// disablePlugins(BintrayPlugin)
bintrayRepository in bintray := "sbt-plugins"
bintrayOrganization in bintray := None
publishMavenStyle := false
publishTo := (publishTo in bintray).value


// this is covered by the test
generateDocs := {}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.12
sbt.version = 1.0.2
14 changes: 5 additions & 9 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
resolvers ++= Seq(
"Era7 maven releases" at "https://s3-eu-west-1.amazonaws.com/releases.era7.com",
"Era7 maven snapshots" at "https://s3-eu-west-1.amazonaws.com/snapshots.era7.com"
)
resolvers += Resolver.jcenterRepo
resolvers += "Github-API" at "http://repo.jenkins-ci.org/public/"
resolvers += "Era7 maven releases" at "https://s3-eu-west-1.amazonaws.com/releases.era7.com"

addSbtPlugin("ohnosequences" % "nice-sbt-settings" % "0.6.0")
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
addSbtPlugin("ohnosequences" % "nice-sbt-settings" % "0.9.0")


// itself for testing:
// addSbtPlugin("laughedelic" % "literator-plugin" % "0.7.0-SNAPSHOT")
addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")
14 changes: 8 additions & 6 deletions src/main/scala/lib/FileUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ case class FileNode(f: File, t: List[FileNode]) {
import FileUtils._

def link(base: File): String =
if (f.isSource) "["+f.name+"]["+f.relativePath(base)+"]"
if (f.isSource) s"[${f.name}][${f.relativePath(base)}]"
else f.name

def listTree(base: File): List[String] = {
("+ " + link(base)) ::
t.flatMap{ i: FileNode => i.listTree(base).map{ s: String => " " + s } }
s"+ ${link(base)}" ::
t.flatMap { i: FileNode =>
i.listTree(base).map { str => s" ${str}" }
}
}

override def toString: String = listTree(f).mkString("\n")
Expand All @@ -33,7 +35,7 @@ object FileUtils {

/* Returning path of `file` relatively to `base` */
def relativePath(base: File): Path = {
val b = if (base.isDirectory) base.getCanonicalFile
val b = if (base.isDirectory) base.getCanonicalFile
else base.getCanonicalFile.getParentFile
b.toPath.relativize(file.getCanonicalFile.toPath)
}
Expand All @@ -50,8 +52,8 @@ object FileUtils {
/* Traversing recursively and building file hierarchy tree */
def getFileTree(filter: (File => Boolean) = (_ => true)): Option[FileNode] =
if (!filter(file)) None
else Some(FileNode(file,
if (file.isDirectory) file.listFiles.toList.map(_.getFileTree(filter)).flatten
else Some(FileNode(file,
if (file.isDirectory) file.listFiles.toList.map(_.getFileTree(filter)).flatten
else List()
))

Expand Down
8 changes: 4 additions & 4 deletions src/main/scala/plugin/LiteratorPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ object LiteratorPlugin extends AutoPlugin {
docsOutputDirs := docsMap.value.values.toSeq,
docsAddIndex := false,
docsCleanBefore := true,
generateDocs := {
generateDocs := {
val s: TaskStreams = streams.value
docsMap.value map { case (in, out) =>
s.log.info("Generating documentation for " + in)
s.log.info(s"Generating documentation for ${in}")

if(docsCleanBefore.value && out.exists) {
s.log.info("Cleaning up output directory " + out)
s.log.info(s"Cleaning up output directory ${out}")
Defaults.doClean(Seq(out), Seq())
}

val errors = in.literate(Some(out), withIndex = docsAddIndex.value)
errors foreach { s.log.error(_) }

if (errors.nonEmpty) sys.error("Couldn't generate documentation due to parsing errors")
else s.log.info("Documentation is written to " + out)
else s.log.info(s"Documentation is written to ${out}")
}
}
)
Expand Down
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit d1ad0bb

Please sign in to comment.