1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 */ 19 package org.apache.maven.doxia.siterenderer; 20 21 import java.io.File; 22 import java.io.FileNotFoundException; 23 import java.io.IOException; 24 import java.io.UnsupportedEncodingException; 25 import java.io.Writer; 26 import java.util.Collection; 27 import java.util.Locale; 28 import java.util.Map; 29 30 import org.apache.maven.artifact.Artifact; 31 import org.apache.maven.doxia.site.decoration.DecorationModel; 32 33 /** 34 * Site Renderer interface: render a collection of documents into a site, ie decorated with a site template. 35 * 36 * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a> 37 */ 38 public interface Renderer // TODO rename to SiteRenderer 39 { 40 /** 41 * Render a collection of documents into a site. 42 * 43 * @param documents the documents to render. 44 * @param siteRenderingContext the SiteRenderingContext to use. 45 * @param outputDirectory the output directory to write results. 46 * @throws RendererException if it bombs. 47 * @throws IOException if it bombs. 48 */ 49 void render(Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, File outputDirectory) 50 throws RendererException, IOException; 51 52 /** 53 * Generate a document output integrated in a site from a document content, 54 * i.e. merge the document content into the site template. 55 * 56 * @param writer the Writer to use. 57 * @param content the document content to be merged. 58 * @param siteRenderingContext the SiteRenderingContext to use. 59 * @throws RendererException if it bombs. 60 * @since 1.8 61 */ 62 void mergeDocumentIntoSite(Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext) 63 throws RendererException; 64 65 /** 66 * Create a Site Rendering Context for a site using a skin. 67 * 68 * @param skin a skin 69 * @param attributes attributes to use 70 * @param decoration a decoration model 71 * @param defaultTitle default title 72 * @param locale locale to use 73 * @return a SiteRenderingContext. 74 * @throws RendererException if it bombs. 75 * @throws java.io.IOException if it bombs. 76 * @since 1.7.3 was previously with skin as File instead of Artifact 77 */ 78 SiteRenderingContext createContextForSkin( 79 Artifact skin, Map<String, ?> attributes, DecorationModel decoration, String defaultTitle, Locale locale) 80 throws RendererException, IOException; 81 82 /** 83 * Copy resource files from skin, template, and site resources. 84 * 85 * @param siteRenderingContext the SiteRenderingContext to use. 86 * @param outputDirectory output directory as file 87 * @throws IOException if it bombs. 88 * @since 1.7 89 */ 90 void copyResources(SiteRenderingContext siteRenderingContext, File outputDirectory) throws IOException; 91 92 /** 93 * Locate Doxia document source files in the site source context. 94 * 95 * @param siteRenderingContext the SiteRenderingContext to use 96 * @param editable Doxia document renderer as editable? (should not set editable if generated Doxia source) 97 * @return the Doxia document renderers in a Map keyed by output file name. 98 * @throws IOException if it bombs. 99 * @throws RendererException if it bombs. 100 * @since 1.8 101 */ 102 Map<String, DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext, boolean editable) 103 throws IOException, RendererException; 104 105 /** 106 * Render a document written in a Doxia markup language. This method is an internal method, used by 107 * {@link DoxiaDocumentRenderer}. 108 * 109 * @param writer the writer to render the document to. 110 * @param docRenderingContext the document's rendering context, which is expected to have a non-null parser id. 111 * @param siteContext the site's rendering context 112 * @throws RendererException if it bombs. 113 * @throws FileNotFoundException if it bombs. 114 * @throws UnsupportedEncodingException if it bombs. 115 */ 116 void renderDocument(Writer writer, RenderingContext docRenderingContext, SiteRenderingContext siteContext) 117 throws RendererException, FileNotFoundException, UnsupportedEncodingException; 118 }