Skip to content

Commit

Permalink
Adapt to Paradox to use code-tag (#71)
Browse files Browse the repository at this point in the history
* Don't use `TextNode` to adapt to Paradox 0.6.6
* Update to Paradox 0.6.6
See lightbend/paradox#378
  • Loading branch information
ennru authored Oct 9, 2019
1 parent b82696f commit 2b37b76
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 46 deletions.
15 changes: 4 additions & 11 deletions project/Dependencies.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import sbt._

object Version {
val classgraph = "4.8.47"
val jtidy = "r938"
val sbtParadox = "0.6.5"
val scalatest = "3.0.8"
}

object Library {
val classgraph = "io.github.classgraph" % "classgraph" % Version.classgraph
val jtidy = "net.sf.jtidy" % "jtidy" % Version.jtidy
val sbtParadox = "com.lightbend.paradox" % "sbt-paradox" % Version.sbtParadox
val scalatest = "org.scalatest" %% "scalatest" % Version.scalatest
val classgraph = "io.github.classgraph" % "classgraph" % "4.8.47"
val jtidy = "net.sf.jtidy" % "jtidy" % "r938"
val sbtParadox = "com.lightbend.paradox" % "sbt-paradox" % "0.6.6"
val scalatest = "org.scalatest" %% "scalatest" % "3.0.8"
}
23 changes: 14 additions & 9 deletions src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package com.lightbend.paradox.apidoc

import com.lightbend.paradox.markdown.InlineDirective
import org.pegdown.Printer
import org.pegdown.ast.{DirectiveNode, TextNode, Visitor}
import org.pegdown.ast.{DirectiveNode, Visitor}

class ApidocDirective(allClassesAndObjects: IndexedSeq[String], properties: Map[String, String])
extends InlineDirective("apidoc") {
Expand All @@ -35,8 +35,8 @@ class ApidocDirective(allClassesAndObjects: IndexedSeq[String], properties: Map[
matched.split('.').last + generics
def javaLabel(matched: String): String =
scalaLabel(matched)
.replaceAll("\\[", "<")
.replaceAll("\\]", ">")
.replaceAll("\\[", "<")
.replaceAll("\\]", ">")
.replaceAll("_", "?")

override def toString =
Expand Down Expand Up @@ -80,9 +80,14 @@ class ApidocDirective(allClassesAndObjects: IndexedSeq[String], properties: Map[
}
}

def syntheticNode(group: String, doctype: String, label: String, fqcn: String, node: DirectiveNode): DirectiveNode = {
val syntheticSource = new DirectiveNode.Source.Direct(fqcn)
val attributes = new org.pegdown.ast.DirectiveAttributes.AttributeMap()
private def syntheticNode(
group: String,
doctype: String,
label: String,
fqcn: String,
node: DirectiveNode
): DirectiveNode = {
val attributes = new org.pegdown.ast.DirectiveAttributes.AttributeMap()
new DirectiveNode(
DirectiveNode.Format.Inline,
group,
Expand All @@ -94,10 +99,10 @@ class ApidocDirective(allClassesAndObjects: IndexedSeq[String], properties: Map[
DirectiveNode.Format.Inline,
doctype + "doc",
label,
syntheticSource,
new DirectiveNode.Source.Direct(fqcn),
node.attributes,
fqcn,
new TextNode(label)
label, // contents
null
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/apidoc/multi-project/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ val docs = project
"scaladoc.apidoc.base_url" -> "https://localhost:8000",
"javadoc.apidoc.base_url" -> "https://localhost:8000"
),
apidocRootPackage := ""
apidocRootPackage := "apidoc"
)

val root = project
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/apidoc/multi-project/expected/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Api link to sub-project <span class="group-scala"><a href="https://localhost:8000/apidoc/LibClass.html">LibClass</a></span><span class="group-java"><a href="https://localhost:8000/?apidoc/LibClass.html">LibClass</a></span></p>
<p>Api link to sub-project <span class="group-scala"><a href="https://localhost:8000/apidoc/LibClass.html" title="apidoc.LibClass"><code>LibClass</code></a></span><span class="group-java"><a href="https://localhost:8000/?apidoc/LibClass.html" title="apidoc.LibClass"><code>LibClass</code></a></span></p>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<p>Api link to a class that is both in scaladsl and javadsl packages, but has no javadoc configured: <span class="group-java"><a href="akka-stream-scaladoc/akka/stream/javadsl/Flow.html">Flow</a></span><span class="group-scala"><a href="akka-stream-scaladoc/akka/stream/scaladsl/Flow.html">Flow</a></span></p>
<p>Api link to a class that is in common package, but has no javadoc configured <span class="group-scala"><a href="akka-stream-scaladoc/akka/stream/stage/GraphStage.html">GraphStage</a></span><span class="group-java"><a href="akka-stream-scaladoc/akka/stream/stage/GraphStage.html">GraphStage</a></span></p>
<p>Api link to a class that is both in scaladsl and javadsl packages, and has javadoc configured: <span class="group-java"><a href="akka-javadoc/?akka/actor/typed/javadsl/Behaviors.html">Behaviors</a></span><span class="group-scala"><a href="akka-scaladoc/akka/actor/typed/scaladsl/Behaviors.html">Behaviors</a></span></p>
<p>Api link to a class that is both in scaladsl and javadsl packages, but has no javadoc configured: <span class="group-java"><a href="akka-stream-scaladoc/akka/stream/javadsl/Flow.html" title="akka.stream.javadsl.Flow"><code>Flow</code></a></span><span class="group-scala"><a href="akka-stream-scaladoc/akka/stream/scaladsl/Flow.html" title="akka.stream.scaladsl.Flow"><code>Flow</code></a></span></p>
<p>Api link to a class that is in common package, but has no javadoc configured <span class="group-scala"><a href="akka-stream-scaladoc/akka/stream/stage/GraphStage.html" title="akka.stream.stage.GraphStage"><code>GraphStage</code></a></span><span class="group-java"><a href="akka-stream-scaladoc/akka/stream/stage/GraphStage.html" title="akka.stream.stage.GraphStage"><code>GraphStage</code></a></span></p>
<p>Api link to a class that is both in scaladsl and javadsl packages, and has javadoc configured: <span class="group-java"><a href="akka-javadoc/?akka/actor/typed/javadsl/Behaviors.html" title="akka.actor.typed.javadsl.Behaviors"><code>Behaviors</code></a></span><span class="group-scala"><a href="akka-scaladoc/akka/actor/typed/scaladsl/Behaviors.html" title="akka.actor.typed.scaladsl.Behaviors"><code>Behaviors</code></a></span></p>
2 changes: 1 addition & 1 deletion src/sbt-test/apidoc/single-project/expected/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<p>Api link to Akka <span class="group-java"><a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Flow.html">Flow</a></span><span class="group-scala"><a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Flow.html">Flow</a></span></p>
<p>Api link to Akka <span class="group-java"><a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Flow.html" title="akka.stream.javadsl.Flow"><code>Flow</code></a></span><span class="group-scala"><a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Flow.html" title="akka.stream.scaladsl.Flow"><code>Flow</code></a></span></p>
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[Envelope]") shouldEqual
html(
"""<p><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/dispatch/Envelope.html">Envelope</a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/dispatch/Envelope.html">Envelope</a></span>
|<a href="https://doc.akka.io/api/akka/2.5/akka/dispatch/Envelope.html" title="akka.dispatch.Envelope"><code>Envelope</code></a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/dispatch/Envelope.html" title="akka.dispatch.Envelope"><code>Envelope</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -85,8 +85,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[Flow]") shouldEqual
html(
"""<p><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Flow.html">Flow</a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Flow.html">Flow</a></span>
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Flow.html" title="akka.stream.javadsl.Flow"><code>Flow</code></a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Flow.html" title="akka.stream.scaladsl.Flow"><code>Flow</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -95,8 +95,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[typed.*.Replicator$]") shouldEqual
html(
"""<p><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/ddata/typed/scaladsl/Replicator$.html">Replicator</a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/cluster/ddata/typed/javadsl/Replicator.html">Replicator</a></span>
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/ddata/typed/scaladsl/Replicator$.html" title="akka.cluster.ddata.typed.scaladsl.Replicator"><code>Replicator</code></a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/cluster/ddata/typed/javadsl/Replicator.html" title="akka.cluster.ddata.typed.javadsl.Replicator"><code>Replicator</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -105,8 +105,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[ddata.Replicator$]") shouldEqual
html(
"""<p><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/ddata/Replicator$.html">Replicator</a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/cluster/ddata/Replicator.html">Replicator</a></span>
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/ddata/Replicator$.html" title="akka.cluster.ddata.Replicator"><code>Replicator</code></a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/cluster/ddata/Replicator.html" title="akka.cluster.ddata.Replicator"><code>Replicator</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -121,8 +121,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[akka.actor.ActorRef]") shouldEqual
html(
"""<p><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/actor/ActorRef.html">ActorRef</a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/actor/ActorRef.html">ActorRef</a></span>
|<a href="https://doc.akka.io/api/akka/2.5/akka/actor/ActorRef.html" title="akka.actor.ActorRef"><code>ActorRef</code></a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/actor/ActorRef.html" title="akka.actor.ActorRef"><code>ActorRef</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -131,8 +131,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[actor.typed.ActorRef]") shouldEqual
html(
"""<p><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/actor/typed/ActorRef.html">ActorRef</a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/actor/typed/ActorRef.html">ActorRef</a></span>
|<a href="https://doc.akka.io/api/akka/2.5/akka/actor/typed/ActorRef.html" title="akka.actor.typed.ActorRef"><code>ActorRef</code></a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/actor/typed/ActorRef.html" title="akka.actor.typed.ActorRef"><code>ActorRef</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -141,8 +141,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[ClusterClient$]") shouldEqual
html(
"""<p><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/client/ClusterClient$.html">ClusterClient</a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/cluster/client/ClusterClient.html">ClusterClient</a></span>
|<a href="https://doc.akka.io/api/akka/2.5/akka/cluster/client/ClusterClient$.html" title="akka.cluster.client.ClusterClient"><code>ClusterClient</code></a></span><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/cluster/client/ClusterClient.html" title="akka.cluster.client.ClusterClient"><code>ClusterClient</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -151,8 +151,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[Source[ServerSentEvent, \\_]]") shouldEqual
html(
"""<p><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Source.html">Source&lt;ServerSentEvent, ?&gt;</a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Source.html">Source[ServerSentEvent, _]</a></span>
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Source.html" title="akka.stream.javadsl.Source"><code>Source&lt;ServerSentEvent, ?&gt;</code></a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Source.html" title="akka.stream.scaladsl.Source"><code>Source[ServerSentEvent, _]</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -161,8 +161,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[Flow[Message, Message, Mat]]") shouldEqual
html(
"""<p><span class="group-java">
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Flow.html">Flow&lt;Message, Message, Mat&gt;</a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Flow.html">Flow[Message, Message, Mat]</a></span>
|<a href="https://doc.akka.io/japi/akka/2.5/?akka/stream/javadsl/Flow.html" title="akka.stream.javadsl.Flow"><code>Flow&lt;Message, Message, Mat&gt;</code></a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka/2.5/akka/stream/scaladsl/Flow.html" title="akka.stream.scaladsl.Flow"><code>Flow[Message, Message, Mat]</code></a></span>
|</p>""".stripMargin
)
}
Expand All @@ -171,8 +171,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec {
markdown("@apidoc[Marshaller[Try[A], B]]") shouldEqual
html(
"""<p><span class="group-java">
|<a href="https://doc.akka.io/japi/akka-http/current/?akka/http/javadsl/marshalling/Marshaller.html">Marshaller&lt;Try&lt;A&gt;, B&gt;</a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka-http/current/akka/http/scaladsl/marshalling/Marshaller.html">Marshaller[Try[A], B]</a></span>
|<a href="https://doc.akka.io/japi/akka-http/current/?akka/http/javadsl/marshalling/Marshaller.html" title="akka.http.javadsl.marshalling.Marshaller"><code>Marshaller&lt;Try&lt;A&gt;, B&gt;</code></a></span><span class="group-scala">
|<a href="https://doc.akka.io/api/akka-http/current/akka/http/scaladsl/marshalling/Marshaller.html" title="akka.http.scaladsl.marshalling.Marshaller"><code>Marshaller[Try[A], B]</code></a></span>
|</p>""".stripMargin
)
}
Expand Down

0 comments on commit 2b37b76

Please sign in to comment.