use of org.eclipse.ceylon.common.tools.help.model.Visitor in project ceylon by eclipse.
the class CeylonDocToolTool method generateDoc.
private void generateDoc(List<Doc> docs) throws IOException {
for (Doc doc : docs) {
File out = new File(applyCwd(dir), filename(doc));
try (FileWriter writer = new FileWriter(out)) {
Visitor visitor = format.newOutput(this, writer);
doc.accept(visitor);
}
}
if (index && format == Format.html) {
generateIndexHtml(docs);
}
}
use of org.eclipse.ceylon.common.tools.help.model.Visitor in project ceylon by eclipse.
the class CeylonHelpTool method run.
@Override
public void run() {
if (wantsPager && OSUtil.isWindows() && tool != null) {
if (openHelpInBrowser()) {
return;
}
}
docBuilder.setIncludeHidden(includeHidden);
Doc doc;
if (tool != null) {
doc = docBuilder.buildDoc(tool);
} else {
final ToolModel<CeylonTool> root = toolLoader.loadToolModel("");
doc = docBuilder.buildDoc(root, true);
}
Process pagerProcess = null;
if (wantsPager && !OSUtil.isWindows()) {
pagerProcess = startPager();
}
OutputStream pagerPipe = null;
if (pagerProcess != null)
pagerPipe = pagerProcess.getOutputStream();
try {
final WordWrap wrap = getWrap(pagerPipe);
Visitor plain = new PlainVisitor(wrap);
if (synopsis) {
plain = new SynopsisOnlyVisitor(plain);
} else if (options != null) {
plain = new OptionsOnlyVisitor(plain, new HashSet<String>(Arrays.asList(options.trim().split("\\s*,\\s*"))));
}
doc.accept(plain);
wrap.flush();
} finally {
// shutdown pager
if (pagerPipe != null) {
try {
pagerPipe.close();
} catch (IOException e) {
// Seems common on MacOS so let's just ignore this
}
// wait for pager to be done, there's no point doing anything else meanwhile
try {
int errorCode = pagerProcess.waitFor();
if (errorCode != 0) {
throw new ToolUsageError("Pager process returned an error exit code: " + errorCode + ". Try fixing your $CEYLON_PAGER or $PAGER environment variable or invoke with the --no-pager command-line option.");
}
} catch (InterruptedException e) {
throw new ToolUsageError("Pager process interrupted. Try fixing your $CEYLON_PAGER or $PAGER environment variable or invoke with the --no-pager command-line option.");
}
}
}
}
Aggregations