From a61175c5120b95d53104478511697777bc661ce2 Mon Sep 17 00:00:00 2001 From: Eric Torreborre Date: Tue, 31 Mar 2015 14:49:42 +1100 Subject: [PATCH] fixed the table of contents which was broken after the sorting of specifications has changed in the runners. --- .../specs2/specification/core/SpecStructure.scala | 2 +- .../test/scala/org/specs2/guide/UserGuide.scala | 12 ++++++++---- .../scala/org/specs2/html/TableOfContents.scala | 14 +++++++++----- version.sbt | 2 +- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/core/src/main/scala/org/specs2/specification/core/SpecStructure.scala b/core/src/main/scala/org/specs2/specification/core/SpecStructure.scala index 79ed20472d..5d7d1cd6b8 100644 --- a/core/src/main/scala/org/specs2/specification/core/SpecStructure.scala +++ b/core/src/main/scala/org/specs2/specification/core/SpecStructure.scala @@ -64,7 +64,7 @@ object SpecStructure { def create(header: SpecHeader, arguments: Arguments, fragments: =>Fragments): SpecStructure = new SpecStructure(header, arguments, () => fragments) - def topologicalSort(specifications: Seq[SpecStructure]) = + def topologicalSort(specifications: Seq[SpecStructure]): Option[Vector[SpecStructure]] = TopologicalSort.sort(specifications, dependsOn) /** return true if s1 depends on s2, i.e, s1 has a link to s2 */ diff --git a/guide/src/test/scala/org/specs2/guide/UserGuide.scala b/guide/src/test/scala/org/specs2/guide/UserGuide.scala index 052cd7d8d9..d81faaa44d 100644 --- a/guide/src/test/scala/org/specs2/guide/UserGuide.scala +++ b/guide/src/test/scala/org/specs2/guide/UserGuide.scala @@ -12,13 +12,17 @@ object UserGuide extends UserGuidePage { def is = "User Guide".title ^ s2""" In this user guide, you will find: - ${win}a ${ "quick start guide" ~ QuickStart } - ${win}how to ${"structure your specification" ~ Structure} - ${win}how to use ${"matchers" ~ Matchers } - ${win}how to ${"execute a specification" ~ Runners } + ${win}a ${ "quick start guide" ~/ QuickStart } + ${win}how to ${"structure your specification" ~/ Structure} + ${win}how to use ${"matchers" ~/ Matchers } + ${win}how to ${"execute a specification" ~/ Runners } And much more! + ${link(QuickStart).hide} + ${link(Structure).hide} + ${link(Matchers).hide} + ${link(Runners).hide} ${link(Contexts).hide} ${link(UseScalaCheck).hide} ${link(UseMockito).hide} diff --git a/html/src/main/scala/org/specs2/html/TableOfContents.scala b/html/src/main/scala/org/specs2/html/TableOfContents.scala index 4b203f6d73..5d4d540885 100644 --- a/html/src/main/scala/org/specs2/html/TableOfContents.scala +++ b/html/src/main/scala/org/specs2/html/TableOfContents.scala @@ -18,11 +18,15 @@ import text.Trim._ trait TableOfContents { /** create a table of contents for all the specifications */ - def createToc(specifications: List[SpecStructure], outDir: DirectoryPath, entryMaxSize: Int, fileSystem: FileSystem): Action[Unit] = for { - pages <- readHtmlPages(specifications, outDir, fileSystem) - toc = createToc(pages, outDir, entryMaxSize) - _ <- saveHtmlPages(pages.map(page => page.addToc(toc(page))), fileSystem) - } yield () + def createToc(specifications: List[SpecStructure], outDir: DirectoryPath, entryMaxSize: Int, fileSystem: FileSystem): Action[Unit] = { + // sort specifications a, b, c so that a depends on b and c + val sorted = SpecStructure.topologicalSort(specifications).map(_.toList).getOrElse(List()) + for { + pages <- readHtmlPages(sorted, outDir, fileSystem) + toc = createToc(pages, outDir, entryMaxSize) + _ <- saveHtmlPages(pages.map(page => page.addToc(toc(page))), fileSystem) + } yield () + } /** read the generated html pages and return them as a tree, based on the links relationships between them */ def readHtmlPages(specifications: List[SpecStructure], outDir: DirectoryPath, fileSystem: FileSystem): Action[List[SpecHtmlPage]] = diff --git a/version.sbt b/version.sbt index e27923e8d9..fe55552f01 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "3.2" \ No newline at end of file +version in ThisBuild := "3.3.1" \ No newline at end of file