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

Add simple API to invoke DITA-OT from Java #2604

Merged
merged 9 commits into from Feb 20, 2017
Merged

Add simple API to invoke DITA-OT from Java #2604

merged 9 commits into from Feb 20, 2017

Conversation

jelovirt
Copy link
Member

@jelovirt jelovirt commented Feb 17, 2017

A Java API can be use invoke DITA-OT from Java code without needing to have knowledge about the internals of DITA-OT, like Ant.

Usage

final ProcessorFactory pf = ProcessorFactory.newInstance(ditaDir);
pf.setTempDir(absoluteBaseTempDir);
final Processor p = pf.newProcessor("html5");
try {
  p.setInput(absoluteInputmapFile)
   .setOutputDir(absoluteOutputDir)
   .cleanOnFailure(false)
   .setMode(Mode.LAX)
   .setProperty("brand", "acme")
   .setLogger(logger)
   .run();
} catch (DITAOTException e) {
  logger.error("Failed to process: " + e.getMessage());
}

The Processor object is reusable but not thread-safe.

@jelovirt jelovirt added feature New feature or request priority/medium Medium (or unknown) priority issue labels Feb 17, 2017
@jelovirt jelovirt added this to the 2.5 milestone Feb 17, 2017
@jelovirt jelovirt self-assigned this Feb 17, 2017
@jelovirt
Copy link
Member Author

Should we provide setters for the same properties as we have options for in the dita command? That is, should we add remaining setters for

  • setFilter(File)
  • setTempDir(File) for the exact temporary directory, not the base directory for timestampped directories

@jelovirt
Copy link
Member Author

jelovirt commented Feb 17, 2017

Should we have a toggle to also write log file into the temporary directory, with e.g. name log.txt. We still want to keep the normal logger setter, but this would help in debugging. The log file in temporary directory would be written with verbose logging level. This could be combined with e.g. cleanOnFailure(boolean) method to retain the temporary directory on failure.

@robander
Copy link
Member

Looks good to me.

For the questions above - I think it would be good to have setters for the same options available to dita. Those seem to be the most common, particularly the filter parameter that's really a critical set of info about the content. I don't think they're required, but good idea.

Overall -- looks very useful and I'm wondering if some of my team will want to make use of this as well.

@jelovirt jelovirt merged commit 2551f63 into develop Feb 20, 2017
@jelovirt jelovirt deleted the feature/api branch February 20, 2017 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request priority/medium Medium (or unknown) priority issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants