use of org.eclipse.ceylon.common.tool.OptionModel in project ceylon by eclipse.
the class DocBuilder method buildRootSynopsis.
private SynopsesSection buildRootSynopsis(ToolModel<?> model) {
SynopsesSection synopsis = new SynopsesSection();
synopsis.setTitle(CeylonHelpToolMessages.msg("section.SYNOPSIS"));
List<Synopsis> synopsisList = new ArrayList<>();
{
Synopsis s1 = new Synopsis();
s1.setInvocation(Tools.progName());
OptionModel<Boolean> option = new OptionModel<>();
option.setLongName("version");
option.setArgumentType(ArgumentType.BOOLEAN);
ArgumentModel<Boolean> argument = new ArgumentModel<>();
argument.setMultiplicity(Multiplicity._1);
argument.setType(Boolean.TYPE);
option.setArgument(argument);
// model.getOption("version")));
s1.setOptionsAndArguments(Collections.singletonList(option));
synopsisList.add(s1);
}
{
Synopsis s2 = new Synopsis();
s2.setInvocation(Tools.progName());
ArrayList<Object> args = new ArrayList<Object>(model.getOptions());
args.remove(model.getOption("version"));
/*ArgumentModel<?> options = new ArgumentModel();
options.setMultiplicity(Multiplicity._0_OR_MORE);
options.setName("cey\u2011options");
args.add(options);*/
ArgumentModel<?> command = new ArgumentModel<>();
command.setMultiplicity(Multiplicity._1);
command.setName("command");
args.add(command);
ArgumentModel<?> commandOptions = new ArgumentModel<>();
commandOptions.setMultiplicity(Multiplicity._0_OR_MORE);
commandOptions.setName("command\u2011options");
args.add(commandOptions);
ArgumentModel<?> commandArgs = new ArgumentModel<>();
commandArgs.setMultiplicity(Multiplicity._0_OR_MORE);
commandArgs.setName("command\u2011args");
args.add(commandArgs);
s2.setOptionsAndArguments(args);
synopsisList.add(s2);
}
synopsis.setSynopses(synopsisList);
return synopsis;
}
use of org.eclipse.ceylon.common.tool.OptionModel 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