Replace use of deprecated 'numbered' attribute by 'sectnums'
Fixes
MODIFY
CHANGELOG.adoc
CHANGELOG.adoc
@@ -33,6 +33,10 @@ Build Improvement::
* Upgrade build to Gradle 7.5.1 (#1109)
* Fix upstream tests forcing SNAPSHOT on Asciidoctor gem installation (#1123) (@abelsromero)
+Build / Infrastructure::
+
+* Replace use of deprecated 'numbered' attribute by 'sectnums' (#1123) (@abelsromero)
+
== 2.5.4 (2022-06-30)
Improvement::

MODIFY
asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java
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 class Attributes {
}
/**
- * auto-number section titles in the HTML backend
+ * auto-number section titles.
*
* @param sectionNumbers
*/
@@ -596,9 +596,9 @@ public class 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 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 class 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.

MODIFY
asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java
asciidoctorj-api/src/main/java/org/asciidoctor/AttributesBuilder.java
@@ -435,10 +435,10 @@ public class AttributesBuilder {
}
/**
- * 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 class AttributesBuilder {
/**
* 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 class AttributesBuilder {
/**
* 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.

MODIFY
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/cli/AsciidoctorCliOptions.java
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)")

MODIFY
asciidoctorj-core/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java
asciidoctorj-core/src/test/java/org/asciidoctor/WhenAttributesAreUsedInAsciidoctor.java
@@ -513,7 +513,7 @@ public class WhenAttributesAreUsedInAsciidoctor {
@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 class WhenAttributesAreUsedInAsciidoctor {
@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);

MODIFY
asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorAPICallIsCalled.java
asciidoctorj-core/src/test/java/org/asciidoctor/jruby/cli/WhenAsciidoctorAPICallIsCalled.java
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<String> command = AsciidoctorUtils.toAsciidoctorCommand(
optionsBuilder.asMap(), "file.adoc");
@@ -45,8 +47,8 @@ public class WhenAsciidoctorAPICallIsCalled {
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!"));
}

Replace use of deprecated 'numbered' attribute by 'sectnums'

Fixes #1120