Search in sources :

Example 1 with DoxiaDocumentRenderer

use of org.apache.maven.doxia.siterenderer.DoxiaDocumentRenderer in project maven-plugins by apache.

the class SiteMojo method renderDoxiaDocuments.

/**
     * Render Doxia documents from the list given, but not reports.
     * 
     * @param documents a collection of documents containing both Doxia source files and reports
     * @return the sublist of documents that are not Doxia source files
     */
private List<DocumentRenderer> renderDoxiaDocuments(Map<String, DocumentRenderer> documents, SiteRenderingContext context, File outputDir, boolean generated) throws RendererException, IOException {
    Map<String, DocumentRenderer> doxiaDocuments = new TreeMap<String, DocumentRenderer>();
    List<DocumentRenderer> nonDoxiaDocuments = new ArrayList<DocumentRenderer>();
    Map<String, Integer> counts = new TreeMap<String, Integer>();
    for (Map.Entry<String, DocumentRenderer> entry : documents.entrySet()) {
        DocumentRenderer doc = entry.getValue();
        if (doc instanceof DoxiaDocumentRenderer) {
            doxiaDocuments.put(entry.getKey(), doc);
            DoxiaDocumentRenderer doxia = (DoxiaDocumentRenderer) doc;
            // count documents per parserId
            String parserId = doxia.getRenderingContext().getParserId();
            Integer count = counts.get(parserId);
            if (count == null) {
                count = 1;
            } else {
                count++;
            }
            counts.put(parserId, count);
        } else {
            nonDoxiaDocuments.add(doc);
        }
    }
    if (doxiaDocuments.size() > 0) {
        StringBuilder sb = new StringBuilder(15 * counts.size());
        for (Map.Entry<String, Integer> entry : counts.entrySet()) {
            if (sb.length() > 0) {
                sb.append(", ");
            }
            sb.append(entry.getValue());
            sb.append(' ');
            sb.append(entry.getKey());
        }
        getLog().info("Rendering " + doxiaDocuments.size() + (generated ? " generated" : "") + " Doxia document" + (doxiaDocuments.size() > 1 ? "s" : "") + ": " + sb.toString());
        siteRenderer.render(doxiaDocuments.values(), context, outputDir);
    }
    return nonDoxiaDocuments;
}
Also used : ArrayList(java.util.ArrayList) TreeMap(java.util.TreeMap) DocumentRenderer(org.apache.maven.doxia.siterenderer.DocumentRenderer) DoxiaDocumentRenderer(org.apache.maven.doxia.siterenderer.DoxiaDocumentRenderer) DoxiaDocumentRenderer(org.apache.maven.doxia.siterenderer.DoxiaDocumentRenderer) TreeMap(java.util.TreeMap) Map(java.util.Map)

Aggregations

ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 DocumentRenderer (org.apache.maven.doxia.siterenderer.DocumentRenderer)1 DoxiaDocumentRenderer (org.apache.maven.doxia.siterenderer.DoxiaDocumentRenderer)1