Skip to content

Commit

Permalink
Improve the toFile documentation about file vs. string output
Browse files Browse the repository at this point in the history
Closes #502.
  • Loading branch information
sschuberth authored and robertpanzer committed Sep 6, 2016
1 parent d169243 commit 07fed40
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
25 changes: 25 additions & 0 deletions asciidoctorj-core/src/main/java/org/asciidoctor/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public void setAttributes(Map<String, Object> attributes) {
this.options.put(ATTRIBUTES, attributes);
}

/**
* Toggle including header and footer into the output.
*
* @param headerFooter If <code>true</true>, include header and footer into the output,
* otherwise exclude them. This overrides any output-specific defaults.
*
*/
public void setHeaderFooter(boolean headerFooter) {
this.options.put(HEADER_FOOTER, headerFooter);
}
Expand All @@ -68,6 +75,14 @@ public void setTemplateEngine(String templateEngine) {
this.options.put(TEMPLATE_ENGINE, templateEngine);
}

/**
* Enable writing output to a file. The file includes header and footer by default.
*
* @param toFile The path to the output file. If the path is not absolute, it is
* interpreted relative to what was set via {@link #setToDir()}
* or {@link #setBaseDir()}, in that order.
*
*/
public void setToFile(String toFile) {
this.options.put(TO_FILE, toFile);
}
Expand All @@ -76,6 +91,16 @@ public void setToStream(OutputStream toStream) {
this.options.put(TO_FILE, toStream);
}

/**
* Toogle 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
* <code>false</code>, return output as a string without any header or
* footer. The default header and footer visibility can be overridden
* using {@link #setHeaderFooter()}.
*
*/
public void setToFile(boolean toFile) {
this.options.put(TO_FILE, toFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,13 @@ public OptionsBuilder attributes(AttributesBuilder attributes) {
}

/**
* Sets to file value. This is the destination file name.
* Sets to file value. This toggles writing output to a file or returning output
* as a string. If writing to a string, the header and footer are omitted from the
* output by default.
*
* @param toFile
* name of output file.
* <code>true</code> to write output to a file, <code>false</code>
* to write output to a string.
* @return this instance.
*/
public OptionsBuilder toFile(boolean toFile) {
Expand Down

0 comments on commit 07fed40

Please sign in to comment.