Skip to content

Commit

Permalink
Merge pull request #89 from scala-steward/update/scalafmt-core-2.4.2
Browse files Browse the repository at this point in the history
Update scalafmt-core to 2.4.2
  • Loading branch information
mergify[bot] authored Mar 3, 2020
2 parents be0e1d0 + 836cad1 commit 1382ffe
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ rewrite.rules = [ AvoidInfix, ExpandImportSelectors, RedundantParens, SortModifi
rewrite.sortModifiers.order = [ "private", "protected", "final", "sealed", "abstract", "implicit", "override", "lazy" ]
spaces.inImportCurlyBraces = true # more idiomatic to include whitepsace in import x.{ yyy }
trailingCommas = preserve
version = 2.3.2
version = 2.4.2
8 changes: 2 additions & 6 deletions src/main/scala/play/doc/PageIndex.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class PageIndex(val toc: Toc, path: Option[String] = None) {
toc.nodes.flatMap {
case (_, TocPage(page, title, explicitNext)) =>
val nextLinks = explicitNext
.map { links =>
links.collect(Function.unlift(byNameMap.get))
}
.map { links => links.collect(Function.unlift(byNameMap.get)) }
.getOrElse {
findNext(page, nav).toList
}
Expand Down Expand Up @@ -158,9 +156,7 @@ object PageIndex {
}
}.toMap

val next = parsedParams.get("next").map { n =>
n.split(",").toList
}
val next = parsedParams.get("next").map { n => n.split(",").toList }

val (relPath, descend) = if (link.startsWith("!")) {
link.drop(1) -> false
Expand Down
12 changes: 4 additions & 8 deletions src/main/scala/play/doc/PlayDoc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ class PlayDoc(
// Most files will be accessed multiple times from the same markdown file, no point in opening them many times
// so memoize them. This cache is only per file rendered, so does not need to be thread safe.
val repo = Memoize[String, Option[Seq[String]]] { path =>
codeRepository.loadFile(path) { is =>
IOUtils.readLines(is).asScala.toSeq
}
codeRepository.loadFile(path) { is => IOUtils.readLines(is).asScala.toSeq }
}

def visit(node: Node, visitor: Visitor, printer: Printer) = node match {
Expand Down Expand Up @@ -370,9 +368,7 @@ class PlayDoc(
// Calculate the indent, which is equal to the smallest indent of any line, excluding lines that only consist
// of space characters
val indent = segment
.map { line =>
if (!line.exists(_ != ' ')) None else Some(line.indexWhere(_ != ' '))
}
.map { line => if (!line.exists(_ != ' ')) None else Some(line.indexWhere(_ != ' ')) }
.reduce((i1, i2) =>
(i1, i2) match {
case (None, None) => None
Expand All @@ -394,7 +390,7 @@ class PlayDoc(
this
}
}
val compiledSegment = (segment
val compiledSegment = segment
.foldLeft(State()) { (state, line) =>
state.skip match {
case Some(n) if (n > 1) => state.copy(skip = Some(n - 1))
Expand All @@ -408,7 +404,7 @@ class PlayDoc(
case _ => state.dropIndentAndAppendLine(line)
}
}
})
}
.buffer /* Drop last newline */
.dropRight(1)
.toString()
Expand Down
4 changes: 1 addition & 3 deletions src/main/scala/play/doc/PrettifyVerbatimSerializer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ object PrettifyVerbatimSerializer extends VerbatimSerializer {

val text = node.getText
// print HTML breaks for all initial newlines
text.takeWhile(_ == '\n').foreach { _ =>
printer.print("<br/>")
}
text.takeWhile(_ == '\n').foreach { _ => printer.print("<br/>") }

printer.printEncoded(text.dropWhile(_ == '\n'))
printer.print("</code></pre>");
Expand Down
7 changes: 5 additions & 2 deletions src/test/scala/play/doc/PlayDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ class PlayDocSpec extends Specification {
"allow extracting code snippets" in test("simple", "Snippet")

"allow extracting code snippets using string that exists as substring elsewhere" in test("one", "One")
"allow extracting code snippets using string as full string" in test("onetwothree", "One Two Three") // paired with previous test
"fail on substring code snippets using string as trailing" in failTest("three") // paired with previous test
"allow extracting code snippets using string as full string" in test(
"onetwothree",
"One Two Three"
) // paired with previous test
"fail on substring code snippets using string as trailing" in failTest("three") // paired with previous test

"fail on substring with no full string match" in failTest("leading")
"should match on full string" in test("leading-following", "Leading Following") // paired with test for exception
Expand Down

0 comments on commit 1382ffe

Please sign in to comment.