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.SiteModel; 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 SiteRenderer { 39 /** 40 * Render a collection of documents into a site. 41 * 42 * @param documents the documents to render. 43 * @param siteRenderingContext the SiteRenderingContext to use. 44 * @param outputDirectory the output directory to write results. 45 * @throws RendererException if it bombs. 46 * @throws IOException if it bombs. 47 */ 48 void render(Collection<DocumentRenderer> documents, SiteRenderingContext siteRenderingContext, File outputDirectory) 49 throws RendererException, IOException; 50 51 /** 52 * Generate a document output integrated in a site from a document content, 53 * i.e. merge the document content into the site template. 54 * 55 * @param writer the Writer to use. 56 * @param content the document content to be merged. 57 * @param siteRenderingContext the SiteRenderingContext to use. 58 * @throws RendererException if it bombs. 59 * @since 1.8 60 */ 61 void mergeDocumentIntoSite(Writer writer, DocumentContent content, SiteRenderingContext siteRenderingContext) 62 throws RendererException; 63 64 /** 65 * Create a Site Rendering Context for a site using a skin. 66 * 67 * @param skin a skin 68 * @param attributes attributes to use 69 * @param siteModel a site model 70 * @param defaultTitle default title 71 * @param locale locale to use 72 * @return a SiteRenderingContext. 73 * @throws RendererException if it bombs. 74 * @throws java.io.IOException if it bombs. 75 * @since 1.7.3 was previously with skin as File instead of Artifact 76 */ 77 SiteRenderingContext createContextForSkin( 78 Artifact skin, Map<String, ?> attributes, SiteModel siteModel, String defaultTitle, Locale locale) 79 throws RendererException, IOException; 80 81 /** 82 * Copy resource files from skin, template, and site resources. 83 * 84 * @param siteRenderingContext the SiteRenderingContext to use. 85 * @param outputDirectory output directory as file 86 * @throws IOException if it bombs. 87 * @since 1.7 88 */ 89 void copyResources(SiteRenderingContext siteRenderingContext, File outputDirectory) throws IOException; 90 91 /** 92 * Locate Doxia document source files in the site source context. 93 * 94 * @param siteRenderingContext the SiteRenderingContext to use 95 * @param editable Doxia document renderer as editable? (should not set editable if generated Doxia source) 96 * @return the Doxia document renderers in a Map keyed by output file name. 97 * @throws IOException if it bombs. 98 * @throws RendererException if it bombs. 99 * @since 1.8 100 */ 101 Map<String, DocumentRenderer> locateDocumentFiles(SiteRenderingContext siteRenderingContext, boolean editable) 102 throws IOException, RendererException; 103 104 /** 105 * Render a document written in a Doxia markup language. This method is an internal method, used by 106 * {@link DoxiaDocumentRenderer}. 107 * 108 * @param writer the writer to render the document to. 109 * @param docRenderingContext the document's rendering context, which is expected to have a non-null parser id. 110 * @param siteContext the site's rendering context 111 * @throws RendererException if it bombs. 112 * @throws FileNotFoundException if it bombs. 113 * @throws UnsupportedEncodingException if it bombs. 114 */ 115 void renderDocument(Writer writer, DocumentRenderingContext docRenderingContext, SiteRenderingContext siteContext) 116 throws RendererException, FileNotFoundException, UnsupportedEncodingException; 117 }