use of org.eclipse.ceylon.common.tools.help.model.Option in project ceylon by eclipse.
the class DocBuilder method buildOptions.
private OptionsSection buildOptions(ToolModel<?> model) {
if (!(model instanceof AnnotatedToolModel))
return null;
final HashMap<ToolModel<?>, OptionsSection> map = new HashMap<>();
new SubtoolVisitor(model) {
@Override
protected void visit(ToolModel<?> model, SubtoolModel<?> subtoolModel) {
OptionsSection optionsSection = new OptionsSection();
map.put(model, optionsSection);
if (model == root) {
optionsSection.setTitle(Markdown.markdown("##" + CeylonHelpToolMessages.msg("section.OPTIONS")));
} else {
optionsSection.setTitle(Markdown.markdown("###" + CeylonHelpToolMessages.msg("section.OPTIONS.sub", model.getName())));
}
List<Option> options = new ArrayList<>();
for (OptionModel<?> opt : sortedOptions(model.getOptions())) {
Option option = new Option();
option.setOption(opt);
String descriptionMd = getOptionDescription(model, opt);
if (descriptionMd == null || descriptionMd.isEmpty()) {
descriptionMd = CeylonHelpToolMessages.msg("option.undocumented");
}
option.setDescription(Markdown.markdown(descriptionMd));
options.add(option);
}
optionsSection.setOptions(options);
if (model != root && !options.isEmpty()) {
OptionsSection parent = map.get(ancestors.lastElement().getModel());
ArrayList<OptionsSection> parentSubsections = new ArrayList<OptionsSection>(parent.getSubsections());
parentSubsections.add(optionsSection);
parent.setSubsections(parentSubsections);
}
}
}.accept();
return map.get(model);
}
Aggregations