Skip to content

Commit

Permalink
Upgrade to newer version of sbt-scalariform
Browse files Browse the repository at this point in the history
  • Loading branch information
pvlugter committed Mar 31, 2017
1 parent 3a01b63 commit 77ad9c2
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 37 deletions.
19 changes: 10 additions & 9 deletions core/src/main/scala/com/lightbend/paradox/ParadoxProcessor.scala
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ class ParadoxProcessor(reader: Reader = new Reader, writer: Writer = new Writer)
/**
* Process all mappings to build the site.
*/
def process(mappings: Seq[(File, String)],
leadingBreadcrumbs: List[(String, String)],
outputDirectory: File,
sourceSuffix: String,
targetSuffix: String,
properties: Map[String, String],
navigationDepth: Int,
themeDir: File,
errorListener: STErrorListener): Seq[(File, String)] = {
def process(
mappings: Seq[(File, String)],
leadingBreadcrumbs: List[(String, String)],
outputDirectory: File,
sourceSuffix: String,
targetSuffix: String,
properties: Map[String, String],
navigationDepth: Int,
themeDir: File,
errorListener: STErrorListener): Seq[(File, String)] = {
val pages = parsePages(mappings, Path.replaceSuffix(sourceSuffix, targetSuffix))
val paths = Page.allPaths(pages).toSet
val globalPageMappings = rootPageMappings(pages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ import scala.concurrent.duration._
*/
class Reader(parser: Parser) {

def this(options: Int = Extensions.ALL ^ Extensions.HARDWRAPS /* disable hard wraps, see #31 */ ,
maxParsingTime: Duration = 2.seconds,
parseRunnerProvider: Parser.ParseRunnerProvider = Parser.DefaultParseRunnerProvider,
plugins: PegDownPlugins = PegDownPlugins.NONE) =
def this(
options: Int = Extensions.ALL ^ Extensions.HARDWRAPS /* disable hard wraps, see #31 */ ,
maxParsingTime: Duration = 2.seconds,
parseRunnerProvider: Parser.ParseRunnerProvider = Parser.DefaultParseRunnerProvider,
plugins: PegDownPlugins = PegDownPlugins.NONE) =
this(Parboiled.createParser[ParserWithDirectives, AnyRef](
classOf[ParserWithDirectives],
options: java.lang.Integer,
Expand Down
19 changes: 10 additions & 9 deletions core/src/main/scala/com/lightbend/paradox/markdown/Writer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import scala.collection.JavaConverters._
*/
class Writer(serializer: Writer.Context => ToHtmlSerializer) {

def this(linkRenderer: Writer.Context => LinkRenderer = Writer.defaultLinks,
verbatimSerializers: Map[String, VerbatimSerializer] = Writer.defaultVerbatims,
serializerPlugins: Writer.Context => Seq[ToHtmlSerializerPlugin] = Writer.defaultPlugins) =
def this(
linkRenderer: Writer.Context => LinkRenderer = Writer.defaultLinks,
verbatimSerializers: Map[String, VerbatimSerializer] = Writer.defaultVerbatims,
serializerPlugins: Writer.Context => Seq[ToHtmlSerializerPlugin] = Writer.defaultPlugins) =
this((context: Writer.Context) => new ToHtmlSerializer(
linkRenderer(context),
verbatimSerializers.asJava,
Expand Down Expand Up @@ -86,12 +87,12 @@ object Writer {
* Write context which is passed through to directives.
*/
case class Context(
location: Location[Page],
paths: Set[String],
pageMappings: String => String = Path.replaceExtension(DefaultSourceSuffix, DefaultTargetSuffix),
sourceSuffix: String = DefaultSourceSuffix,
targetSuffix: String = DefaultTargetSuffix,
properties: Map[String, String] = Map.empty)
location: Location[Page],
paths: Set[String],
pageMappings: String => String = Path.replaceExtension(DefaultSourceSuffix, DefaultTargetSuffix),
sourceSuffix: String = DefaultSourceSuffix,
targetSuffix: String = DefaultTargetSuffix,
properties: Map[String, String] = Map.empty)

def defaultLinks(context: Context): LinkRenderer =
new DefaultLinkRenderer(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ class FrontinSpec extends MarkdownBaseSpec {
val second = "second line"

val f1 = new File("f1.md")
writeInFile(f1,
writeInFile(
f1,
"""
|%s
|%s
""" format (first, second))

val f2 = new File("f2.md")
writeInFile(f2,
writeInFile(
f2,
"""
|---
|---
Expand All @@ -39,7 +41,8 @@ class FrontinSpec extends MarkdownBaseSpec {
""" format (first, second))

val f3 = new File("f3.md")
writeInFile(f3,
writeInFile(
f3,
"""
|---
|out: index.html
Expand All @@ -49,7 +52,8 @@ class FrontinSpec extends MarkdownBaseSpec {
""" format (first, second))

val f4 = new File("f4.md")
writeInFile(f4,
writeInFile(
f4,
"""
|---
|out: index.html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class LayoutSpec extends MarkdownBaseSpec {
|#Foo
|some text
"""
)("page.st" -> defaultTemplate,
)(
"page.st" -> defaultTemplate,
"noPageRef.st" -> """
|<div>
|No page ref
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import java.io.File

class PathSpec extends FlatSpec with Matchers {
def provideRelativeMapping: (Map[String, String], String) = {
val mappings = Map("index.md" -> "index.html",
val mappings = Map(
"index.md" -> "index.html",
"a/A.md" -> "a/A.html",
"b/B.md" -> "b/B.html",
"a/a2/A2.md" -> "a/a2/A2.html",
Expand Down Expand Up @@ -88,7 +89,8 @@ class PathSpec extends FlatSpec with Matchers {

"Path.relativeMapping" should "return the correct mapping given the current source file and the global Mappings" in {
val (mappings, sourcePath) = provideRelativeMapping
Path.relativeMapping(sourcePath, mappings) shouldEqual Map("index.md" -> "../../index.html",
Path.relativeMapping(sourcePath, mappings) shouldEqual Map(
"index.md" -> "../../index.html",
"a/A.md" -> "../A.html",
"b/B.md" -> "../../b/B.html",
"a/a2/A2.md" -> "../a2/A2.html",
Expand Down
6 changes: 3 additions & 3 deletions project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import sbt._
import sbt.Keys._
import de.heikoseeberger.sbtheader.{ HeaderPattern, HeaderPlugin, AutomateHeaderPlugin }
import com.typesafe.sbt.SbtScalariform.{ scalariformSettings, ScalariformKeys }
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import scalariform.formatter.preferences._

/**
Expand All @@ -30,15 +30,15 @@ object Common extends AutoPlugin {
override def requires = plugins.JvmPlugin && HeaderPlugin

// AutomateHeaderPlugin is not an allRequirements-AutoPlugin, so explicitly add settings here:
override def projectSettings = scalariformSettings ++ AutomateHeaderPlugin.projectSettings ++ Seq(
override def projectSettings = AutomateHeaderPlugin.projectSettings ++ Seq(
scalacOptions ++= Seq("-encoding", "UTF-8", "-target:jvm-1.6", "-unchecked", "-deprecation", "-feature"),
javacOptions ++= Seq("-encoding", "UTF-8", "-source", "1.6", "-target", "1.6"),
// Scalariform settings
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(AlignSingleLineCaseStatements.MaxArrowIndent, 100)
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(PreserveDanglingCloseParenthesis, true)
.setPreference(DanglingCloseParenthesis, Preserve)
.setPreference(AlignParameters, true),
// Header settings
HeaderPlugin.autoImport.headers := Map(
Expand Down
6 changes: 1 addition & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@
*/

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-scalariform" % "1.3.0")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0")
addSbtPlugin("com.typesafe.tmp" % "sbt-header" % "1.5.0-JDK6-0.1")
addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.0")
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.2.7")

libraryDependencies += "org.scala-sbt" % "scripted-plugin" % sbtVersion.value

// override scalariform version to get some fixes
resolvers += Resolver.typesafeRepo("releases")
libraryDependencies += "org.scalariform" %% "scalariform" % "0.1.5-20140822-69e2e30"

lazy val metaroot = (project in file(".")).
dependsOn(metaThemePlugin)

Expand Down

0 comments on commit 77ad9c2

Please sign in to comment.