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