use of org.eclipse.ceylon.common.tools.help.model.DescribedSection in project ceylon by eclipse.
the class DocBuilder method buildDescription.
private DescribedSection buildDescription(ToolModel<?> model, String description) {
DescribedSection section = null;
if (!description.isEmpty()) {
section = new DescribedSection();
section.setRole(Role.DESCRIPTION);
section.setTitle(Markdown.markdown("## " + CeylonHelpToolMessages.msg("section.DESCRIPTION") + "\n"));
section.setDescription(Markdown.markdown(description));
}
return section;
}
use of org.eclipse.ceylon.common.tools.help.model.DescribedSection in project ceylon by eclipse.
the class DocBuilder method buildRootDescription.
private DescribedSection buildRootDescription(ToolModel<?> rootModel) {
StringBuilder sb = new StringBuilder();
final String newline = "\n";
sb.append(newline);
sb.append(newline);
for (String toolName : toolLoader.getToolNames()) {
final ToolModel<?> model = toolLoader.loadToolModel(toolName);
if (model == null) {
throw new RuntimeException(toolName);
}
if (!model.isPorcelain() && !includeHidden) {
continue;
}
sb.append("* `").append(toolName).append("` - ");
String summary = getSummaryValue(model);
if (summary != null) {
sb.append(summary);
}
sb.append(newline);
sb.append(newline);
}
sb.append(newline);
sb.append(CeylonHelpToolMessages.getMoreInfo());
sb.append(newline);
sb.append(newline);
String both = getDescription(rootModel) + sb.toString();
DescribedSection description = buildDescription(rootModel, both);
return description;
}
use of org.eclipse.ceylon.common.tools.help.model.DescribedSection in project ceylon by eclipse.
the class DocBuilder method buildAdditionalSections.
private List<DescribedSection> buildAdditionalSections(ToolModel<?> model) {
List<DescribedSection> additionalSections = new ArrayList<DescribedSection>();
String sections = getSections(model);
if (sections != null && !sections.isEmpty()) {
Document doc = Markdown.markdown(sections);
List<Section> markdownSections = Markdown.extractSections(doc);
for (Markdown.Section sect : markdownSections) {
DescribedSection ds = new DescribedSection();
ds.setRole(Role.ADDITIONAL);
Document sectionDoc = sect.getDoc();
if (sect.getHeading() == null) {
// TODO Warn that there were no section headings
continue;
} else {
// Adjust the heading levels, so that the most prominent
// heading is H2
Markdown.adjustHeadings(sectionDoc, 2 - sect.getHeading().getLevel());
}
ds.setTitle(sect.getHeading());
ds.setDescription(sectionDoc);
additionalSections.add(ds);
}
}
return additionalSections;
}
use of org.eclipse.ceylon.common.tools.help.model.DescribedSection in project ceylon by eclipse.
the class HtmlVisitor method describedSection.
private void describedSection(int depth, DescribedSection describedSection) {
String sectionId = null;
if (depth == 0) {
if (describedSection.getRole() == Role.DESCRIPTION) {
html.open("div class='section section-description'").text("\n");
sectionId = "section-description";
} else {
html.open("div class='section'").text("\n");
}
addTableStart(html, sectionId, describedSection.getTitle(), 1);
html.open("tr", "td").markdown(describedSection.getDescription());
} else {
if (describedSection.getAbout() instanceof ToolModel) {
html.open("div id='" + idSubtool((ToolModel<?>) describedSection.getAbout()) + "'");
} else {
html.open("div");
}
html.markdown(describedSection.getTitle());
html.markdown(describedSection.getDescription());
}
for (DescribedSection subsection : describedSection.getSubsections()) {
describedSection(depth + 1, subsection);
}
if (depth != 0) {
html.close("div");
} else {
html.close("td", "tr");
addTableEnd(html);
html.close("div").text("\n");
}
}
use of org.eclipse.ceylon.common.tools.help.model.DescribedSection in project ceylon by eclipse.
the class PlainVisitor method describedSection.
private void describedSection(DescribedSection describedSection) {
markdown(describedSection.getTitle());
markdown(describedSection.getDescription());
for (DescribedSection subsection : describedSection.getSubsections()) {
describedSection(subsection);
}
out.setIndent(0);
out.newline();
}
Aggregations