From 911a6ab795511ac4c483be6c732b710f5aec967d Mon Sep 17 00:00:00 2001 From: Abel Salgado Romero Date: Wed, 12 Oct 2022 18:11:43 +0200 Subject: [PATCH 1/2] Replace use of deprecated 'numbered' attribute by 'sectnums' Fixes #1120 --- CHANGELOG.adoc | 4 ++++ .../main/java/org/asciidoctor/Attributes.java | 12 +++++----- .../org/asciidoctor/AttributesBuilder.java | 12 +++++----- .../jruby/cli/AsciidoctorCliOptions.java | 2 +- .../WhenAttributesAreUsedInAsciidoctor.java | 5 ++-- .../cli/WhenAsciidoctorAPICallIsCalled.java | 24 ++++++++++--------- 6 files changed, 32 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index bf57c730..6d12d253 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -39,6 +39,10 @@ Bug Fixes:: * Cell nodes do not inherit from StructuralNode (#1086) (@rahmanusta) +Build / Infrastructure:: + +* Replace use of deprecated 'numbered' attribute by 'sectnums' (#1123) (@abelsromero) + == 2.5.4 (2022-06-30) Improvement:: diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java b/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java index 7504277e..5ab82d64 100644 --- a/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java +++ b/asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java @@ -38,7 +38,7 @@ public class Attributes { public static final String ICONFONT_NAME = "iconfont-name"; public static final String ICONS_DIR = "iconsdir"; public static final String DATA_URI = "data-uri"; - public static final String SECTION_NUMBERS = "numbered"; + public static final String SECTION_NUMBERS = "sectnums"; public static final String IMAGE_ICONS = ""; public static final String FONT_ICONS = "font"; public static final String LINK_ATTRS = "linkattrs"; @@ -541,7 +541,7 @@ public void setIconsDir(String iconsDir) { } /** - * auto-number section titles in the HTML backend + * auto-number section titles. * * @param sectionNumbers */ @@ -596,9 +596,9 @@ public void setAttribute(String attributeName, Object attributeValue) { /** * Sets attributes in string form. An example of a valid string would be: * - * 'toc numbered source-highlighter=coderay' + * 'toc sectnums source-highlighter=coderay' * - * where you are adding three attributes: toc, numbered and source-highlighter with value coderay. + * where you are adding three attributes: toc, sectnums and source-highlighter with value coderay. * * @param attributes * in string format. @@ -612,9 +612,9 @@ public void setAttributes(String attributes) { /** * Sets attributes in array form. An example of a valid array would be: * - * '['toc', 'numbered']' + * '['toc', 'sectnums']' * - * where you are adding three attributes: toc and numbered. + * where you are adding two attributes: toc and sectnums. * * @param attributes * in array format. diff --git a/asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java b/asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java index 649e9727..4e5b78fb 100644 --- a/asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java +++ b/asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java @@ -435,10 +435,10 @@ public AttributesBuilder attribute(String attributeName) { } /** - * Auto-number section titles in the HTML backend. + * Auto-number section titles. * * @param sectionNumbers - * true if numbers should be autonumbered, false otherwise. + * true if numbers should be auto-numbered, false otherwise. * @return this instance. */ public AttributesBuilder sectionNumbers(boolean sectionNumbers) { @@ -573,9 +573,9 @@ public AttributesBuilder attributes(Map attributes) { /** * Sets attributes in string form. An example of a valid string would be: * - * 'toc numbered source-highlighter=coderay' + * 'toc sectnums source-highlighter=coderay' * - * where you are adding three attributes: toc, numbered and + * where you are adding three attributes: toc, sectnums and * source-highlighter with value coderay. * * @param attributes @@ -591,9 +591,9 @@ public AttributesBuilder arguments(String attributes) { /** * Sets attributes in array form. An example of a valid array would be: * - * '['toc', 'numbered']' + * '['toc', 'sectnums']' * - * where you are adding three attributes: toc and numbered. + * where you are adding two attributes: toc and sectnums. * * @param attributes * in array format. diff --git a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/cli/AsciidoctorCliOptions.java b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/cli/AsciidoctorCliOptions.java index 724a6539..cc96d104 100644 --- a/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/cli/AsciidoctorCliOptions.java +++ b/asciidoctorj-core/src/main/java/org/asciidoctor/jruby/cli/AsciidoctorCliOptions.java @@ -60,7 +60,7 @@ public class AsciidoctorCliOptions { @Parameter(names = {NO_HEADER_FOOTER, "--no-header-footer"}, description = "suppress output of header and footer (default: false)") private boolean noHeaderFooter = false; - @Parameter(names = {SECTION_NUMBERS, "--section-numbers"}, description = "auto-number section titles in the HTML backend; disabled by default") + @Parameter(names = {SECTION_NUMBERS, "--section-numbers"}, description = "auto-number section titles; disabled by default") private boolean sectionNumbers = false; @Parameter(names = {ERUBY, "--eruby"}, description = "specify eRuby implementation to render built-in templates: [erb, erubis] (default: erb)") diff --git a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java index 672ad877..53d02810 100644 --- a/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java +++ b/asciidoctorj-core/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java @@ -513,7 +513,7 @@ public void setting_linkcss_as_false_in_string_should_embed_css_file() throws IO @Test public void setting_toc_attribute_and_numbered_in_string_form_table_of_contents_should_be_generated() throws IOException { - Attributes attributes = attributes("toc numbered").get(); + Attributes attributes = attributes("toc sectnums").get(); Options options = options().inPlace(false).toDir(testFolder.getRoot()).safe(SafeMode.UNSAFE).attributes(attributes).get(); asciidoctor.convertFile(classpath.getResource("tocsample.asciidoc"), options); @@ -530,8 +530,7 @@ public void setting_toc_attribute_and_numbered_in_string_form_table_of_contents_ @Test public void setting_toc_attribute_and_numbered_in_array_form_table_of_contents_should_be_generated() throws IOException { - Attributes attributes = attributes(new String[] { "toc", "numbered" }) - .get(); + Attributes attributes = attributes(new String[] { "toc", "sectnums" }).get(); Options options = options().inPlace(false).toDir(testFolder.getRoot()).safe(SafeMode.UNSAFE).attributes(attributes).get(); asciidoctor.convertFile(classpath.getResource("tocsample.asciidoc"), options); diff --git a/asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorAPICallIsCalled.java b/asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorAPICallIsCalled.java index 760f0035..00a7045a 100644 --- a/asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorAPICallIsCalled.java +++ b/asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorAPICallIsCalled.java @@ -1,9 +1,7 @@ package org.asciidoctor.jruby.cli; import com.beust.jcommander.JCommander; -import org.asciidoctor.AttributesBuilder; -import org.asciidoctor.OptionsBuilder; -import org.asciidoctor.SafeMode; +import org.asciidoctor.*; import org.asciidoctor.jruby.internal.AsciidoctorUtils; import org.junit.Test; @@ -21,13 +19,17 @@ public class WhenAsciidoctorAPICallIsCalled { @Test public void api_parameters_should_be_transformed_to_cli_command() { - AttributesBuilder attributesBuilder = AttributesBuilder.attributes() - .attribute("myAtribute", "myValue").sectionNumbers(true) - .copyCss(false); + Attributes attributes = Attributes.builder() + .attribute("myAtribute", "myValue") + .sectionNumbers(true) + .copyCss(false) + .build(); - OptionsBuilder optionsBuilder = OptionsBuilder.options() - .backend("docbook").templateDirs(new File("a"), new File("b")) - .safe(SafeMode.UNSAFE).attributes(attributesBuilder.get()); + OptionsBuilder optionsBuilder = Options.builder() + .backend("docbook") + .templateDirs(new File("a"), new File("b")) + .safe(SafeMode.UNSAFE) + .attributes(attributes); List command = AsciidoctorUtils.toAsciidoctorCommand( optionsBuilder.asMap(), "file.adoc"); @@ -45,8 +47,8 @@ public void api_parameters_should_be_transformed_to_cli_command() { assertThat(asciidoctorCliOptions.getBackend(), is("docbook")); assertThat(asciidoctorCliOptions.getParameters(), containsInAnyOrder("file.adoc")); - assertThat(asciidoctorCliOptions.getAttributes(), hasEntry("myAtribute", (Object) "myValue")); - assertThat(asciidoctorCliOptions.getAttributes(), hasKey("numbered")); + assertThat(asciidoctorCliOptions.getAttributes(), hasEntry("myAtribute", "myValue")); + assertThat(asciidoctorCliOptions.getAttributes(), hasKey("sectnums")); assertThat(asciidoctorCliOptions.getAttributes(), hasKey("copycss!")); } From 200ff10e4270332dbbfeb116d13796f871a3ba9b Mon Sep 17 00:00:00 2001 From: Robert Panzer Date: Sun, 16 Oct 2022 15:33:33 +0200 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.adoc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 6d12d253..f85122bd 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -17,6 +17,10 @@ Improvement:: * Upgrade to asciidoctorj 2.0.18 (#1126) +Build / Infrastructure:: + +* Replace use of deprecated 'numbered' attribute by 'sectnums' (#1127) (@abelsromero) + == 2.5.6 (2022-09-19) Improvement:: @@ -39,10 +43,6 @@ Bug Fixes:: * Cell nodes do not inherit from StructuralNode (#1086) (@rahmanusta) -Build / Infrastructure:: - -* Replace use of deprecated 'numbered' attribute by 'sectnums' (#1123) (@abelsromero) - == 2.5.4 (2022-06-30) Improvement::