Skip to content

Commit

Permalink
Remove invalid destinationDir option from API
Browse files Browse the repository at this point in the history
The option only is used for the CLI, in that case
the value is redirected to 'to_dir'.

Fixes asciidoctor#853
Fixes asciidoctor#941
  • Loading branch information
abelsromero committed Mar 30, 2023
1 parent 44b5776 commit 369acd8
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Bug Fixes::
* BREAKING: Fix CLI target file location for source files relative to source dir (#1135) (@AlexCzar)
* Cell nodes do not inherit from StructuralNode (#1086) (@rahmanusta)
* Avoid throwing an exception when using AsciidoctorJ CLI and reading input from stdin (#1105) (@AlexCzar)
* Remove destinationDir Option from API (use toDir instead) (#853, #941) (@abelsromero)

Build Improvement::

Expand Down
5 changes: 0 additions & 5 deletions asciidoctorj-api/src/main/java/org/asciidoctor/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public class Options {
public static final String ERUBY = "eruby";
public static final String CATALOG_ASSETS = "catalog_assets";
public static final String COMPACT = "compact";
public static final String DESTINATION_DIR = "destination_dir";
public static final String SOURCE_DIR = "source_dir";
public static final String BACKEND = "backend";
public static final String DOCTYPE = "doctype";
Expand Down Expand Up @@ -171,10 +170,6 @@ public void setCompact(boolean compact) {
this.options.put(COMPACT, compact);
}

public void setDestinationDir(String destinationDir) {
this.options.put(DESTINATION_DIR, destinationDir);
}

public void setSourceDir(String srcDir) {
this.options.put(SOURCE_DIR, srcDir);
}
Expand Down
45 changes: 19 additions & 26 deletions asciidoctorj-api/src/main/java/org/asciidoctor/OptionsBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public OptionsBuilder attributes(Attributes attributes) {
this.options.setAttributes(attributes);
return this;
}

/**
* Sets attributes used for rendering input.
* @deprecated Use {@link #attributes(Attributes)} instead.
Expand Down Expand Up @@ -232,8 +232,9 @@ public OptionsBuilder safe(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).
*
* 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.
* @return this instance.
Expand All @@ -254,10 +255,13 @@ public OptionsBuilder eruby(String eruby) {
this.options.setEruby(eruby);
return this;
}

/**
* 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).
*
* 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.
* @return this instance.
Expand All @@ -280,8 +284,9 @@ public OptionsBuilder compact(boolean compact) {
}

/**
* 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.
*
* 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.
* @return this instance.
Expand All @@ -303,22 +308,10 @@ public OptionsBuilder parseHeaderOnly(boolean parseHeaderOnly) {
return this;
}

/**
* Destination output directory.
*
* @param destinationDir
* destination directory.
* @return this instance.
*/
public OptionsBuilder destinationDir(File destinationDir) {
this.options.setDestinationDir(destinationDir.getAbsolutePath());
return this;
}

/**
* Source directory.
*
* This must be used alongside {@link #destinationDir(File)}.
* This must be used alongside {@link #toDir(File)}.
*
* @param srcDir
* source directory.
Expand All @@ -342,7 +335,7 @@ public OptionsBuilder option(String option, Object value) {
this.options.setOption(option, value);
return this;
}

/**
* Sets base dir for working directory.
*
Expand All @@ -359,24 +352,24 @@ public OptionsBuilder baseDir(File baseDir) {
* Gets a map with configured options.
* @deprecated Use {@link #build()} instead.
*
* @return map with all options. By default an empty map is returned.
* @return map with all options. By default, an empty map is returned.
*/
@Deprecated
public Map<String, Object> asMap() {
return this.options.map();
}

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

/**
* Returns a valid Options instance.
*
*
* @return options instance.
*/
public Options build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public class AsciidoctorUtils {
* See class 'org.asciidoctor.jruby.cli.AsciidoctorCliOptions'
*/
private class CliOptions {
private static final String DESTINATION_DIR_LONG = "destination_dir";

private static final String DESTINATION_DIR = "-D";
private static final String BASE_DIR = "-B";
private static final String TEMPLATE_DIR = "-T";
Expand Down Expand Up @@ -58,9 +60,9 @@ private static List<String> getOptions(Map<String, Object> options) {

List<String> optionsAndAttributes = new ArrayList<>();

if (options.containsKey(Options.DESTINATION_DIR)) {
if (options.containsKey(CliOptions.DESTINATION_DIR_LONG)) {
optionsAndAttributes.add(CliOptions.DESTINATION_DIR);
optionsAndAttributes.add(options.get(Options.DESTINATION_DIR).toString());
optionsAndAttributes.add(options.get(CliOptions.DESTINATION_DIR_LONG).toString());
}

if (options.containsKey(Options.BASEDIR)) {
Expand Down

0 comments on commit 369acd8

Please sign in to comment.