mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-03-03 10:46:42 +01:00
Merge pull request #566 from torkelrogstad/2019-07-03-bloop-mdoc
Add main method for running Mdoc
This commit is contained in:
commit
554820b3b8
5 changed files with 65 additions and 20 deletions
37
bitcoin-s-docs/docs.sbt
Normal file
37
bitcoin-s-docs/docs.sbt
Normal file
|
@ -0,0 +1,37 @@
|
|||
lazy val bitcoins = RootProject(file("."))
|
||||
|
||||
lazy val publishWebsite = taskKey[Unit]("Publish website")
|
||||
|
||||
publishWebsite := Def
|
||||
.sequential(
|
||||
bitcoins / Compile / unidoc,
|
||||
Compile / docusaurusPublishGhpages
|
||||
)
|
||||
.value
|
||||
|
||||
name := "bitcoin-s-docs"
|
||||
|
||||
publish / skip := true
|
||||
|
||||
////////
|
||||
/// Mdoc
|
||||
|
||||
// Without this we get errors on bad links,
|
||||
// but those links are to other parts of
|
||||
// the website, AKA false errors.
|
||||
// See this issue: https://github.com/scalameta/mdoc/issues/94
|
||||
mdocExtraArguments := List("--no-link-hygiene")
|
||||
|
||||
mdocVariables := Map(
|
||||
"STABLE_VERSION" -> previousStableVersion.value.get,
|
||||
"UNSTABLE_VERSION" -> version.value
|
||||
)
|
||||
|
||||
enablePlugins(MdocPlugin, DocusaurusPlugin, BuildInfoPlugin)
|
||||
buildInfoKeys := Seq[BuildInfoKey](mdocVariables, mdocExtraArguments)
|
||||
buildInfoPackage := "org.bitcoins.docs"
|
||||
|
||||
// Mdoc end
|
||||
///////
|
||||
|
||||
libraryDependencies ++= Deps.docs
|
|
@ -0,0 +1,25 @@
|
|||
package org.bitcoins.docs
|
||||
|
||||
import mdoc.MainSettings
|
||||
import scala.meta.io.AbsolutePath
|
||||
|
||||
/** This is cribbed from how Bloop does
|
||||
* docs generation: https://github.com/scalacenter/bloop/blob/6c8dc54b7bdf5a6145b31f94b73456693c0d1230/docs-gen/src/main/scala/bloop/Docs.scala#L8-L35
|
||||
*/
|
||||
object DocsGen extends App {
|
||||
val cwd0 = AbsolutePath.workingDirectory
|
||||
|
||||
// Depending on who runs it (sbt vs bloop), the current working directory is different
|
||||
val cwd =
|
||||
if (!cwd0.resolve("docs").isDirectory) cwd0.toNIO.getParent else cwd0.toNIO
|
||||
|
||||
val settings = MainSettings()
|
||||
.withSiteVariables(BuildInfo.mdocVariables)
|
||||
.withArgs((BuildInfo.mdocExtraArguments ++ args).toList)
|
||||
// it should work with mdoc when run inside bloop but it doesn't, let's wait until it's fixed
|
||||
.withIn(cwd.resolve("docs"))
|
||||
.withOut(cwd.resolve("bitcoin-s-docs").resolve("target").resolve("mdoc"))
|
||||
|
||||
val exitCode = mdoc.Main.process(settings)
|
||||
if (exitCode != 0) sys.exit(exitCode)
|
||||
}
|
18
build.sbt
18
build.sbt
|
@ -439,27 +439,10 @@ lazy val testkit = project
|
|||
)
|
||||
.enablePlugins(GitVersioning)
|
||||
|
||||
lazy val publishWebsite = taskKey[Unit]("Publish website")
|
||||
|
||||
lazy val docs = project
|
||||
.in(file("bitcoin-s-docs")) // important: it must not be docs/
|
||||
.settings(commonTestSettings: _*)
|
||||
.settings(
|
||||
// come back to visit this setting later
|
||||
mdocExtraArguments := List("--no-link-hygiene"),
|
||||
name := "bitcoin-s-docs",
|
||||
mdocVariables := Map(
|
||||
"STABLE_VERSION" -> previousStableVersion.value.get,
|
||||
"UNSTABLE_VERSION" -> version.value
|
||||
),
|
||||
publishWebsite := Def
|
||||
.sequential(
|
||||
bitcoins / Compile / unidoc,
|
||||
Compile / docusaurusPublishGhpages
|
||||
)
|
||||
.value,
|
||||
libraryDependencies ++= Deps.docs
|
||||
)
|
||||
.dependsOn(
|
||||
bitcoindRpc,
|
||||
core,
|
||||
|
@ -468,7 +451,6 @@ lazy val docs = project
|
|||
testkit,
|
||||
zmq
|
||||
)
|
||||
.enablePlugins(MdocPlugin, DocusaurusPlugin)
|
||||
|
||||
lazy val walletDbSettings = dbFlywaySettings("walletdb")
|
||||
lazy val wallet = project
|
||||
|
|
|
@ -52,8 +52,7 @@ yarn start
|
|||
In a separate shell:
|
||||
|
||||
```bash
|
||||
$ sbt
|
||||
> docs/mdoc --watch
|
||||
$ bloop run docs -- --watch
|
||||
```
|
||||
|
||||
The above commands compiles our Mdoc Markdown files every time you change
|
||||
|
|
|
@ -13,6 +13,8 @@ addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15")
|
|||
// sbt plugin to unify scaladoc/javadoc across multiple projects
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")
|
||||
|
||||
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0")
|
||||
|
||||
// ensure proper linkage across libraries in Scaladoc
|
||||
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "2.1.0")
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue