Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1120 replace deprecated numbered by sectnums v2.5.x #1127

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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::
Expand Down
12 changes: 6 additions & 6 deletions asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -541,7 +541,7 @@ public void setIconsDir(String iconsDir) {
}

/**
* auto-number section titles in the HTML backend
* auto-number section titles.
*
* @param sectionNumbers
*/
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -573,9 +573,9 @@ public AttributesBuilder attributes(Map<String, Object> 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
Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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");
Expand All @@ -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!"));

}
Expand Down