Skip to content

Commit

Permalink
Removes tut (#527)
Browse files Browse the repository at this point in the history
* Removes tut

* Updates docs

* Fixes scripted tests

* Removes useless test
  • Loading branch information
juanpedromoreno authored Dec 23, 2020
1 parent 7cdf102 commit 4c00ed3
Show file tree
Hide file tree
Showing 25 changed files with 19 additions and 216 deletions.
1 change: 0 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ lazy val documentation = project
.enablePlugins(MdocPlugin)

lazy val pluginSettings: Seq[Def.Setting[_]] = Seq(
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13"),
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.13"),
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3"),
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1"),
Expand Down
2 changes: 1 addition & 1 deletion microsite/docs/docs/build-the-microsite.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Once you have written your documents, you can build the microsite running this s
sbt> makeMicrosite
```

Internally, it'll sequentially run other tasks including its own, [`tut`](https://github.com/tpolecat/tut) or [`mdoc`](https://scalameta.org/mdoc/), and `makeSite` ([sbt-site](https://github.com/sbt/sbt-site)) tasks.
Internally, it'll sequentially run other tasks including its own, [`mdoc`](https://scalameta.org/mdoc/), and `makeSite` ([sbt-site](https://github.com/sbt/sbt-site)) tasks.


# Multiversion support
Expand Down
5 changes: 1 addition & 4 deletions microsite/docs/docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,4 @@ enablePlugins(MicrositesPlugin)

# Write your documentation `.md` files

Your docs can be placed wherever you want in your project since there are sbt settings to point to the sources of your microsite, however the plugin expects to find the sources where both [**tut**](https://github.com/tpolecat/tut) and [**mdoc**](https://github.com/scalameta/mdoc) have defined by default. They are:

- Tut: `src/main/tut/`
- mdoc: `docs/`
Your docs can be placed wherever you want in your project since there are sbt settings to point to the sources of your microsite, however the plugin expects to find the sources where [**mdoc**](https://github.com/scalameta/mdoc) have defined by default (`docs/`).
1 change: 0 additions & 1 deletion microsite/docs/docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The plugin provides basic free styles, css, and image resources by default. Ever

In order to create microsites, this plugin directly uses the following plugins and libraries:

* [tut-plugin](https://github.com/tpolecat/tut)
* [sbt-mdoc](https://github.com/scalameta/mdoc)
* [sbt-site](https://github.com/sbt/sbt-site)
* [sbt-ghpages](https://github.com/sbt/sbt-ghpages)
Expand Down
2 changes: 1 addition & 1 deletion microsite/docs/docs/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ To be able to access the documentation, you have to configure `micrositeDocument

In order to change the default label description for the `micrositeDocumentationUrl` (the default value is `Documentation`), you have to change the `micrositeDocumentationLabelDescription`.

As an example, you can look at the sbt-microsites documentation at [GitHub](https://github.com/47deg/sbt-microsites/tree/master/docs/src/main/tut). We have several documentation files:
As an example, you can look at the sbt-microsites documentation at [GitHub](https://github.com/47degrees/sbt-microsites/tree/master/microsite/docs). We have several documentation files:

- `build-the-microsite.md`
- `customize.md`
Expand Down
13 changes: 3 additions & 10 deletions microsite/docs/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ micrositeStaticDirectory := (resourceDirectory in Compile).value / "site" / "mys

The directory will be copied as-is, but no process will be applied to any file on it. So the responsibility of loading/linking/using them on a layout is yours. Also, see the `includeFilter in makeSite` config setting for the allowed file types that will be copied.

- `micrositeExtraMdFiles`: This setting can be handy if you want to include additional markdown files in your site, and these files are not located in the same place in your `mdoc` or `tut` directory. By default, the setting is set up as an empty map. You can override it in this way:
- `micrositeExtraMdFiles`: This setting can be handy if you want to include additional markdown files in your site, and these files are not located in the same place in your `mdoc` directory. By default, the setting is set up as an empty map. You can override it in this way:

```scala
micrositeExtraMdFiles := Map(
Expand All @@ -278,7 +278,7 @@ micrositeExtraMdFiles := Map(

Each file (the map key) can be related to a specific configuration through the `ExtraMdFileConfig` case class. This class allows you to specify three additional configurations:

1. The target file name. The plugin will copy the file, and it will put it in tut directory each time you build the microsite. Therefore, you might want to include this auto-copied file in the list of ignored files at the `.gitignore` file.
1. The target file name. The plugin will copy the file, and it will put it in mdoc directory each time you build the microsite. Therefore, you might want to include this auto-copied file in the list of ignored files at the `.gitignore` file.
2. Jekyll `layout` property.
3. Other custom Jekyll properties that you might want to include in your document. A good point to highlight here is that through the `permalink` property you can control the place where `Jekyll` is going to move your extra file. The value of this property prevails over the folder where the file is copied.

Expand Down Expand Up @@ -367,16 +367,9 @@ repository URL, and should include the dynamic property `{% raw %}{{page.path}}{
compiles the site. **The strings are passed in unsanitized to the templating engine.**

```scala
{% raw %}micrositeEditButton := Some(MicrositeEditButton("Improve this Page", "/edit/master/docs/src/main/tut/{{ page.path }}")){% endraw %}
{% raw %}micrositeEditButton := Some(MicrositeEditButton("Improve this Page", "/edit/master/docs/{{ page.path }}")){% endraw %}
```

- `micrositeCompilingDocsTool`: Choose between compiling code snippets with [**tut**](https://github.com/tpolecat/tut) or [**mdoc**](https://github.com/scalameta/mdoc). By default, it's set to `WithMdoc` since the sbt-microsites 1.0.0 release. But you could use `WithTut` if you want to preserve the compatibility with previous versions of your markdown files.

```scala
micrositeCompilingDocsTool := WithMdoc
```
If you are interested in learning where to place the markdown files according to the compilation tool chosen, please take a look at the [Typechecked Snippets]({% link docs/typechecked-snippets.md %}) section.

- `includeFilter in makeSite`: Restrict the type of files that are included during the microsite build. The default value is `"*.html" | "*.css" | "*.png" | "*.jpg" | "*.jpeg" | "*.gif" | "*.js" | "*.swf" | "*.md" | "*.webm" | "*.ico" | "CNAME" | "*.yml" | "*.svg" | "*.json"` but you can override it like this:

```scala
Expand Down
19 changes: 2 additions & 17 deletions microsite/docs/docs/typechecked-snippets.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,18 @@ permalink: docs/typechecked-snippets/

# Typechecked Snippets

As has been mentioned a couple of times throughout this tutorial, this plugin supports the compilation of Scala code written in markdown files. This process is now being delegated on two different sbt plugins: [**tut**](https://github.com/tpolecat/tut) and [**mdoc**](https://github.com/scalameta/mdoc).

## Tut

[tut](https://github.com/tpolecat/tut) has been deprecated, please switch to mdoc (see next section). If for some reason you want to keep using it, here there are some recommendations:

- Set this property accordingly: `micrositeCompilingDocsTool := WithTut`.
- Add your markdown files in this path by default: `src/main/tut/`.
- If you want to place your documments in a different path, just set the sbt property `tutSourceDirectory := your-path` being _your-path_ a `SettingKey[File]`.
- Mark the snippets that you want to compile, following this convention: **_```tut_** or any of its [modifiers](https://tpolecat.github.io/tut/modifiers.html)

As has been mentioned a couple of times throughout this tutorial, this plugin supports the compilation of Scala code written in markdown files. This process is now being delegated on [**mdoc**](https://github.com/scalameta/mdoc).

## mdoc

`mdoc` is the option by default, so no special action is required from your side. See the scalameta site for more information [here](https://scalameta.org/mdoc/). Here is some advice for using this in your microsite:

- Add your markdown files in this path by default: `docs/`.
- By default, the setting `micrositeCompilingDocsTool` will be `WithMdoc`, so no action would be required.
- If you want to place your documents in a different path, just set the sbt property `mdocIn := your-path` being _your-path_ a `SettingKey[File]`.
- Mark the snippets that you want to compile, following this convention: **_```scala mdoc_** or any of its [modifiers](https://scalameta.org/mdoc/docs/modifiers.html)

## Migrating from tut to mdoc

You can migrate your microsite from _tut_ to _mdoc_ in 3 smooth steps:

- Set this property accordingly: `micrositeCompilingDocsTool := WithMdoc`
- Set the property `mdocIn := tutSourceDirectory`, thus we are setting the source for mdoc as it used to be for tut.
- Replace **_tut_** with **_mdoc_** in the snippets modifiers following this [migration guide](https://scalameta.org/mdoc/docs/tut.html).
If your project is still based on `tut`, you can migrate it from _tut_ to _mdoc_ can follow this [migration guide](https://scalameta.org/mdoc/docs/tut.html).

There is also a [script](https://github.com/scalameta/mdoc/blob/5c732bc48eb88b8a416e5c61e945eac6d410b27b/bin/migrate-tut.sh) that does the replacement for you.
1 change: 0 additions & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ addSbtPlugin("com.alejandrohdezma" % "sbt-github" % "0.9.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.9.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.9.0")
addSbtPlugin("com.alejandrohdezma" % "sbt-remove-test-from-pom" % "0.1.0")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13")
addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.2.14")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.1")
39 changes: 4 additions & 35 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import sbt.Keys._
import sbt._
import sbt.complete.DefaultParsers.OptNotSpace
import sbt.io.{IO => FIO}
import tut.TutPlugin.autoImport._

import scala.concurrent.ExecutionContext
import scala.sys.process._
Expand All @@ -52,10 +51,6 @@ trait MicrositeKeys {
final case object GHPagesPlugin extends PushWith("ghPagesPlugin")
final case object GitHub4s extends PushWith("github4s")

sealed abstract class CompilingDocsTool extends Product with Serializable
final case object WithTut extends CompilingDocsTool
final case object WithMdoc extends CompilingDocsTool

object GitHostingService {
implicit def string2GitHostingService(name: String): GitHostingService = {
List(GitHub, GitLab, Bitbucket)
Expand All @@ -71,11 +66,8 @@ trait MicrositeKeys {
}

val makeMicrosite: TaskKey[Unit] = taskKey[Unit]("Main task to build a microsite")
val makeTut: TaskKey[Unit] = taskKey[Unit]("Sequential tasks to compile tut and move the result")
val makeMdoc: TaskKey[Unit] =
taskKey[Unit]("Sequential tasks to compile mdoc and move the result")
val makeDocs: TaskKey[Unit] =
taskKey[Unit]("Dynamic task that will evaluate makeTut or makeMdoc depending on setting")
val createMicrositeVersions: TaskKey[Unit] =
taskKey[Unit](
"Task to create the different microsites going through the list specified in the settings"
Expand All @@ -102,8 +94,6 @@ trait MicrositeKeys {
val microsite: TaskKey[Seq[File]] = taskKey[Seq[File]]("Create microsite files")
val micrositeMakeExtraMdFiles: TaskKey[File] =
taskKey[File]("Create microsite extra md files")
val micrositeTutExtraMdFiles: TaskKey[Seq[File]] =
taskKey[Seq[File]]("Run tut for extra microsite md files")
val micrositeName: SettingKey[String] = settingKey[String]("Microsite name")
val micrositeDescription: SettingKey[String] = settingKey[String]("Microsite description")
val micrositeAuthor: SettingKey[String] = settingKey[String]("Microsite author")
Expand Down Expand Up @@ -156,7 +146,7 @@ trait MicrositeKeys {
)
val micrositeExtraMdFiles: SettingKey[Map[File, ExtraMdFileConfig]] =
settingKey[Map[File, ExtraMdFileConfig]](
"Optional. This key is useful when you want to include automatically markdown documents as a part of your microsite, and these files are located in different places from the tutSourceDirectory. The map key is related with the source file, the map value corresponds with the target relative file path and the document meta-information configuration. By default, the map is empty."
"Optional. This key is useful when you want to include automatically markdown documents as a part of your microsite, and these files are located in different places. The map key is related with the source file, the map value corresponds with the target relative file path and the document meta-information configuration. By default, the map is empty."
)
val micrositeExtraMdFilesOutput: SettingKey[File] = settingKey[File](
"Optional. Microsite output location for extra-md files. Default is resourceManaged + '/jekyll/extra_md'"
Expand Down Expand Up @@ -214,9 +204,6 @@ trait MicrositeKeys {
"Optional. Add a button in DocsLayout pages that links to the file in the repository."
)

val micrositeCompilingDocsTool =
settingKey[CompilingDocsTool]("Choose between compiling code snippets with tut or mdoc")

val micrositeTheme: SettingKey[String] = settingKey[String](
"Optional. 'light' by default. Set it to 'pattern' to generate the pattern theme design."
)
Expand Down Expand Up @@ -320,7 +307,7 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
"style" -> "compressed",
"sourcemap" -> "never"
),
"collections" -> Map("tut" -> Map("output" -> true))
"collections" -> Map("mdoc" -> Map("output" -> true))
)

val userCustomVariables = micrositeConfigYaml.value
Expand Down Expand Up @@ -401,28 +388,10 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
microsite := micrositeHelper.value
.createResources(resourceManagedDir = (resourceManaged in Compile).value),
micrositeMakeExtraMdFiles := micrositeHelper.value.buildAdditionalMd(),
micrositeTutExtraMdFiles := {
val r = (runner in Tut).value
val in = micrositeMakeExtraMdFiles.value
val out = tutTargetDirectory.value
val cp = (fullClasspath in Tut).value
val opts = (scalacOptions in Tut).value
val pOpts = tutPluginJars.value.map(f => "–Xplugin:" + f.getAbsolutePath)
val re = tutNameFilter.value.pattern.toString
_root_.tut.TutPlugin.tutOne(streams.value, r, in, out, cp, opts, pOpts, re).map(_._1)
},
makeTut :=
Def.sequential(tut, micrositeTutExtraMdFiles).value,
makeMdoc :=
Def.sequential(mdoc.toTask(""), micrositeMakeExtraMdFiles).value,
makeDocs := Def.taskDyn {
micrositeCompilingDocsTool.value match {
case WithTut => Def.sequential(makeTut)
case WithMdoc => Def.sequential(makeMdoc)
}
}.value,
makeMicrosite :=
Def.sequential(microsite, makeDocs, makeSite).value,
Def.sequential(microsite, makeMdoc, makeSite).value,
makeVersionsJson := {
"which git".! match {
case 0 => ()
Expand Down Expand Up @@ -478,7 +447,7 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
}
},
makeVersionedMicrosite :=
Def.sequential(microsite, makeVersionsJson, makeDocs, makeSite).value,
Def.sequential(microsite, makeVersionsJson, makeMdoc, makeSite).value,
makeMultiversionMicrosite :=
Def
.sequential(createMicrositeVersions, clean, makeVersionedMicrosite, moveMicrositeVersions)
Expand Down
7 changes: 1 addition & 6 deletions src/main/scala/microsites/MicrositesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import com.typesafe.sbt.site.SitePlugin.autoImport._
import sbt.Keys._
import sbt._
import sbt.plugins.IvyPlugin
import tut.TutPlugin
import tut.TutPlugin.autoImport._
import mdoc.MdocPlugin
import mdoc.MdocPlugin.autoImport._

Expand All @@ -38,7 +36,7 @@ object MicrositesPlugin extends AutoPlugin {
import com.typesafe.sbt.site.jekyll.JekyllPlugin.autoImport._

override def requires: Plugins =
IvyPlugin && MdocPlugin && TutPlugin && JekyllPlugin && GhpagesPlugin
IvyPlugin && MdocPlugin && JekyllPlugin && GhpagesPlugin

override def trigger: PluginTrigger = allRequirements

Expand All @@ -48,8 +46,6 @@ object MicrositesPlugin extends AutoPlugin {
Seq(
git.remoteRepo := s"[email protected]:${micrositeGithubOwner.value}/${micrositeGithubRepo.value}.git",
sourceDirectory in Jekyll := resourceManaged.value / "main" / "jekyll",
tutSourceDirectory := sourceDirectory.value / "main" / "tut",
tutTargetDirectory := resourceManaged.value / "main" / "jekyll",
mdocIn := baseDirectory.value / "docs",
mdocOut := resourceManaged.value / "main" / "jekyll"
)
Expand Down Expand Up @@ -126,7 +122,6 @@ object MicrositesPlugin extends AutoPlugin {
micrositeFooterText := Some(layouts.Layout.footer.toString),
micrositeEditButton := None,
micrositeGithubLinks := true,
micrositeCompilingDocsTool := WithMdoc,
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.jpeg" | "*.gif" | "*.js" | "*.swf" | "*.md" | "*.webm" | "*.ico" | "CNAME" | "*.yml" | "*.svg" | "*.json",
includeFilter in Jekyll := (includeFilter in makeSite).value || "LICENSE",
commands ++= Seq(publishMicrositeCommand),
Expand Down
2 changes: 1 addition & 1 deletion src/sbt-test/microsites/change-default-paths/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ micrositeExtraMdFilesOutput := (target in Compile).value / "extra_md_override"
micrositeImgDirectory := (resourceDirectory in Compile).value / "images"
micrositeCssDirectory := (resourceDirectory in Compile).value / "styles"
micrositePluginsDirectory := (resourceDirectory in Compile).value / "plugins"
mdocIn := baseDirectory.in(ThisBuild).value / "src" / "main" / "tut"
mdocIn := baseDirectory.in(ThisBuild).value / "src" / "main" / "mdoc"
3 changes: 0 additions & 3 deletions src/sbt-test/microsites/extra-md-files/CONSEQUAT.md

This file was deleted.

40 changes: 0 additions & 40 deletions src/sbt-test/microsites/extra-md-files/build.sbt

This file was deleted.

2 changes: 0 additions & 2 deletions src/sbt-test/microsites/extra-md-files/project/plugins.sbt

This file was deleted.

13 changes: 0 additions & 13 deletions src/sbt-test/microsites/extra-md-files/test

This file was deleted.

1 change: 0 additions & 1 deletion src/sbt-test/microsites/mdoc-compile/build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
enablePlugins(MicrositesPlugin)
scalaVersion := sys.props("scala.version")
micrositeCompilingDocsTool := WithMdoc
1 change: 0 additions & 1 deletion src/sbt-test/microsites/mdoc-extra-md-files/build.sbt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import microsites.ExtraMdFileConfig
enablePlugins(MicrositesPlugin)
scalaVersion := sys.props("scala.version")
micrositeCompilingDocsTool := WithMdoc

micrositeExtraMdFilesOutput := (resourceManaged in Compile).value / "jekyll"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
layout: docs
---

# Overview

README file of the project, located in the project's root.
2 changes: 1 addition & 1 deletion src/sbt-test/microsites/microsites-tasks/test
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> microsite

> tut
> mdoc

> makeSite

Expand Down
Loading

0 comments on commit 4c00ed3

Please sign in to comment.