Skip to content

Commit

Permalink
Fix mdoc generation and remove mdoc dependency from generated pom
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilquist committed Oct 6, 2020
1 parent 2c29d13 commit bc08bb0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
19 changes: 15 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ ThisBuild / testFrameworks += new TestFramework("munit.Framework")

ThisBuild / strictSemVer := false

ThisBuild / doctestTestFramework := DoctestTestFramework.ScalaCheck

lazy val root = project
.in(file("."))
.aggregate(coreJVM, coreJS, testKitJVM, testKitJS)
Expand Down Expand Up @@ -105,10 +107,10 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
Compile / scalafmt / unmanagedSources := (Compile / scalafmt / unmanagedSources).value.filterNot(_.toString.endsWith("Interpolators.scala")),
Test / scalafmt / unmanagedSources := (Test / scalafmt / unmanagedSources).value.filterNot(_.toString.endsWith("Interpolators.scala")),
)
.settings(scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)))
.settings(dottyLibrarySettings)
.settings(dottyJsSettings(ThisBuild / crossScalaVersions))
.jsSettings(
scalaJSLinkerConfig ~= (_.withModuleKind(ModuleKind.CommonJSModule)),
npmDependencies in Compile += "punycode" -> "2.1.1",
crossScalaVersions := crossScalaVersions.value.filterNot(_.startsWith("0."))
)
Expand All @@ -125,7 +127,18 @@ lazy val core = crossProject(JVMPlatform, JSPlatform)
osgiSettings
)

lazy val coreJVM = core.jvm.enablePlugins(MdocPlugin, SbtOsgi)
lazy val coreJVM = core.jvm.enablePlugins(MdocPlugin, SbtOsgi).settings(
pomPostProcess := { (node) =>
import scala.xml._
import scala.xml.transform._
def stripIf(f: Node => Boolean) = new RewriteRule {
override def transform(n: Node) =
if (f(n)) NodeSeq.Empty else n
}
val stripTestScope = stripIf(n => n.label == "dependency" && (n \ "artifactId").text.startsWith("mdoc"))
new RuleTransformer(stripTestScope).transform(node)(0)
}
)
lazy val coreJS = core.js.disablePlugins(DoctestPlugin).enablePlugins(ScalaJSBundlerPlugin)

lazy val commonSettings = Seq(
Expand All @@ -134,8 +147,6 @@ lazy val commonSettings = Seq(
(base / "NOTICE") +: (base / "LICENSE") +: (base / "CONTRIBUTING") +: ((base / "licenses") * "LICENSE_*").get
},
scalacOptions := scalacOptions.value.filterNot(_ == "-Xfatal-warnings"),
sourceDirectories in (Compile, scalafmt) += baseDirectory.value / "../shared/src/main/scala",
scalafmtOnCompile := true,
doctestTestFramework := DoctestTestFramework.ScalaCheck,
initialCommands := "import com.comcast.ip4s._"
)
12 changes: 6 additions & 6 deletions docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ On the JVM, a `SocketAddress` can be converted to a `java.net.InetSocketAddress`

```scala
val u = t.toInetSocketAddress
// u: java.net.InetSocketAddress = /0:0:0:0:0:0:0:1:5555
// u: java.net.InetSocketAddress = /[0:0:0:0:0:0:0:1]:5555
```

## Multicast Socket Addresses
Expand Down Expand Up @@ -301,13 +301,13 @@ import cats.effect.IO
val home = host"localhost"
// home: Hostname = localhost
val homeIp = home.resolve[IO]
// homeIp: IO[Option[IpAddress]] = IO$1854634462
homeIp.unsafeRunSync
// homeIp: IO[Option[IpAddress]] = IO$1249038588
homeIp.unsafeRunSync()
// res4: Option[IpAddress] = Some(127.0.0.1)

val homeIps = home.resolveAll[IO]
// homeIps: IO[Option[cats.data.NonEmptyList[IpAddress]]] = IO$1663940228
homeIps.unsafeRunSync
// homeIps: IO[Option[cats.data.NonEmptyList[IpAddress]]] = IO$1994639181
homeIps.unsafeRunSync()
// res5: Option[cats.data.NonEmptyList[IpAddress]] = Some(NonEmptyList(127.0.0.1, ::1))
```

Expand All @@ -316,7 +316,7 @@ homeIps.unsafeRunSync
RFC1123 hostnames are limited to ASCII characters. The `IDN` type provides a way to represent Unicode hostnames.

```scala
val unicodeComcast = idn"comcast\u3002com"
val unicodeComcast = idn"comcast。com"
// unicodeComcast: IDN = comcast。com
unicodeComcast.hostname
// res6: Hostname = comcast.com
Expand Down
6 changes: 3 additions & 3 deletions jvm/src/main/docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,18 @@ import cats.effect.IO

val home = host"localhost"
val homeIp = home.resolve[IO]
homeIp.unsafeRunSync
homeIp.unsafeRunSync()

val homeIps = home.resolveAll[IO]
homeIps.unsafeRunSync
homeIps.unsafeRunSync()
```

# Internationalized Domain Names

RFC1123 hostnames are limited to ASCII characters. The `IDN` type provides a way to represent Unicode hostnames.

```scala mdoc:to-string
val unicodeComcast = idn"comcast\u3002com"
val unicodeComcast = idn"comcast。com"
unicodeComcast.hostname

val emojiRegistrar = idn"i❤.ws"
Expand Down

0 comments on commit bc08bb0

Please sign in to comment.