diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 7267df2..f3b561c 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -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" } diff --git a/src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala b/src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala index bcdbaaa..e381d1c 100644 --- a/src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala +++ b/src/main/scala/com/lightbend/paradox/apidoc/ApidocDirective.scala @@ -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") { @@ -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 = @@ -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, @@ -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 ) ) } diff --git a/src/sbt-test/apidoc/multi-project/build.sbt b/src/sbt-test/apidoc/multi-project/build.sbt index bfa7120..2359be3 100644 --- a/src/sbt-test/apidoc/multi-project/build.sbt +++ b/src/sbt-test/apidoc/multi-project/build.sbt @@ -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 diff --git a/src/sbt-test/apidoc/multi-project/expected/index.html b/src/sbt-test/apidoc/multi-project/expected/index.html index bf077df..ea59613 100644 --- a/src/sbt-test/apidoc/multi-project/expected/index.html +++ b/src/sbt-test/apidoc/multi-project/expected/index.html @@ -1 +1 @@ -

Api link to sub-project LibClassLibClass

+

Api link to sub-project LibClassLibClass

diff --git a/src/sbt-test/apidoc/scaladoc-for-java-class/expected/index.html b/src/sbt-test/apidoc/scaladoc-for-java-class/expected/index.html index 2178321..f1d63e8 100644 --- a/src/sbt-test/apidoc/scaladoc-for-java-class/expected/index.html +++ b/src/sbt-test/apidoc/scaladoc-for-java-class/expected/index.html @@ -1,3 +1,3 @@ -

Api link to a class that is both in scaladsl and javadsl packages, but has no javadoc configured: FlowFlow

-

Api link to a class that is in common package, but has no javadoc configured GraphStageGraphStage

-

Api link to a class that is both in scaladsl and javadsl packages, and has javadoc configured: BehaviorsBehaviors

\ No newline at end of file +

Api link to a class that is both in scaladsl and javadsl packages, but has no javadoc configured: FlowFlow

+

Api link to a class that is in common package, but has no javadoc configured GraphStageGraphStage

+

Api link to a class that is both in scaladsl and javadsl packages, and has javadoc configured: BehaviorsBehaviors

diff --git a/src/sbt-test/apidoc/single-project/expected/index.html b/src/sbt-test/apidoc/single-project/expected/index.html index 675ed34..d84a878 100644 --- a/src/sbt-test/apidoc/single-project/expected/index.html +++ b/src/sbt-test/apidoc/single-project/expected/index.html @@ -1 +1 @@ -

Api link to Akka FlowFlow

+

Api link to Akka FlowFlow

diff --git a/src/test/scala/com/lightbend/paradox/apidoc/ApidocDirectiveSpec.scala b/src/test/scala/com/lightbend/paradox/apidoc/ApidocDirectiveSpec.scala index 0c4d0b0..12bcfb5 100644 --- a/src/test/scala/com/lightbend/paradox/apidoc/ApidocDirectiveSpec.scala +++ b/src/test/scala/com/lightbend/paradox/apidoc/ApidocDirectiveSpec.scala @@ -69,8 +69,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[Envelope]") shouldEqual html( """

- |Envelope - |Envelope + |Envelope + |Envelope |

""".stripMargin ) } @@ -85,8 +85,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[Flow]") shouldEqual html( """

- |Flow - |Flow + |Flow + |Flow |

""".stripMargin ) } @@ -95,8 +95,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[typed.*.Replicator$]") shouldEqual html( """

- |Replicator - |Replicator + |Replicator + |Replicator |

""".stripMargin ) } @@ -105,8 +105,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[ddata.Replicator$]") shouldEqual html( """

- |Replicator - |Replicator + |Replicator + |Replicator |

""".stripMargin ) } @@ -121,8 +121,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[akka.actor.ActorRef]") shouldEqual html( """

- |ActorRef - |ActorRef + |ActorRef + |ActorRef |

""".stripMargin ) } @@ -131,8 +131,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[actor.typed.ActorRef]") shouldEqual html( """

- |ActorRef - |ActorRef + |ActorRef + |ActorRef |

""".stripMargin ) } @@ -141,8 +141,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[ClusterClient$]") shouldEqual html( """

- |ClusterClient - |ClusterClient + |ClusterClient + |ClusterClient |

""".stripMargin ) } @@ -151,8 +151,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[Source[ServerSentEvent, \\_]]") shouldEqual html( """

- |Source<ServerSentEvent, ?> - |Source[ServerSentEvent, _] + |Source<ServerSentEvent, ?> + |Source[ServerSentEvent, _] |

""".stripMargin ) } @@ -161,8 +161,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[Flow[Message, Message, Mat]]") shouldEqual html( """

- |Flow<Message, Message, Mat> - |Flow[Message, Message, Mat] + |Flow<Message, Message, Mat> + |Flow[Message, Message, Mat] |

""".stripMargin ) } @@ -171,8 +171,8 @@ class ApidocDirectiveSpec extends MarkdownBaseSpec { markdown("@apidoc[Marshaller[Try[A], B]]") shouldEqual html( """

- |Marshaller<Try<A>, B> - |Marshaller[Try[A], B] + |Marshaller<Try<A>, B> + |Marshaller[Try[A], B] |

""".stripMargin ) }