Search in sources :

Example 1 with DescribedSection

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;
}
Also used : DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection)

Example 2 with DescribedSection

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;
}
Also used : DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection)

Example 3 with DescribedSection

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;
}
Also used : Section(org.eclipse.ceylon.common.tools.help.Markdown.Section) ArrayList(java.util.ArrayList) DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection) Document(org.tautua.markdownpapers.ast.Document) OptionsSection(org.eclipse.ceylon.common.tools.help.model.OptionsSection) SynopsesSection(org.eclipse.ceylon.common.tools.help.model.SynopsesSection) Section(org.eclipse.ceylon.common.tools.help.Markdown.Section) DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection) SummarySection(org.eclipse.ceylon.common.tools.help.model.SummarySection)

Example 4 with DescribedSection

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");
    }
}
Also used : ToolModel(org.eclipse.ceylon.common.tool.ToolModel) DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection)

Example 5 with DescribedSection

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();
}
Also used : DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection)

Aggregations

DescribedSection (org.eclipse.ceylon.common.tools.help.model.DescribedSection)7 ArrayList (java.util.ArrayList)2 ToolModel (org.eclipse.ceylon.common.tool.ToolModel)2 HashMap (java.util.HashMap)1 AnnotatedToolModel (org.eclipse.ceylon.common.tool.AnnotatedToolModel)1 PluginToolModel (org.eclipse.ceylon.common.tool.PluginToolModel)1 ScriptToolModel (org.eclipse.ceylon.common.tool.ScriptToolModel)1 Section (org.eclipse.ceylon.common.tools.help.Markdown.Section)1 OptionsSection (org.eclipse.ceylon.common.tools.help.model.OptionsSection)1 SubtoolVisitor (org.eclipse.ceylon.common.tools.help.model.SubtoolVisitor)1 SummarySection (org.eclipse.ceylon.common.tools.help.model.SummarySection)1 SynopsesSection (org.eclipse.ceylon.common.tools.help.model.SynopsesSection)1 Document (org.tautua.markdownpapers.ast.Document)1