Skip to content

Commit 17b1436

Browse files
authored
Merge pull request #195 from armanbilge/doc/website
Add page for sbt-typelevel-site plugin
2 parents 4795978 + 3514d53 commit 17b1436

File tree

8 files changed

+64
-25
lines changed

8 files changed

+64
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sbt-typelevel configures [sbt](https://www.scala-sbt.org/) for developing, testi
88
- git-based dynamic versioning
99
- Binary-compatibility checking with [MiMa](https://github.com/lightbend/mima), following [early semantic versioning](https://www.scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html#early-semver-and-sbt-version-policy)
1010
- CI publishing of releases and snapshots to Sonatype/Maven
11-
- CI deployed GitHub pages microsites, generated with [mdoc](https://github.com/scalameta/mdoc/) and [Laika](https://github.com/planet42/laika)
11+
- CI deployed GitHub pages websites generated with [mdoc](https://github.com/scalameta/mdoc/) and [Laika](https://github.com/planet42/laika)
1212
- Auto-populated settings for various boilerplate (SCM info, API doc urls, Scala.js sourcemaps, etc.)
1313

1414
## Get Started

build.sbt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ lazy val docs = project
183183
"sbt-github-actions" -> url("https://github.com/djspiewak/sbt-github-actions/"),
184184
"mima" -> url("https://github.com/lightbend/mima"),
185185
"mdoc" -> url("https://scalameta.org/mdoc/"),
186-
"Laika" -> url("https://planet42.github.io/Laika/")
186+
"Laika" -> url("https://planet42.github.io/Laika/"),
187+
"sbt-unidoc" -> url("https://github.com/sbt/sbt-unidoc")
187188
)
188189
)

docs/customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Instead of using the super-plugins, for finer-grained control you can always add
6161
- `tlFatalWarningsInCi` (setting): Convert compiler warnings into errors under CI builds (default: true).
6262

6363
### sbt-typelevel-site
64-
- `TypelevelSitePlugin`: Sets up an [mdoc](https://scalameta.org/mdoc/)/[Laika](https://planet42.github.io/Laika/)-generated microsite, automatically published to GitHub pages in CI.
64+
- `TypelevelSitePlugin`: Sets up an [mdoc](https://scalameta.org/mdoc/)/[Laika](https://planet42.github.io/Laika/)-generated website, automatically published to GitHub pages in CI.
6565
- `tlSitePublishBranch` (setting): The branch to publish the site from on every push. Set this to `None` if you only want to update the site on tag releases. (default: `main`)
6666
- `tlSitePublishTags` (setting): Defines whether the site should be published on tag releases. Note on setting this to `true` requires the `tlSitePublishBranch` setting to be set to `None`. (default: `false`)
6767
- `tlSiteApiUrl` (setting): URL to the API docs. (default: `None`)

docs/directory.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
laika.navigationOrder = [
22
index.md
3+
site.md
34
faq.md
45
customization.md
56
]

docs/faq.md

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,20 +92,6 @@ val root = tlCrossRootProject
9292
ThisBuild / tlSonatypeUseLegacyHost := false
9393
```
9494

95-
## How do I publish a site like this one?
96-
97-
```scala
98-
// project/plugins.sbt
99-
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "@VERSION@")
100-
// build.sbt
101-
ThisBuild / tlSitePublishBranch := Some("main") // deploy docs from this branch
102-
lazy val docs = project.in(file("site")).enablePlugins(TypelevelSitePlugin)
103-
```
104-
105-
Place your `.md` files in the `docs/` directory of your project. The site is generated using [mdoc](https://scalameta.org/mdoc/) and [Laika](https://planet42.github.io/Laika/) and published to the `gh-pages` branch on every push to the specified branch. Make sure to enable GitHub pages in your repo settings.
106-
107-
To preview locally, run `docs/mdoc` and then `docs/laikaPreview`. This should (reasonably quickly) start a webserver you can view on localhost.
108-
109-
To enjoy a tighter edit loop: with `docs/laikaPreview` running, consider firing up another terminal and starting another sbt, then run `docs/mdoc --watch` ([mdoc docs](https://scalameta.org/mdoc/docs/installation.html#live-reload-html-preview-on-file-save)).
110-
95+
## How do I publish a website like this one?
11196

97+
Check out the [**sbt-typelevel-site**](site.md) plugin.

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ sbt-typelevel configures [sbt](https://www.scala-sbt.org/) for developing, testi
88
- git-based dynamic versioning
99
- Binary-compatibility checking with [MiMa](https://github.com/lightbend/mima), following [early semantic versioning](https://www.scala-lang.org/blog/2021/02/16/preventing-version-conflicts-with-versionscheme.html#early-semver-and-sbt-version-policy)
1010
- CI publishing of releases and snapshots to Sonatype/Maven
11-
- CI deployed GitHub pages microsites, generated with [mdoc](https://github.com/scalameta/mdoc/) and [Laika](https://github.com/planet42/laika)
11+
- CI deployed GitHub pages websites, generated with [mdoc](https://github.com/scalameta/mdoc/) and [Laika](https://github.com/planet42/laika)
1212
- Auto-populated settings for various boilerplate (SCM info, API doc urls, Scala.js sourcemaps, etc.)
1313

1414
## Quick start
1515

1616
[![sbt-typelevel Scala version support](https://index.scala-lang.org/typelevel/sbt-typelevel/sbt-typelevel/latest-by-scala-version.svg?targetType=Sbt)](https://index.scala-lang.org/typelevel/sbt-typelevel/sbt-typelevel)
1717
[![Discord](https://img.shields.io/discord/632277896739946517.svg?label=&logo=discord&logoColor=ffffff&color=404244&labelColor=6A7EC2)](https://discord.gg/D7wY3aH7BQ)
1818

19-
Pick either the `sbt-typelevel` (recommended) or `sbt-typelevel-ci-release` plugin.
19+
Pick either the **sbt-typelevel** (recommended) or **sbt-typelevel-ci-release** plugin.
2020

2121
#### `project/plugins.sbt`
2222

docs/site.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# sbt-typelevel-site
2+
3+
**sbt-typelevel-site** is an optional plugin for generating websites with [mdoc](https://scalameta.org/mdoc/) and [Laika](https://planet42.github.io/Laika/) and deploying to GitHub Pages from CI. You can add it to your build alongside either the **sbt-typelevel** or **sbt-typelevel-ci-release** plugin.
4+
5+
## Quick start
6+
7+
#### `project/plugins.sbt`
8+
9+
```scala
10+
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % "@VERSION@")
11+
```
12+
13+
#### `build.sbt`
14+
15+
```scala
16+
// publish website from this branch
17+
ThisBuild / tlSitePublishBranch := Some("main")
18+
19+
lazy val docs = project.in(file("site")).enablePlugins(TypelevelSitePlugin)
20+
```
21+
22+
Place your `.md` files in the `docs/` directory of your project. To preview locally, run `docs/tlSitePreview`. This will start a preview server at http://localhost:4242.
23+
24+
The site is generated using [mdoc](https://scalameta.org/mdoc/) and [Laika](https://planet42.github.io/Laika/) and published to the `gh-pages` branch on every push to the specified branch. Make sure to enable GitHub Pages in your repository settings.
25+
26+
### How can I include my project version on the website?
27+
28+
**sbt-typelevel-site** automatically adds `VERSION` and `SNAPSHOT_VERSION` to the `mdocVariables` setting which can be used with [variable injection](https://scalameta.org/mdoc/docs/why.html#variable-injection).
29+
30+
For example, the sbt-typelevel `VERSION` is `@VERSION@` and `SNAPSHOT_VERSION` is `@SNAPSHOT_VERSION@`.
31+
32+
### How can I publish "unidoc" API docs?
33+
34+
If you generate your API documentation with [sbt-unidoc](https://github.com/sbt/sbt-unidoc), you can use the `TypelevelUnidocPlugin` to publish a Scaladoc-only artifact to Sonatype/Maven alongside your library artifacts. This makes it possible to browse your unidocs at [javadoc.io](https://www.javadoc.io/); for example, the sbt-typelevel [API docs](@API_URL@) are published like this.
35+
36+
```scala
37+
lazy val unidoc = project
38+
.in(file("unidoc"))
39+
.enablePlugins(TypelevelUnidocPlugin) // also enables the ScalaUnidocPlugin
40+
.settings(
41+
name := "woozle-docs"
42+
)
43+
```
44+
45+
### How can I customize my website's appearance?
46+
47+
We refer you to the comprehensive [Laika manual](https://planet42.github.io/Laika/index.html) and specifically the [`laikaTheme` setting](https://planet42.github.io/Laika/0.18/02-running-laika/01-sbt-plugin.html#laikatheme-setting).

site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,14 @@ object TypelevelSitePlugin extends AutoPlugin {
106106
tlSitePreview := previewTask.value,
107107
Laika / sourceDirectories := Seq(mdocOut.value),
108108
laikaTheme := tlSiteHeliumConfig.value.build.extend(tlSiteHeliumExtensions.value),
109-
mdocVariables ++= Map(
110-
"VERSION" -> currentRelease.value.getOrElse(version.value),
111-
"SNAPSHOT_VERSION" -> version.value
112-
),
109+
mdocVariables := {
110+
mdocVariables.value ++
111+
Map(
112+
"VERSION" -> currentRelease.value.getOrElse(version.value),
113+
"SNAPSHOT_VERSION" -> version.value
114+
) ++
115+
tlSiteApiUrl.value.map("API_URL" -> _.toString).toMap
116+
},
113117
tlSiteHeliumExtensions := TypelevelHeliumExtensions(
114118
licenses.value.headOption,
115119
tlSiteRelatedProjects.value

0 commit comments

Comments
 (0)