Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalafmt-core 2.7.5 (was 2.6.4) #134

Merged
merged 2 commits into from
Mar 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.6.4
version = 2.7.5
7 changes: 3 additions & 4 deletions src/main/scala/play/doc/FileRepository.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,9 @@ class JarRepository(jarFile: JarFile, base: Option[String] = None) extends FileR
}

def handleFile[A](path: String)(handler: FileHandle => A) = {
getEntry(path).map {
case (entry, is) =>
val handle = FileHandle(entry.getName.split(PathSeparator).last, entry.getSize, is, () => is.close())
handler(handle)
getEntry(path).map { case (entry, is) =>
val handle = FileHandle(entry.getName.split(PathSeparator).last, entry.getSize, is, () => is.close())
handler(handle)
}
}

Expand Down
85 changes: 39 additions & 46 deletions src/test/scala/play/doc/PageIndexSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,33 +17,29 @@ class PageIndexSpec extends Specification {

"provide access to pages" in {
"top level" in {
index.get("Home") must beSome.like {
case page =>
page.page must_== "Home"
page.path must_== Some("example")
page.title must_== "Documentation Home"
index.get("Home") must beSome.like { case page =>
page.page must_== "Home"
page.path must_== Some("example")
page.title must_== "Documentation Home"
}
}
"first level" in {
index.get("Foo") must beSome.like {
case page =>
page.page must_== "Foo"
page.path must_== Some("example/docs")
page.title must_== "Foo Page"
index.get("Foo") must beSome.like { case page =>
page.page must_== "Foo"
page.path must_== Some("example/docs")
page.title must_== "Foo Page"
}
}
"deep" in {
index.get("SubFoo1") must beSome.like {
case page =>
page.page must_== "SubFoo1"
page.path must_== Some("example/docs/sub")
page.title must_== "Sub Foo Page 1"
index.get("SubFoo1") must beSome.like { case page =>
page.page must_== "SubFoo1"
page.path must_== Some("example/docs/sub")
page.title must_== "Sub Foo Page 1"
}
index.get("SubFoo2") must beSome.like {
case page =>
page.page must_== "SubFoo2"
page.path must_== Some("example/docs/sub")
page.title must_== "Sub Foo Page 2"
index.get("SubFoo2") must beSome.like { case page =>
page.page must_== "SubFoo2"
page.path must_== Some("example/docs/sub")
page.title must_== "Sub Foo Page 2"
}
}
"non existent" in {
Expand All @@ -53,42 +49,39 @@ class PageIndexSpec extends Specification {

"provide a table of contents" in {
index.toc.nodes.collectFirst { case ("Home", n) => n } must beSome(TocPage("Home", "Documentation Home", None))
index.toc.nodes.collectFirst { case ("docs", n) => n } must beSome.like {
case toc: Toc =>
toc.title must_== "Sub Documentation"
toc.nodes.collectFirst { case ("Foo", n) => n } must beSome(TocPage("Foo", "Foo Page", Some(List("SubFoo2"))))
toc.nodes.collectFirst { case ("sub", n) => n } must beSome.like {
case toc: Toc =>
toc.title must_== "Sub Section"
toc.nodes.collectFirst { case ("SubFoo1", n) => n } must beSome(
TocPage("SubFoo1", "Sub Foo Page 1", None)
)
toc.nodes.collectFirst { case ("SubFoo2", n) => n } must beSome(
TocPage("SubFoo2", "Sub Foo Page 2", None)
)
}
index.toc.nodes.collectFirst { case ("docs", n) => n } must beSome.like { case toc: Toc =>
toc.title must_== "Sub Documentation"
toc.nodes.collectFirst { case ("Foo", n) => n } must beSome(TocPage("Foo", "Foo Page", Some(List("SubFoo2"))))
toc.nodes.collectFirst { case ("sub", n) => n } must beSome.like { case toc: Toc =>
toc.title must_== "Sub Section"
toc.nodes.collectFirst { case ("SubFoo1", n) => n } must beSome(
TocPage("SubFoo1", "Sub Foo Page 1", None)
)
toc.nodes.collectFirst { case ("SubFoo2", n) => n } must beSome(
TocPage("SubFoo2", "Sub Foo Page 2", None)
)
}
}
}

"provide navigation" in {
index.get("SubFoo1") must beSome.like {
case page =>
page.nav.size must_== 3
page.nav(0).title must_== "Sub Section"
page.nav(1).title must_== "Sub Documentation"
page.nav(2).title must_== "Home"
index.get("SubFoo1") must beSome.like { case page =>
page.nav.size must_== 3
page.nav(0).title must_== "Sub Section"
page.nav(1).title must_== "Sub Documentation"
page.nav(2).title must_== "Home"
}
}

"provide the next page" in {
index.get("Home").flatMap(_.next) must beSome.like {
case toc: Toc => toc.name must_== "docs"
index.get("Home").flatMap(_.next) must beSome.like { case toc: Toc =>
toc.name must_== "docs"
}
index.get("Foo").flatMap(_.next) must beSome.like {
case toc: TocPage => toc.page must_== "SubFoo2"
index.get("Foo").flatMap(_.next) must beSome.like { case toc: TocPage =>
toc.page must_== "SubFoo2"
}
index.get("SubFoo1").flatMap(_.next) must beSome.like {
case toc: TocPage => toc.page must_== "SubFoo2"
index.get("SubFoo1").flatMap(_.next) must beSome.like { case toc: TocPage =>
toc.page must_== "SubFoo2"
}
index.get("SubFoo2").flatMap(_.next) must beNone
}
Expand Down
63 changes: 28 additions & 35 deletions src/test/scala/play/doc/PlayDocSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,42 +59,36 @@ class PlayDocSpec extends Specification {
"old renderer" in {
"render the page and the sidebar" in {
val result = oldRenderer.renderPage("Foo")
result must beSome.like {
case RenderedPage(main, maybeSidebar, path, maybeBreadcrumbs) =>
main must contain("Some markdown")
main must not contain "Sidebar"
maybeSidebar must beSome.like {
case sidebar =>
sidebar must contain("Sidebar")
sidebar must not contain "Some markdown"
}
maybeBreadcrumbs must beSome.like {
case breadcrumbs =>
breadcrumbs must contain("Breadcrumbs")
breadcrumbs must not contain "Some markdown"
}
path must_== "example/docs/Foo.md"
result must beSome.like { case RenderedPage(main, maybeSidebar, path, maybeBreadcrumbs) =>
main must contain("Some markdown")
main must not contain "Sidebar"
maybeSidebar must beSome.like { case sidebar =>
sidebar must contain("Sidebar")
sidebar must not contain "Some markdown"
}
maybeBreadcrumbs must beSome.like { case breadcrumbs =>
breadcrumbs must contain("Breadcrumbs")
breadcrumbs must not contain "Some markdown"
}
path must_== "example/docs/Foo.md"
}
}
}

"new renderer" in {
"render the page and sidebar" in {
val result = renderer.renderPage("Foo")
result must beSome.like {
case RenderedPage(main, maybeSidebar, path, maybeBreadcrumbs) =>
main must contain("Some markdown")
maybeSidebar must beSome.like {
case sidebar =>
sidebar must contain("<a href=\"Home\">Documentation Home</a>")
}
maybeBreadcrumbs must beSome.like {
case breadcrumbs =>
breadcrumbs must contain(
"<a itemprop=\"item\" href=\"Home\"><span itemprop=\"name\" title=\"Home\">Home</span></a>"
)
}
path must_== "example/docs/Foo.md"
result must beSome.like { case RenderedPage(main, maybeSidebar, path, maybeBreadcrumbs) =>
main must contain("Some markdown")
maybeSidebar must beSome.like { case sidebar =>
sidebar must contain("<a href=\"Home\">Documentation Home</a>")
}
maybeBreadcrumbs must beSome.like { case breadcrumbs =>
breadcrumbs must contain(
"<a itemprop=\"item\" href=\"Home\"><span itemprop=\"name\" title=\"Home\">Home</span></a>"
)
}
path must_== "example/docs/Foo.md"
}
}
}
Expand All @@ -121,12 +115,11 @@ class PlayDocSpec extends Specification {

"play table of contents support" should {
"render a table of contents" in {
renderer.renderPage("Home") must beSome.like {
case page =>
page.html must contain("<h2>Sub Documentation</h2>")
page.html must contain("<a href=\"Foo\">Foo Page</a>")
page.html must contain("<a href=\"SubFoo1\">Sub Section</a>")
page.html must contain("<a href=\"SubFoo1\">Sub Foo Page 1</a>")
renderer.renderPage("Home") must beSome.like { case page =>
page.html must contain("<h2>Sub Documentation</h2>")
page.html must contain("<a href=\"Foo\">Foo Page</a>")
page.html must contain("<a href=\"SubFoo1\">Sub Section</a>")
page.html must contain("<a href=\"SubFoo1\">Sub Foo Page 1</a>")
}
}
}
Expand Down