Skip to content

Commit

Permalink
fixed the table of contents which was broken after the sorting of spe…
Browse files Browse the repository at this point in the history
…cifications has changed in the runners.
  • Loading branch information
etorreborre committed Mar 31, 2015
1 parent 1fe1bd6 commit a61175c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 8 additions & 4 deletions guide/src/test/scala/org/specs2/guide/UserGuide.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
14 changes: 9 additions & 5 deletions html/src/main/scala/org/specs2/html/TableOfContents.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]] =
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version in ThisBuild := "3.2"
version in ThisBuild := "3.3.1"

0 comments on commit a61175c

Please sign in to comment.