diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9ec719ca16..7916a0ed1e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,6 +10,58 @@ It's possible to communicate with other developers through a variety of communic - [Bitcoin-S Gitter](https://gitter.im/bitcoin-s-core/) - [#bitcoin-scala](https://webchat.freenode.net/?channels=bitcoin-scala) on IRC Freenode +## Documentation + +One of the goals of Bitcoin-S is having useful and well-formatted Scaladoc comments on classes, +objects and functions. Here are some useful resources on how to properly format your Scaladoc comments: + +- [Scaladoc for library authors](https://docs.scala-lang.org/overviews/scaladoc/for-library-authors.html) +- [Guidelines](https://docs.scala-lang.org/style/scaladoc.html) used by the official Scala language Scaladoc + +### Bitcoin-S static site + +Bitcoin-S comes bundles with it's own web site with documentation about the library. It consists if the generated Scaladoc of the project, as well as the content of `src/site`. + +### Working with documentation locally + +View generated site: + +```bash +$ sbt previewSite +``` + +### Publishing Bitcoin-S site + +```bash +$ sbt ghpagesPushSite +``` + +Read more on the [`sbt-ghpages`](https://github.com/sbt/sbt-ghpages) sbt plugin. + +> Note: some setup is required before doing this the first time +> From the `sbt-ghpages` documentation: + +Before using sbt-ghpages, you must create the gh-pages branch in your repository and push the branch to GitHub. The quick steps are: + +```bash +# Using a fresh, temporary clone is safest for this procedure +$ pushd /tmp +$ git clone git@github.com:youruser/yourproject.git +$ cd yourproject + +# Create branch with no history or content +$ git checkout --orphan gh-pages +$ git rm -rf . + +# Establish the branch existence +$ git commit --allow-empty -m "Initialize gh-pages branch" +$ git push origin gh-pages + +# Return to original working copy clone, we're finished with the /tmp one +$ popd +$ rm -rf /tmp/yourproject +``` + ## Development ### `testkit` and circular dependencies diff --git a/build.sbt b/build.sbt index 94c53564ee..bb53e0f122 100644 --- a/build.sbt +++ b/build.sbt @@ -1,5 +1,7 @@ import sbt.Credentials import sbt.Keys.publishTo +import com.typesafe.sbt.SbtGit.GitKeys._ + cancelable in Global := true @@ -96,6 +98,12 @@ lazy val root = project ) .settings(commonSettings: _*) .settings(crossScalaVersions := Nil) + .enablePlugins(ScalaUnidocPlugin, GhpagesPlugin) + .settings( + ScalaUnidoc / siteSubdirName := "latest/api", + addMappingsToSiteDir(ScalaUnidoc / packageDoc / mappings, ScalaUnidoc / siteSubdirName), + gitRemoteRepo := "git@github.com:bitcoin-s/bitcoin-s-core.git" + ) lazy val secp256k1jni = project @@ -190,3 +198,7 @@ lazy val doc = project ) publishArtifact in root := false + +previewSite / aggregate := false +previewAuto / aggregate := false +previewSite / aggregate := false diff --git a/project/plugins.sbt b/project/plugins.sbt index 39efc7f74b..a7a0f17402 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -13,3 +13,12 @@ addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15") addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1") + +// sbt plugin to unify scaladoc/javadoc across multiple projects +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2") + +// make static site through sbt +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") + +// publish said site to GitHub pages +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")