Search in sources :

Example 6 with DescribedSection

use of org.eclipse.ceylon.common.tools.help.model.DescribedSection in project ceylon by eclipse.

the class DocBookVisitor method describedSection.

private void describedSection(int depth, DescribedSection describedSection) {
    if (depth <= 2) {
        docbook.open("refsect" + (depth + 1)).text("\n");
        docbook.markdown(describedSection.getTitle()).text("\n");
        docbook.markdown(describedSection.getDescription());
    } else {
        throw new RuntimeException("No refsect4");
    }
    for (DescribedSection subsection : describedSection.getSubsections()) {
        describedSection(depth + 1, subsection);
    }
    docbook.close("refsect" + (depth + 1)).text("\n");
}
Also used : DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection)

Example 7 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) {
    final HashMap<ToolModel<?>, DescribedSection> map = new HashMap<ToolModel<?>, DescribedSection>();
    new SubtoolVisitor(model) {

        @Override
        protected void visit(ToolModel<?> model, SubtoolModel<?> subtoolModel) {
            if (model == root) {
                map.put(model, buildDescription(model, getDescription(model)));
            } else if (model.getSubtoolModel() == null) {
                // leaf
                DescribedSection section = new DescribedSection();
                section.setRole(Role.DESCRIPTION);
                StringBuilder sb = new StringBuilder();
                for (SubtoolVisitor.ToolModelAndSubtoolModel subtool : ancestors.subList(1, ancestors.size())) {
                    sb.append(subtool.getModel().getName()).append(" ");
                }
                sb.append(model.getName());
                section.setTitle(Markdown.markdown("###" + CeylonHelpToolMessages.msg("section.DESCRIPTION.sub", sb.toString())));
                section.setDescription(Markdown.markdown(getDescription(model)));
                section.setAbout(model);
                List<DescribedSection> rootSubsections = new ArrayList<>(map.get(root).getSubsections());
                rootSubsections.add(section);
                map.get(root).setSubsections(rootSubsections);
            }
        }
    }.accept();
    return map.get(model);
}
Also used : HashMap(java.util.HashMap) PluginToolModel(org.eclipse.ceylon.common.tool.PluginToolModel) AnnotatedToolModel(org.eclipse.ceylon.common.tool.AnnotatedToolModel) ToolModel(org.eclipse.ceylon.common.tool.ToolModel) ScriptToolModel(org.eclipse.ceylon.common.tool.ScriptToolModel) ArrayList(java.util.ArrayList) DescribedSection(org.eclipse.ceylon.common.tools.help.model.DescribedSection) SubtoolVisitor(org.eclipse.ceylon.common.tools.help.model.SubtoolVisitor)

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