Skip to content

Commit

Permalink
closes asciidoctor#417: removes attributeMissing option in favour of …
Browse files Browse the repository at this point in the history
…attributes configuration
  • Loading branch information
abelsromero committed Jun 16, 2020
1 parent 6607997 commit 877555c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
21 changes: 21 additions & 0 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,27 @@ To run all tests at once just use `mvn clean verify -DskipTests -Prun-its`.

== Tips & Tricks

=== Fail on missing attributes

Attributes whose value cannot be resolved are ignored by default and they don't show as error or warning.
If you need to, this behaviour can be modified using the https://asciidoctor.org/docs/user-manual/#missing-attribute[missing-attribute] attribute.

Combining it with logHandler option it is possible to report an error and abort a build in case of missing attributes.

[source, xml]
----
<configuration>
<attributes>
<attribute-missing>warn</attribute-missing>
</attributes>
<logHandler>
<failIf>
<severity>WARN</severity>
</failIf>
</logHandler>
</configuration>
----

=== Generate your documentation in separate folders per version

Use Maven `project.version` property to create dedicated custom output directories.
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/org/asciidoctor/maven/AsciidoctorMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,6 @@ protected void setAttributesOnBuilder(AttributesBuilder attributesBuilder) throw
attributesBuilder.dataUri(true);
}

if ("skip".equals(attributeMissing) || "drop".equals(attributeMissing) || "drop-line".equals(attributeMissing)) {
attributesBuilder.attributeMissing(attributeMissing);
} else {
throw new MojoExecutionException(attributeMissing + " is not valid. Must be one of 'skip', 'drop' or 'drop-line'");
}

if ("drop".equals(attributeUndefined) || "drop-line".equals(attributeUndefined)) {
attributesBuilder.attributeUndefined(attributeUndefined);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class AsciidoctorMojoTest extends Specification {
mojo.sourceDirectory = srcDir
mojo.sourceDocumentName = 'attribute-missing.adoc'
mojo.backend = 'html'
mojo.attributeMissing = 'skip'
mojo.attributes = ['attribute-missing':'skip']
mojo.execute()
then:
File sampleOutput = new File(outputDir, 'attribute-missing.html')
Expand All @@ -363,7 +363,7 @@ class AsciidoctorMojoTest extends Specification {
mojo.sourceDirectory = srcDir
mojo.sourceDocumentName = 'attribute-missing.adoc'
mojo.backend = 'html'
mojo.attributeMissing = 'drop'
mojo.attributes = ['attribute-missing':'drop']
mojo.execute()
then:
File sampleOutput = new File(outputDir, 'attribute-missing.html')
Expand All @@ -385,7 +385,7 @@ class AsciidoctorMojoTest extends Specification {
mojo.sourceDirectory = srcDir
mojo.sourceDocumentName = 'attribute-missing.adoc'
mojo.backend = 'html'
mojo.attributeMissing = 'drop-line'
mojo.attributes = ['attribute-missing':'drop-line']
mojo.execute()
then:
File sampleOutput = new File(outputDir, 'attribute-missing.html')
Expand Down

0 comments on commit 877555c

Please sign in to comment.