Skip to content

Commit

Permalink
Replace deprecated 'headerFooter' by 'standalone' in configuration
Browse files Browse the repository at this point in the history
* Update tests
* Update docs
* Add section to v3 migration guide

Closes asciidoctor#649
  • Loading branch information
abelsromero committed Jun 15, 2023
1 parent 446f079 commit c3c2585
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Improvements::
* Fix throwing an exception when registering a non Extension (#596)
* Reimplement resource copy using 'plexus.util.DirectorScanner' instead of 'maven-filtering' to reduce dependencies and build time (#597)
* Set minimal Maven version to v3.8.5 (#629)
* Replace deprecated 'headerFooter' by 'standalone' in configuration (#649)

Build / Infrastructure::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<sourceDirectory>src/main/doc</sourceDirectory>
<outputDirectory>target/docs</outputDirectory>
<backend>html</backend>
<headerFooter>false</headerFooter>
<standalone>false</standalone>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<sourceDirectory>src/main/doc</sourceDirectory>
<outputDirectory>target/docs</outputDirectory>
<backend>html</backend>
<headerFooter>false</headerFooter>
<standalone>false</standalone>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
<sourceDirectory>src/main/doc</sourceDirectory>
<outputDirectory>target/docs</outputDirectory>
<backend>html</backend>
<headerFooter>false</headerFooter>
<standalone>false</standalone>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.asciidoctor.jruby.AsciidoctorJRuby;
import org.asciidoctor.jruby.internal.JRubyRuntimeContext;
import org.asciidoctor.maven.commons.AsciidoctorHelper;
import org.asciidoctor.maven.commons.StringUtils;
import org.asciidoctor.maven.extensions.AsciidoctorJExtensionRegistry;
import org.asciidoctor.maven.extensions.ExtensionConfiguration;
import org.asciidoctor.maven.extensions.ExtensionRegistry;
Expand All @@ -31,7 +30,6 @@
import java.nio.file.Path;
import java.util.*;
import java.util.logging.Logger;
import java.util.stream.Collectors;

import static org.asciidoctor.maven.commons.StringUtils.isBlank;
import static org.asciidoctor.maven.process.SourceDirectoryFinder.DEFAULT_SOURCE_DIR;
Expand Down Expand Up @@ -91,8 +89,8 @@ public class AsciidoctorMojo extends AbstractMojo {
@Parameter(property = AsciidoctorMaven.PREFIX + Options.ERUBY)
protected String eruby;

@Parameter(property = AsciidoctorMaven.PREFIX + "headerFooter")
protected boolean headerFooter = true;
@Parameter(property = AsciidoctorMaven.PREFIX + "standalone", defaultValue = "true")
protected boolean standalone = true;

@Parameter(property = AsciidoctorMaven.PREFIX + "templateDirs")
protected List<File> templateDirs = new ArrayList<>();
Expand Down Expand Up @@ -389,7 +387,7 @@ protected OptionsBuilder createOptionsBuilder(AsciidoctorMojo configuration, Att
final OptionsBuilder optionsBuilder = OptionsBuilder.options()
.backend(configuration.getBackend())
.safe(SafeMode.UNSAFE)
.headerFooter(configuration.isHeaderFooter())
.standalone(configuration.standalone)
.mkDirs(true);

if (!isBlank(configuration.getEruby()))
Expand Down Expand Up @@ -510,14 +508,6 @@ public void setAttributes(Map<String, Object> attributes) {
this.attributes = attributes;
}

public boolean isHeaderFooter() {
return headerFooter;
}

public void setHeaderFooter(boolean headerFooter) {
this.headerFooter = headerFooter;
}

public String getTemplateEngine() {
return templateEngine;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ public void should_honor_doctype_set_in_document() throws MojoFailureException,
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "book.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("linkcss", "", "copycss!", "");
mojo.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void should_fail_when_extension_is_not_found_in_classpath() {
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null, "linkcss!", "");
mojo.extensions = Arrays.asList(extensionConfiguration("non.existent.Processor"));
Throwable throwable = Assertions.catchThrowable(mojo::execute);
Expand All @@ -66,7 +66,7 @@ public void should_fail_when_extension_throws_an_uncaught_exception() {
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null, "linkcss!", "");
mojo.extensions = Arrays.asList(extensionConfiguration(FailingPreprocessor.class));
Throwable throwable = Assertions.catchThrowable(mojo::execute);
Expand Down Expand Up @@ -140,7 +140,7 @@ private void shouldRegisterAndRunExtension(String extensionClassName, String ini
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = singletonList(extensionConfiguration("org.asciidoctor.maven.test.processors." + extensionClassName));
mojo.execute();
Expand All @@ -163,7 +163,7 @@ public void should_convert_to_html_with_a_preprocessor() throws MojoFailureExcep
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = Arrays.asList(extensionConfiguration(ChangeAttributeValuePreprocessor.class));
mojo.execute();
Expand All @@ -184,7 +184,7 @@ public void should_convert_to_html_with_a_blockprocessor() throws MojoFailureExc
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = singletonList(extensionConfiguration(YellBlockProcessor.class, "yell"));
mojo.execute();
Expand All @@ -205,7 +205,7 @@ public void should_convert_to_html_and_add_meta_tag_with_a_DocinfoProcessor() th
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = singletonList(extensionConfiguration(MetaDocinfoProcessor.class, "yell"));
mojo.execute();
Expand All @@ -226,7 +226,7 @@ public void should_convert_to_html_and_modify_output_with_a_BlockMacroProcessor(
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = singletonList(extensionConfiguration(GistBlockMacroProcessor.class, "gist"));
mojo.execute();
Expand All @@ -247,7 +247,7 @@ public void should_convert_to_html_and_modify_output_with_a_InlineMacroProcessor
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = singletonList(extensionConfiguration(ManpageInlineMacroProcessor.class, "man"));
mojo.execute();
Expand All @@ -268,7 +268,7 @@ public void should_convert_to_html_and_modify_output_with_an_IncludeProcessor()
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = singletonList(extensionConfiguration(UriIncludeProcessor.class));
mojo.execute();
Expand All @@ -290,7 +290,7 @@ public void should_run_the_same_preprocessor_twice_when_registered_twice() throw
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = Arrays.asList(
extensionConfiguration(ChangeAttributeValuePreprocessor.class),
Expand Down Expand Up @@ -320,7 +320,7 @@ public void should_convert_to_html_with_Preprocessor_DocinfoProcessor_InlineMacr
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.extensions = Arrays.asList(
extensionConfiguration("org.asciidoctor.maven.test.processors.ChangeAttributeValuePreprocessor"),
Expand Down Expand Up @@ -348,7 +348,7 @@ public void should_convert_to_html_using_all_extension_types() throws MojoFailur
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", "",
"linkcss", "",
"copycss!", "");
Expand Down Expand Up @@ -386,7 +386,7 @@ public void property_extension() throws MojoFailureException, MojoExecutionExcep
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = "processors-sample.adoc";
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null, "linkcss!", "");
mojo.execute();
// then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void should_not_fail_when_logHandler_is_not_set() throws MojoFailureExcep
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.execute();

Expand All @@ -64,7 +64,7 @@ public void should_show_Asciidoctor_messages_as_info_by_default() throws MojoFai
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.execute();

Expand Down Expand Up @@ -105,7 +105,7 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set()
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.execute();

Expand Down Expand Up @@ -148,7 +148,7 @@ public void should_not_fail_and_log_errors_as_INFO_when_outputToConsole_is_set_a
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.enableVerbose = true;
mojo.execute();
Expand Down Expand Up @@ -188,7 +188,7 @@ public void should_not_fail_and_log_verbose_errors_when_gempath_is_set() throws
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.enableVerbose = true;
mojo.gemPath = System.getProperty("java.io.tmpdir");
Expand Down Expand Up @@ -226,7 +226,7 @@ public void should_fail_when_logHandler_failIf_is_WARNING() {
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
Throwable throwable = catchThrowable(mojo::execute);

Expand All @@ -253,7 +253,7 @@ public void should_fail_when_logHandler_failIf_is_ERROR() {
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
Throwable throwable = catchThrowable(mojo::execute);

Expand All @@ -280,7 +280,7 @@ public void should_not_fail_if_containsText_does_not_match_any_message() throws
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.execute();

Expand Down Expand Up @@ -308,7 +308,7 @@ public void should_fail_when_containsText_matches() {
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
Throwable throwable = catchThrowable(mojo::execute);

Expand Down Expand Up @@ -354,7 +354,7 @@ public void should_fail_and_filter_errors_that_match_both_severity_and_text() {
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
Throwable throwable = catchThrowable(mojo::execute);

Expand Down Expand Up @@ -390,7 +390,7 @@ public void should_not_print_default_AsciidoctorJ_messages() throws MojoFailureE
mojo.sourceDirectory = srcDir;
mojo.sourceDocumentName = sourceDocument;
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null);
mojo.execute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public void should_convert_to_html_with_attributes() throws MojoFailureException
mojo.sourceDocumentName = "sample.asciidoc";
mojo.resources = excludeAll();
mojo.outputDirectory = outputDir;
mojo.headerFooter = true;
mojo.standalone = true;
mojo.attributes = map("toc", null,
"linkcss!", "",
"source-highlighter", "coderay");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ public void should_convert_additional_sources_when_set_in_refreshOn() throws IOE

// when
Thread mojoThread = runMojoAsynchronously(mojo -> {
mojo.headerFooter = false;
mojo.standalone = false;
mojo.backend = "html5";
mojo.sourceDirectory = srcDir;
mojo.outputDirectory = outputDir;
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/plugin/pages/usage.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ An example of this setup is below:
</executions>
<configuration> <!--.-->
<sourceDirectory>src/main/asciidoc</sourceDirectory>
<headerFooter>true</headerFooter>
<standalone>true</standalone>
</configuration>
</plugin>
----
Expand Down

0 comments on commit c3c2585

Please sign in to comment.