-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Asciidoctor attribute support (#157)
- Loading branch information
1 parent
c4af2a8
commit 5aab1d9
Showing
8 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/main/scala/com/typesafe/sbt/site/asciidoctor/AsciidoctorKeys.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.typesafe.sbt.site.asciidoctor | ||
|
||
import sbt.SettingKey | ||
|
||
trait AsciidoctorKeys { | ||
val asciidoctorAttributes = SettingKey[Map[String, String]]( | ||
"asciidoctor-attributes", | ||
"Asciidoctor allows the rendering process to be influenced by so-called attributes. " + | ||
"You can read more about attributes here: https://asciidoctor.org/docs/user-manual/#attributes") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/sbt-test/asciidoctor/asciidoctor-skips-frontmatter/build.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name := "test" | ||
|
||
//#enablePlugin | ||
enablePlugins(AsciidoctorPlugin) | ||
//#enablePlugin | ||
|
||
//#siteSubdirName | ||
// Puts output in `target/site/asciimd` | ||
siteSubdirName in Asciidoctor := "asciimd" | ||
asciidoctorAttributes in Asciidoctor := Map( | ||
"skip-front-matter" -> "", // skip-front-matter is a flag that just has to be present. | ||
"lang" -> "nl") | ||
//#siteSubdirName | ||
|
||
TaskKey[Unit]("checkContent") := { | ||
val dest = (target in makeSite).value / (siteSubdirName in Asciidoctor).value | ||
val index = dest / "index.html" | ||
assert(index.exists, s"${index.getAbsolutePath} did not exist") | ||
val content = IO.readLines(index) | ||
|
||
assert(content.exists(_.contains("lang=\"nl\"")), s"Did not find expected content in:\n${content.mkString("\n")}") | ||
assert(content.forall(!_.contains("title: \"Document Title\"")), s"Expected front-matter metadata to be removed from the output in:\n${content.mkString("\n")}") | ||
} |
1 change: 1 addition & 0 deletions
1
src/sbt-test/asciidoctor/asciidoctor-skips-frontmatter/project/plugins.sbt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % sys.props("project.version")) |
11 changes: 11 additions & 0 deletions
11
src/sbt-test/asciidoctor/asciidoctor-skips-frontmatter/src/asciidoctor/index.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
title: "Document Title" | ||
--- | ||
|
||
== Hello, AsciiDoc! | ||
Doc Writer <doc@example.com> | ||
:project-version: | ||
|
||
This tests should show that `attributes` are taken into account while rendering. | ||
|
||
This is passed from the sbt build: {project-version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
> makeSite | ||
> checkContent |