Skip to content

Commit

Permalink
Merge pull request asciidoctor#1200 from abelsromero/issue-1199-remov…
Browse files Browse the repository at this point in the history
…e-deprecated-from-options-and-attributes

Remove deprecated methods in Options, OptionsBuilder, Attributes & AttributesBuilder
  • Loading branch information
robertpanzer committed May 29, 2023
2 parents db91334 + 4d1ddc7 commit 1e3aa53
Show file tree
Hide file tree
Showing 65 changed files with 1,031 additions and 827 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Improvement::
* Expose ImageReferences in the catalog (#1166) (@abelsromero)
* Return Document AST when using convert or convertFile with appropriate options (#1171) (@abelsromero)
* Expose Links in the catalog (#1183) (@abelsromero)
* BREAKING: Remove deprecated methods in Options, OptionsBuilder, Attributes & AttributesBuilder (#1199) (@abelsromero)

Bug Fixes::

Expand Down
47 changes: 2 additions & 45 deletions asciidoctorj-api/src/main/java/org/asciidoctor/Attributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
public class Attributes {

private static final char ATTRIBUTE_SEPARATOR = '=';

private static Format DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
private static Format TIME_FORMAT = new SimpleDateFormat("HH:mm:ss z");

public static final String TOC = "toc";
public static final String TOC_POSITION = "toc-position";
public static final String TOC_LEVELS = "toclevels";
public static final String TOC_2 = "toc2";
public static final String BACKEND = Options.BACKEND;
public static final String TITLE = "title";
public static final String DOCTYPE = Options.DOCTYPE;
Expand Down Expand Up @@ -64,38 +63,9 @@ public class Attributes {

private Map<String, Object> attributes = new LinkedHashMap<>();

/**
* @deprecated Use {@link #builder} instead.
*/
@Deprecated
public Attributes() {
super();
Attributes() {
}

/**
* @deprecated Use {@link #builder} instead.
*/
@Deprecated
public Attributes(Map<String, Object> attributes) {
this.attributes = attributes;
}

/**
* @deprecated Use {@link #builder} instead.
*/
@Deprecated
public Attributes(String[] attributes) {
this.setAttributes(attributes);
}

/**
* @deprecated Use {@link #builder} instead.
*/
@Deprecated
public Attributes(String attributes) {
this.setAttributes(attributes);
}

/**
* @return Empty AttributesBuilder instance.
*/
Expand Down Expand Up @@ -328,19 +298,6 @@ public void setIgnoreUndefinedAttributes(boolean ignoreUndefinedAttributes) {
this.attributes.put(IGNORE_UNDEFINED, toAsciidoctorFlag(ignoreUndefinedAttributes));
}

/**
* Sets table of contents 2 attribute.
*
* @param placement
* where toc is rendered.
* @deprecated Use {@link #setTableOfContents(Placement)}
*/
@Deprecated
public void setTableOfContents2(Placement placement) {
this.attributes.put(TOC_2, toAsciidoctorFlag(true));
this.attributes.put(TOC_POSITION, placement.getPosition());
}

/**
* Sets if a table of contents should be rendered or not.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.net.URI;
import java.util.Date;
import java.util.Map;

public class AttributesBuilder {

Expand All @@ -12,43 +11,6 @@ public class AttributesBuilder {
super();
}

/**
* Creates attributes builder.
* @deprecated Use {@link Attributes#builder()} instead.
*
* @return attributes builder.
*/
@Deprecated
public static AttributesBuilder attributes() {
return new AttributesBuilder();
}

/**
* Creates attributes builder.
* @deprecated Use {@link Attributes#builder()} with {@link #arguments(String...)} instead.
*
* @return attributes builder.
*/
@Deprecated
public static AttributesBuilder attributes(String[] arguments) {
AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.arguments(arguments);
return attributesBuilder;
}

/**
* Creates attributes builder.
* @deprecated Use {@link Attributes#builder()} with {@link #arguments(String)} instead.
*
* @return attributes builder.
*/
@Deprecated
public static AttributesBuilder attributes(String arguments) {
AttributesBuilder attributesBuilder = new AttributesBuilder();
attributesBuilder.arguments(arguments);
return attributesBuilder;
}

/**
* Source language attribute.
* @param sourceLanguage value.
Expand Down Expand Up @@ -149,18 +111,6 @@ public AttributesBuilder tableOfContents(Placement placement) {
return this;
}

/**
* Sets table of contents 2 attribute.
* @param placement where toc is rendered.
* @return this instance.
* @deprecated Use {@link #tableOfContents(Placement)}
*/
@Deprecated
public AttributesBuilder tableOfContents2(Placement placement) {
this.attributes.setTableOfContents2(placement);
return this;
}

/**
* Sets allow uri read attribute.
* @param allowUriRead value.
Expand Down Expand Up @@ -558,29 +508,17 @@ public AttributesBuilder attribute(String attributeName, Object attributeValue)
return this;
}

/**
* Adds all attributes.
*
* @param attributes
* map.
* @return this instance.
*/
public AttributesBuilder attributes(Map<String, Object> attributes) {
this.attributes.setAttributes(attributes);
return this;
}

/**
* Sets attributes in string form. An example of a valid string would be:
*
*
* 'toc sectnums source-highlighter=coderay'
*
*
* where you are adding three attributes: toc, sectnums and
* source-highlighter with value coderay.
*
*
* @param attributes
* in string format.
*
*
* @return this instance.
*/
public AttributesBuilder arguments(String attributes) {
Expand All @@ -590,40 +528,21 @@ public AttributesBuilder arguments(String attributes) {

/**
* Sets attributes in array form. An example of a valid array would be:
*
*
* '['toc', 'sectnums']'
*
*
* where you are adding two attributes: toc and sectnums.
*
*
* @param attributes
* in array format.
*
*
* @return this instance.
*/
public AttributesBuilder arguments(String... attributes) {
this.attributes.setAttributes(attributes);
return this;
}

/**
* Gets a map with configured options.
* @deprecated Use {@link #build()} instead.
*
* @return map with all options. By default an empty map is returned.
*/
@Deprecated
public Map<String, Object> asMap() {
return this.attributes.map();
}

/**
* @deprecated Use {@link #build()} instead.
*/
@Deprecated
public Attributes get() {
return this.attributes;
}

/**
* Returns a valid Attributes instance.
*
Expand Down
36 changes: 10 additions & 26 deletions asciidoctorj-api/src/main/java/org/asciidoctor/Options.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
package org.asciidoctor;

import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;

/**
* AsciidoctorJ conversion options. Each one maps to an option in Asciidoctor.
* AsciidoctorJ conversion options.
* <p>
* See https://docs.asciidoctor.org/asciidoctor/latest/api/options/ for further
* details.
*/
Expand Down Expand Up @@ -38,20 +35,7 @@ public class Options {

private Map<String, Object> options = new HashMap<>();

/**
* @deprecated Use {@link Options#builder()} instead.
*/
@Deprecated
public Options() {
super();
}

/**
* @deprecated Use {@link Options#builder()} instead.
*/
@Deprecated
public Options(Map<String, Object> options) {
this.options = options;
Options() {
}

/**
Expand All @@ -60,7 +44,7 @@ public Options(Map<String, Object> options) {
public static OptionsBuilder builder() {
return new OptionsBuilder();
}

public void setInPlace(boolean inPlace) {
this.options.put(IN_PLACE, inPlace);
}
Expand Down Expand Up @@ -117,7 +101,7 @@ public void setToStream(OutputStream toStream) {
}

/**
* Toogle writing output to a file.
* Toggle writing output to a file.
*
* @param toFile If <code>true</true>, write output to a file in the same directory
* as the input file, including header and footer into the output. If
Expand All @@ -140,7 +124,7 @@ public void setMkDirs(boolean mkDirs) {

/**
* Safe method calls safeMode.getLevel() to put the required level.
*
*
* @param safeMode
* enum.
*/
Expand All @@ -150,7 +134,7 @@ public void setSafe(SafeMode safeMode) {

/**
* Keeps track of the file and line number for each parsed block. (Useful for tooling applications where the association between the converted output and the source file is important).
*
*
* @param sourcemap
* value.
*/
Expand All @@ -164,7 +148,7 @@ public void setEruby(String eruby) {

/**
* If true, tells the parser to capture images and links in the reference table. (Normally only IDs, footnotes and indexterms are included). The reference table is available via the references property on the document AST object. (Experimental).
*
*
* @param catalogAssets
* value.
*/
Expand Down Expand Up @@ -198,7 +182,7 @@ public void setTemplateCache(boolean templateCache) {

/**
* If true, the source is parsed eagerly (i.e., as soon as the source is passed to the load or load_file API). If false, parsing is deferred until the parse method is explicitly invoked.
*
*
* @param parse
* value.
*/
Expand Down
Loading

0 comments on commit 1e3aa53

Please sign in to comment.