Skip to content

Commit 6960141

Browse files
author
Helena Edelson
committed
Upgrade Paradox (to 0.5.5), Scala (to 2.12.8) and SBT (to 1.2.8) and travis to use scala 2.12.8 #34
1 parent 33c524b commit 6960141

File tree

6 files changed

+67
-59
lines changed

6 files changed

+67
-59
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: scala
22
jdk: oraclejdk8
3-
scala: 2.12.4
3+
scala: 2.12.8
44

55
jobs:
66
include:

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
scalaVersion := "2.12.7"
1+
scalaVersion := "2.12.8"
22

33
sbtPlugin := true
44
crossSbtVersions := List("1.0.0")

project/Dependencies.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import sbt._
33
object Version {
44
val classgraph = "4.8.41"
55
val jtidy = "r938"
6-
val sbtParadox = "0.4.3"
6+
val sbtParadox = "0.5.5"
77
val scalatest = "3.0.8"
88
}
99

project/build.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=1.2.6
1+
sbt.version=1.2.8

src/test/scala/com.lightbend.paradox/apidoc/ApidocDirectiveSpec.scala

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
4949
)
5050

5151
override val markdownWriter = new Writer(
52-
linkRenderer = Writer.defaultLinks,
52+
linkRenderer = Writer.defaultLinks,
5353
verbatimSerializers = Writer.defaultVerbatims,
5454
serializerPlugins = Writer.defaultPlugins(
5555
Writer.defaultDirectives ++ Seq(
@@ -81,7 +81,6 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
8181
"No matches found for ThereIsNoSuchClass"
8282
}
8383

84-
8584
it should "generate markdown correctly when 2 matches found and their package names include javadsl/scaladsl" in {
8685
markdown("@apidoc[Flow]") shouldEqual
8786
html(
@@ -130,12 +129,12 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
130129

131130
it should "find a class by partiql fqdn" in {
132131
markdown("@apidoc[actor.typed.ActorRef]") shouldEqual
133-
html(
134-
"""<p><span class="group-scala">
135-
|<a href="https://doc.akka.io/api/akka/2.5/akka/actor/typed/ActorRef.html">ActorRef</a></span><span class="group-java">
136-
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/actor/typed/ActorRef.html">ActorRef</a></span>
137-
|</p>""".stripMargin
138-
)
132+
html(
133+
"""<p><span class="group-scala">
134+
|<a href="https://doc.akka.io/api/akka/2.5/akka/actor/typed/ActorRef.html">ActorRef</a></span><span class="group-java">
135+
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/actor/typed/ActorRef.html">ActorRef</a></span>
136+
|</p>""".stripMargin
137+
)
139138
}
140139

141140
it should "generate markdown correctly for a companion object" in {

src/test/scala/com.lightbend.paradox/apidoc/MarkdownBaseSpec.scala

Lines changed: 56 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -30,37 +30,45 @@ abstract class MarkdownBaseSpec extends FlatSpec with Matchers {
3030
val markdownReader = new Reader
3131
val markdownWriter = new Writer
3232

33-
def markdown(text: String)(implicit context: Location[Page] => Writer.Context = writerContext): String = {
33+
def markdown(text: String)(implicit context: Location[Page] => Writer.Context = writerContext): String =
3434
markdownPages("test.md" -> text).getOrElse("test.html", "")
35-
}
3635

37-
def markdownPages(mappings: (String, String)*)(implicit context: Location[Page] => Writer.Context = writerContext): Map[String, String] = {
38-
def render(location: Option[Location[Page]], rendered: Seq[(String, String)] = Seq.empty): Seq[(String, String)] = location match {
39-
case Some(loc) =>
40-
val page = loc.tree.label
41-
val html = normalize(markdownWriter.write(page.markdown, context(loc)))
42-
render(loc.next, rendered :+ (page.path, html))
43-
case None => rendered
44-
}
36+
def markdownPages(mappings: (String, String)*)(
37+
implicit context: Location[Page] => Writer.Context = writerContext): Map[String, String] = {
38+
def render(location: Option[Location[Page]], rendered: Seq[(String, String)] = Seq.empty): Seq[(String, String)] =
39+
location match {
40+
case Some(loc) =>
41+
val page = loc.tree.label
42+
val html = normalize(markdownWriter.write(page.markdown, context(loc)))
43+
render(loc.next, rendered :+ (page.path, html))
44+
case None => rendered
45+
}
4546
render(Location.forest(pages(mappings: _*))).toMap
4647
}
4748

48-
def layoutPages(mappings: (String, String)*)(templates: (String, String)*)(implicit context: Location[Page] => Writer.Context = writerContext): Map[String, String] = {
49+
def layoutPages(mappings: (String, String)*)(templates: (String, String)*)(
50+
implicit context: Location[Page] => Writer.Context = writerContext): Map[String, String] = {
4951
val templateDirectory = Files.createTempDirectory("templates")
5052
createFileTemplates(templateDirectory, templates)
51-
def render(location: Option[Location[Page]], rendered: Seq[(String, String)] = Seq.empty): Seq[(String, String)] = location match {
52-
case Some(loc) =>
53-
val page = loc.tree.label
54-
val html = normalize(markdownWriter.write(page.markdown, context(loc)))
55-
val outputFile = new File(page.path)
56-
val emptyPageContext = PartialPageContent(page.properties.get, html)
57-
val template = new PageTemplate(new File(templateDirectory.toString))
58-
template.write(page.properties(Page.Properties.DefaultLayoutMdIndicator, template.defaultName), emptyPageContext, outputFile, new PageTemplate.ErrorLogger(s => println("[error] " + s)))
59-
val fileContent = fileToContent(outputFile)
60-
outputFile.delete
61-
render(loc.next, rendered :+ (page.path, normalize(fileContent)))
62-
case None => rendered
63-
}
53+
def render(location: Option[Location[Page]], rendered: Seq[(String, String)] = Seq.empty): Seq[(String, String)] =
54+
location match {
55+
case Some(loc) =>
56+
val page = loc.tree.label
57+
val html = normalize(markdownWriter.write(page.markdown, context(loc)))
58+
val outputFile = new File(page.path)
59+
val emptyPageContext = PartialPageContent(page.properties.get, html)
60+
val template = new PageTemplate(new File(templateDirectory.toString))
61+
template.write(
62+
page.properties(Page.Properties.DefaultLayoutMdIndicator, template.defaultName),
63+
emptyPageContext,
64+
outputFile,
65+
new PageTemplate.ErrorLogger(s => println("[error] " + s))
66+
)
67+
val fileContent = fileToContent(outputFile)
68+
outputFile.delete
69+
render(loc.next, rendered :+ (page.path, normalize(fileContent)))
70+
case None => rendered
71+
}
6472
render(Location.forest(pages(mappings: _*))).toMap
6573
}
6674

@@ -83,40 +91,41 @@ abstract class MarkdownBaseSpec extends FlatSpec with Matchers {
8391
writerContext(location).copy(properties = properties.toMap)
8492
}
8593

86-
def writerContext(location: Location[Page]): Writer.Context = {
94+
def writerContext(location: Location[Page]): Writer.Context =
8795
Writer.Context(
8896
location,
8997
Page.allPaths(List(location.root.tree)).toSet,
98+
reader = new Reader,
99+
writer = new Writer,
90100
groups = Map("Language" -> Seq("Scala", "Java"))
91101
)
92-
}
93102

94-
def pages(mappings: (String, String)*): Forest[Page] = {
103+
def pages(mappings: (String, String)*): Forest[Page] =
104+
pagesWithProperties(Map.empty[String, String], mappings: _*)
105+
106+
def pagesWithProperties(properties: Map[String, String], mappings: (String, String)*): Forest[Page] = {
95107
import com.lightbend.paradox.markdown.Path
96108
val parsed = mappings map {
97109
case (path, text) =>
98110
val frontin = Frontin(prepare(text))
99111
(new File(path), path, markdownReader.read(frontin.body), frontin.header)
100112
}
101-
Page.forest(parsed, Path.replaceSuffix(Writer.DefaultSourceSuffix, Writer.DefaultTargetSuffix))
113+
Page.forest(parsed, Path.replaceSuffix(Writer.DefaultSourceSuffix, Writer.DefaultTargetSuffix), properties)
102114
}
103115

104-
def html(text: String): String = {
116+
def html(text: String): String =
105117
normalize(prepare(text))
106-
}
107118

108-
def htmlPages(mappings: (String, String)*): Map[String, String] = {
119+
def htmlPages(mappings: (String, String)*): Map[String, String] =
109120
(mappings map { case (path, text) => (path, html(text)) }).toMap
110-
}
111121

112-
def prepare(text: String): String = {
122+
def prepare(text: String): String =
113123
text.stripMargin.trim
114-
}
115124

116125
def normalize(html: String) = {
117126
val reader = new java.io.StringReader(html)
118127
val writer = new java.io.StringWriter
119-
val tidy = new org.w3c.tidy.Tidy
128+
val tidy = new org.w3c.tidy.Tidy
120129
tidy.setTabsize(2)
121130
tidy.setPrintBodyOnly(true)
122131
tidy.setTrimEmptyElements(false)
@@ -129,26 +138,26 @@ abstract class MarkdownBaseSpec extends FlatSpec with Matchers {
129138
case class PartialPageContent(properties: Map[String, String], content: String) extends PageTemplate.Contents {
130139
import scala.collection.JavaConverters._
131140

132-
val getTitle = ""
141+
val getTitle = ""
133142
val getContent = content
134143

135-
lazy val getBase = ""
136-
lazy val getHome = new EmptyLink()
137-
lazy val getPrev = new EmptyLink()
138-
lazy val getNext = new EmptyLink()
144+
lazy val getBase = ""
145+
lazy val getHome = new EmptyLink()
146+
lazy val getPrev = new EmptyLink()
147+
lazy val getNext = new EmptyLink()
139148
lazy val getBreadcrumbs = ""
140-
lazy val getNavigation = ""
141-
lazy val hasSubheaders = false
142-
lazy val getToc = ""
143-
lazy val getSource_url = ""
149+
lazy val getNavigation = ""
150+
lazy val hasSubheaders = false
151+
lazy val getToc = ""
152+
lazy val getSource_url = ""
144153

145154
lazy val getProperties = properties.asJava
146155
}
147156

148157
case class EmptyLink() extends PageTemplate.Link {
149-
lazy val getHref: String = ""
150-
lazy val getHtml: String = ""
151-
lazy val getTitle: String = ""
158+
lazy val getHref: String = ""
159+
lazy val getHtml: String = ""
160+
lazy val getTitle: String = ""
152161
lazy val isActive: Boolean = false
153162
}
154163

0 commit comments

Comments
 (0)