maven-doxia-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r385559 - in /maven/doxia/trunk: doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/decoration/render/ doxia-core/src/test/java/org/apache/maven/doxia/module/xhtml/ doxia-decoration-model/src/main/mdo/ doxia-site-renderer/src/main...
Date Mon, 13 Mar 2006 14:28:14 GMT
Author: brett
Date: Mon Mar 13 06:28:10 2006
New Revision: 385559

URL: http://svn.apache.org/viewcvs?rev=385559&view=rev
Log:
[MSITE-80] refactored site renderer API and pushed duplicate checking and determination of
files into the site renderer

Added:
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java
  (with props)
Modified:
    maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/decoration/render/RenderingContext.java
    maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
    maven/doxia/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
    maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
    maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java

Modified: maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/decoration/render/RenderingContext.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/decoration/render/RenderingContext.java?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/decoration/render/RenderingContext.java
(original)
+++ maven/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/module/xhtml/decoration/render/RenderingContext.java
Mon Mar 13 06:28:10 2006
@@ -26,20 +26,32 @@
  */
 public class RenderingContext
 {
-    private File basedir;
+    private final File basedir;
 
-    private String relativePath;
+    private final String inputName;
 
-    private String outputName;
+    private final String outputName;
+
+    private final String parserId;
+
+    private final String relativePath;
 
     public RenderingContext( File basedir, String document )
     {
+        this( basedir, document, null );
+    }
+
+    public RenderingContext( File basedir, String document, String parserId )
+    {
         this.basedir = basedir;
 
-        // For site comparisons we'll prepend a "/"
-        this.outputName = "/" + document.substring( 0, document.lastIndexOf( "." ) + 1 )
+ "html";
+        this.outputName = document.substring( 0, document.lastIndexOf( "." ) ) + ".html";
+
+        this.relativePath = PathTool.getRelativePath( basedir.getPath(), new File( basedir,
document ).getPath() );
 
-        relativePath = PathTool.getRelativePath( basedir.getPath(), new File( basedir, document
).getPath() );
+        this.inputName = document;
+
+        this.parserId = parserId;
     }
 
     public File getBasedir()
@@ -47,9 +59,9 @@
         return basedir;
     }
 
-    public String getRelativePath()
+    public String getInputName()
     {
-        return relativePath;
+        return inputName;
     }
 
     public String getOutputName()
@@ -57,4 +69,13 @@
         return outputName;
     }
 
+    public String getParserId()
+    {
+        return parserId;
+    }
+
+    public String getRelativePath()
+    {
+        return relativePath;
+    }
 }

Modified: maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
(original)
+++ maven/doxia/trunk/doxia-core/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlSinkTest.java
Mon Mar 13 06:28:10 2006
@@ -16,11 +16,9 @@
  * limitations under the License.
  */
 
-import org.apache.maven.doxia.module.xhtml.SinkDescriptorReader;
-import org.apache.maven.doxia.module.xhtml.XhtmlSink;
 import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
-import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.AbstractSinkTestCase;
+import org.apache.maven.doxia.sink.Sink;
 
 import java.io.File;
 import java.io.FileReader;
@@ -43,10 +41,10 @@
     protected Sink createSink()
         throws Exception
     {
-        String xdoc = "test.apt";
+        String apt = "test.apt";
 
         RenderingContext renderingContext =
-            new RenderingContext( getBasedirFile(), new File( getBasedirFile(), xdoc ).getPath()
);
+            new RenderingContext( getBasedirFile(), new File( getBasedirFile(), apt ).getPath(),
"apt" );
 
         FileReader reader = new FileReader( new File( getBasedirFile(), "src/test/resources/codehaus.dst"
) );
 
@@ -54,9 +52,7 @@
 
         Map directives = sdr.read( reader );
 
-        XhtmlSink sink = new XhtmlSink( getTestWriter(), renderingContext, directives );
-
-        return sink;
+        return new XhtmlSink( getTestWriter(), renderingContext, directives );
     }
 
     // END SNIPPET: foo

Modified: maven/doxia/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo (original)
+++ maven/doxia/trunk/doxia-decoration-model/src/main/mdo/decoration.mdo Mon Mar 13 06:28:10
2006
@@ -105,6 +105,8 @@
     {
         if ( menusByRef == null )
         {
+            menusByRef = new java.util.HashMap();
+
             for ( java.util.Iterator i = body.getMenus().iterator(); i.hasNext(); )
             {
                 Menu menu = (Menu) i.next();
@@ -384,13 +386,15 @@
         <codeSegment>
           <version>1.0.0</version>
           <code>
-            public static Skin getDefaultSkin()
-            {
-            Skin skin = new Skin();
-            skin.setGroupId( "org.apache.maven.skins" );
-            skin.setArtifactId( "maven-default-skin" );
-            return skin;
-            }
+            <![CDATA[
+    public static Skin getDefaultSkin()
+    {
+        Skin skin = new Skin();
+        skin.setGroupId( "org.apache.maven.skins" );
+        skin.setArtifactId( "maven-default-skin" );
+        return skin;
+    }
+            ]]>
           </code>
         </codeSegment>
       </codeSegments>

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
Mon Mar 13 06:28:10 2006
@@ -23,6 +23,7 @@
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.site.module.SiteModule;
 import org.apache.maven.doxia.site.module.manager.SiteModuleManager;
+import org.apache.maven.doxia.site.module.manager.SiteModuleNotFoundException;
 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
@@ -50,9 +51,11 @@
 import java.net.URLClassLoader;
 import java.text.DateFormat;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
@@ -105,62 +108,118 @@
     // Renderer implementation
     // ----------------------------------------------------------------------
 
-    public void render( File siteDirectory, File outputDirectory, SiteRenderingContext context
)
+    public void render( Collection documents, SiteRenderingContext siteRenderingContext,
File outputDirectory )
         throws RendererException, IOException
     {
-        render( siteDirectory, outputDirectory, context, DEFAULT_OUTPUT_ENCODING );
+        render( documents, siteRenderingContext, outputDirectory, DEFAULT_OUTPUT_ENCODING
);
     }
 
-    public void render( File siteDirectory, File outputDirectory, SiteRenderingContext context,
String outputEncoding )
+    // TODO [IMPORTART] fix sigs
+    public void render( Collection documents, SiteRenderingContext siteRenderingContext,
File outputDirectory,
+                        String outputEncoding )
         throws RendererException, IOException
     {
-        for ( Iterator i = siteModuleManager.getSiteModules().iterator(); i.hasNext(); )
+        renderModule( documents, siteRenderingContext, outputDirectory, outputEncoding );
+
+        for ( Iterator i = siteRenderingContext.getSiteDirectories().iterator(); i.hasNext();
)
         {
-            SiteModule module = (SiteModule) i.next();
+            File siteDirectory = (File) i.next();
+            copyResources( siteRenderingContext, new File( siteDirectory, "resources" ),
outputDirectory );
+        }
+    }
 
-            File moduleBasedir = new File( siteDirectory, module.getSourceDirectory() );
+    public Map locateDocumentFiles( SiteRenderingContext siteRenderingContext )
+        throws IOException, RendererException
+    {
+        Map files = new LinkedHashMap();
 
-            if ( moduleBasedir.exists() )
+        for ( Iterator i = siteRenderingContext.getSiteDirectories().iterator(); i.hasNext();
)
+        {
+            File siteDirectory = (File) i.next();
+            if ( siteDirectory.exists() )
             {
-                renderModule( moduleBasedir, module.getExtension(), module.getParserId(),
outputDirectory,
-                              outputEncoding, context );
+                for ( Iterator j = siteModuleManager.getSiteModules().iterator(); j.hasNext();
)
+                {
+                    SiteModule module = (SiteModule) j.next();
+
+                    File moduleBasedir = new File( siteDirectory, module.getSourceDirectory()
);
+
+                    addModuleFiles( moduleBasedir, module, files );
+                }
             }
         }
 
-        copyResources( outputDirectory, context );
+        for ( Iterator i = siteRenderingContext.getModules().iterator(); i.hasNext(); )
+        {
+            ModuleReference module = (ModuleReference) i.next();
+
+            try
+            {
+                addModuleFiles( module.getBasedir(), siteModuleManager.getSiteModule( module.getParserId()
), files );
+            }
+            catch ( SiteModuleNotFoundException e )
+            {
+                throw new RendererException( "Unable to find module: " + e.getMessage(),
e );
+            }
+        }
+        return files;
     }
 
-    private void renderModule( File moduleBasedir, String moduleExtension, String moduleParserId,
File outputDirectory,
-                               String outputEncoding, SiteRenderingContext context )
+    private void addModuleFiles( File moduleBasedir, SiteModule module, Map files )
         throws IOException, RendererException
     {
-        List docs = FileUtils.getFileNames( moduleBasedir, "**/*." + moduleExtension, null,
false );
-
-        for ( Iterator j = docs.iterator(); j.hasNext(); )
+        if ( moduleBasedir.exists() )
         {
-            String doc = (String) j.next();
+            List docs = FileUtils.getFileNames( moduleBasedir, "**/*." + module.getExtension(),
null, false );
+
+            for ( Iterator k = docs.iterator(); k.hasNext(); )
+            {
+                String doc = (String) k.next();
+
+                RenderingContext context = new RenderingContext( moduleBasedir, doc, module.getParserId()
);
+
+                String key = context.getOutputName().toLowerCase( Locale.getDefault() );
+
+                if ( files.containsKey( key ) )
+                {
+                    RenderingContext originalContext = (RenderingContext) files.get( key
);
+                    File originalDoc = new File( originalContext.getBasedir(), originalContext.getInputName()
);
+                    throw new RendererException( "Files '" + doc + "' clashes with existing
'" + originalDoc + "'" );
+                }
+
+                files.put( key, context );
+            }
+        }
+    }
 
-            String outputName = doc.substring( 0, doc.indexOf( "." ) + 1 ) + "html";
+    private void renderModule( Collection docs, SiteRenderingContext siteRenderingContext,
File outputDirectory,
+                               String outputEncoding )
+        throws IOException, RendererException
+    {
+        for ( Iterator i = docs.iterator(); i.hasNext(); )
+        {
+            RenderingContext renderingContext = (RenderingContext) i.next();
 
-            String fullPathDoc = new File( moduleBasedir, doc ).getPath();
+            String fullPathDoc = new File( renderingContext.getBasedir(), renderingContext.getInputName()
).getPath();
 
-            SiteRendererSink sink = createSink( moduleBasedir, outputName );
+            SiteRendererSink sink = createSink( renderingContext );
 
             try
             {
                 FileReader reader = new FileReader( fullPathDoc );
 
-                doxia.parse( reader, moduleParserId, sink );
+                doxia.parse( reader, renderingContext.getParserId(), sink );
 
-                File outputFile = new File( outputDirectory, outputName );
+                File outputFile = new File( outputDirectory, renderingContext.getOutputName()
);
 
                 if ( !outputFile.getParentFile().exists() )
                 {
                     outputFile.getParentFile().mkdirs();
                 }
 
-                generateDocument( new OutputStreamWriter( new FileOutputStream( outputFile
), outputEncoding ), sink,
-                                  context );
+                OutputStreamWriter writer =
+                    new OutputStreamWriter( new FileOutputStream( outputFile ), outputEncoding
);
+                generateDocument( writer, sink, siteRenderingContext );
             }
             catch ( ParserNotFoundException e )
             {
@@ -179,16 +238,7 @@
         }
     }
 
-    public void render( File moduleBasedir, File outputDirectory, String module, String moduleExtension,
-                        String moduleParserId, SiteRenderingContext context, String outputEncoding
)
-        throws RendererException, IOException
-    {
-        renderModule( moduleBasedir, moduleExtension, moduleParserId, outputDirectory, outputEncoding,
context );
-
-        copyResources( outputDirectory, context );
-    }
-
-    public void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext
siteContext )
+    public void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext
siteRenderingContext )
         throws RendererException
     {
         VelocityContext context = new VelocityContext();
@@ -198,20 +248,19 @@
         // ----------------------------------------------------------------------
 
         RenderingContext renderingContext = sink.getRenderingContext();
-        String relativePath = renderingContext.getRelativePath();
-        context.put( "relativePath", relativePath );
+        context.put( "relativePath", renderingContext.getRelativePath() );
 
         // Add infos from document
         context.put( "authors", sink.getAuthors() );
 
         String title = "";
-        if ( siteContext.getDecoration().getName() != null )
+        if ( siteRenderingContext.getDecoration().getName() != null )
         {
-            title = siteContext.getDecoration().getName();
+            title = siteRenderingContext.getDecoration().getName();
         }
-        else if ( siteContext.getDefaultWindowTitle() != null )
+        else if ( siteRenderingContext.getDefaultWindowTitle() != null )
         {
-            title = siteContext.getDefaultWindowTitle();
+            title = siteRenderingContext.getDefaultWindowTitle();
         }
 
         if ( title.length() > 0 )
@@ -224,21 +273,19 @@
 
         context.put( "bodyContent", sink.getBody() );
 
-        context.put( "decoration", siteContext.getDecoration() );
+        context.put( "decoration", siteRenderingContext.getDecoration() );
 
         context.put( "currentDate", new Date() );
 
-        context.put( "dateFormat", DateFormat.getDateInstance( DateFormat.DEFAULT, siteContext.getLocale()
) );
+        Locale locale = siteRenderingContext.getLocale();
+        context.put( "dateFormat", DateFormat.getDateInstance( DateFormat.DEFAULT, locale
) );
 
-        String currentFileName = PathTool.calculateLink( renderingContext.getOutputName(),
relativePath );
-        currentFileName = currentFileName.replace( '\\', '/' );
+        context.put( "currentFileName", renderingContext.getOutputName().replace( '\\', '/'
) );
 
-        context.put( "currentFileName", currentFileName );
-
-        context.put( "locale", siteContext.getLocale() );
+        context.put( "locale", locale );
 
         // Add user properties
-        Map templateProperties = siteContext.getTemplateProperties();
+        Map templateProperties = siteRenderingContext.getTemplateProperties();
         if ( templateProperties != null )
         {
             for ( Iterator i = templateProperties.keySet().iterator(); i.hasNext(); )
@@ -265,7 +312,7 @@
         //
         // ----------------------------------------------------------------------
 
-        writeTemplate( writer, context, siteContext );
+        writeTemplate( writer, context, siteRenderingContext );
     }
 
     private void writeTemplate( Writer writer, Context context, SiteRenderingContext siteContext
)
@@ -326,14 +373,13 @@
         }
     }
 
-    public SiteRendererSink createSink( File moduleBaseDir, String document )
+    public SiteRendererSink createSink( RenderingContext renderingContext )
     {
-        return new SiteRendererSink( new RenderingContext( moduleBaseDir, document ) );
+        return new SiteRendererSink( renderingContext );
     }
 
     public SiteRenderingContext createContextForSkin( File skinFile, Map attributes, DecorationModel
decoration,
-                                                      Locale locale, String defaultWindowTitle,
-                                                      File resourcesDirectory )
+                                                      String defaultWindowTitle, Locale locale
)
         throws IOException
     {
         SiteRenderingContext context = new SiteRenderingContext();
@@ -364,14 +410,13 @@
         context.setDecoration( decoration );
         context.setDefaultWindowTitle( defaultWindowTitle );
         context.setSkinJarFile( skinFile );
-        context.setResourcesDirectory( resourcesDirectory );
 
         return context;
     }
 
-    public SiteRenderingContext createContextForTemplate( File templateFile, Map attributes,
DecorationModel decoration,
-                                                          Locale locale, String defaultWindowTitle,
File skinFile,
-                                                          File resourcesDirectory )
+    public SiteRenderingContext createContextForTemplate( File templateFile, File skinFile,
Map attributes,
+                                                          DecorationModel decoration, String
defaultWindowTitle,
+                                                          Locale locale )
         throws MalformedURLException
     {
         SiteRenderingContext context = new SiteRenderingContext();
@@ -384,7 +429,6 @@
         context.setDecoration( decoration );
         context.setDefaultWindowTitle( defaultWindowTitle );
         context.setSkinJarFile( skinFile );
-        context.setResourcesDirectory( resourcesDirectory );
 
         return context;
     }
@@ -402,13 +446,7 @@
         }
     }
 
-    /**
-     * Copy Resources
-     *
-     * @param outputDir the output directory
-     * @throws java.io.IOException if any
-     */
-    public void copyResources( File outputDir, SiteRenderingContext siteContext )
+    public void copyResources( SiteRenderingContext siteContext, File resourcesDirectory,
File outputDirectory )
         throws IOException
     {
         if ( siteContext.getSkinJarFile() != null )
@@ -423,21 +461,12 @@
 
                     if ( !entry.getName().startsWith( "META-INF/" ) )
                     {
-                        File destFile = new File( outputDir, entry.getName() );
+                        File destFile = new File( outputDirectory, entry.getName() );
                         if ( !entry.isDirectory() )
                         {
                             destFile.getParentFile().mkdirs();
 
-                            FileOutputStream fos = new FileOutputStream( destFile );
-
-                            try
-                            {
-                                IOUtil.copy( file.getInputStream( entry ), fos );
-                            }
-                            finally
-                            {
-                                IOUtil.close( fos );
-                            }
+                            copyFileFromZip( file, entry, destFile );
                         }
                         else
                         {
@@ -472,7 +501,7 @@
                         throw new IOException( "The resource " + line + " doesn't exist."
);
                     }
 
-                    File outputFile = new File( outputDir, line );
+                    File outputFile = new File( outputDirectory, line );
 
                     if ( !outputFile.getParentFile().exists() )
                     {
@@ -492,16 +521,27 @@
             }
         }
 
-        File resourcesDirectory = siteContext.getResourcesDirectory();
-
         // Copy extra site resources
-        // TODO: this should be accommodating locale
-        // TODO: this should be automatically looking into ${siteDirectory}/resources
         if ( resourcesDirectory != null && resourcesDirectory.exists() )
         {
-            copyDirectory( resourcesDirectory, outputDir );
+            copyDirectory( resourcesDirectory, outputDirectory );
         }
 
+    }
+
+    private void copyFileFromZip( ZipFile file, ZipEntry entry, File destFile )
+        throws IOException
+    {
+        FileOutputStream fos = new FileOutputStream( destFile );
+
+        try
+        {
+            IOUtil.copy( file.getInputStream( entry ), fos );
+        }
+        finally
+        {
+            IOUtil.close( fos );
+        }
     }
 
     /**

Added: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java?rev=385559&view=auto
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java
(added)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java
Mon Mar 13 06:28:10 2006
@@ -0,0 +1,47 @@
+package org.apache.maven.doxia.siterenderer;
+
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+/**
+ * Holds a small extra module reference in the list of added modules to the rendering context.
+ *
+ * @author <a href="mailto:brett@apache.org">Brett Porter</a>
+ */
+class ModuleReference
+{
+    private final String parserId;
+
+    private final File basedir;
+
+    ModuleReference( String parserId, File basedir )
+    {
+        this.parserId = parserId;
+        this.basedir = basedir;
+    }
+
+    public String getParserId()
+    {
+        return parserId;
+    }
+
+    public File getBasedir()
+    {
+        return basedir;
+    }
+}

Propchange: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ModuleReference.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/Renderer.java
Mon Mar 13 06:28:10 2006
@@ -16,6 +16,7 @@
  * limitations under the License.
  */
 
+import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
 
@@ -23,6 +24,7 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.net.MalformedURLException;
+import java.util.Collection;
 import java.util.Locale;
 import java.util.Map;
 
@@ -34,31 +36,31 @@
 {
     String ROLE = Renderer.class.getName();
 
-    void render( File siteDirectory, File outputDirectory, SiteRenderingContext context )
+    void render( Collection documents, SiteRenderingContext siteRenderingContext, File outputDirectory
)
         throws RendererException, IOException;
 
-    void render( File siteDirectory, File outputDirectory, SiteRenderingContext context,
String outputEncoding )
+    void render( Collection documents, SiteRenderingContext siteRenderingContext, File outputDirectory,
+                 String outputEncoding )
         throws RendererException, IOException;
 
-    void render( File moduleBasedir, File outputDirectory, String module, String moduleExtension,
String moduleParserId,
-                 SiteRenderingContext context, String outputEncoding )
-        throws RendererException, IOException;
-
-    void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteContext
)
+    void generateDocument( Writer writer, SiteRendererSink sink, SiteRenderingContext siteRenderingContext
)
         throws RendererException;
 
-    SiteRendererSink createSink( File moduleBaseDir, String document )
+    SiteRendererSink createSink( RenderingContext renderingContext )
         throws RendererException, IOException;
 
-    SiteRenderingContext createContextForSkin( File skinFile, Map attributes, DecorationModel
decoration, Locale locale,
-                                               String defaultWindowTitle, File resourcesDirectory
)
+    SiteRenderingContext createContextForSkin( File skinFile, Map attributes, DecorationModel
decoration,
+                                               String defaultWindowTitle, Locale locale )
         throws IOException;
 
-    SiteRenderingContext createContextForTemplate( File templateFile, Map attributes, DecorationModel
decoration,
-                                                   Locale locale, String defaultWindowTitle,
File skinFile,
-                                                   File resourcesDirectory )
+    SiteRenderingContext createContextForTemplate( File templateFile, File skinFile, Map
attributes,
+                                                   DecorationModel decoration, String defaultWindowTitle,
+                                                   Locale locale )
         throws MalformedURLException;
 
-    void copyResources( File outputDirectory, SiteRenderingContext siteContext )
+    void copyResources( SiteRenderingContext siteRenderingContext, File resourcesDirectory,
File outputDirectory )
         throws IOException;
+
+    Map locateDocumentFiles( SiteRenderingContext siteRenderingContext )
+        throws IOException, RendererException;
 }

Modified: maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
Mon Mar 13 06:28:10 2006
@@ -19,6 +19,9 @@
 import org.apache.maven.doxia.site.decoration.DecorationModel;
 
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 
@@ -44,7 +47,9 @@
 
     private boolean usingDefaultTemplate;
 
-    private File resourcesDirectory;
+    private List siteDirectories = new ArrayList();
+
+    private List modules = new ArrayList();
 
     public String getTemplateName()
     {
@@ -68,7 +73,7 @@
 
     public void setTemplateProperties( Map templateProperties )
     {
-        this.templateProperties = templateProperties;
+        this.templateProperties = Collections.unmodifiableMap( templateProperties );
     }
 
     public Locale getLocale()
@@ -126,13 +131,24 @@
         return usingDefaultTemplate;
     }
 
-    public void setResourcesDirectory( File resourcesDirectory )
+    public void addSiteDirectory( File file )
+    {
+        this.siteDirectories.add( file );
+    }
+
+    public void addModuleDirectory( File file, String moduleParserId )
     {
-        this.resourcesDirectory = resourcesDirectory;
+        this.modules.add( new ModuleReference( moduleParserId, file ) );
     }
 
-    public File getResourcesDirectory()
+    public List getSiteDirectories()
     {
-        return resourcesDirectory;
+        return siteDirectories;
     }
+
+    public List getModules()
+    {
+        return modules;
+    }
+
 }

Modified: maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
URL: http://svn.apache.org/viewcvs/maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java?rev=385559&r1=385558&r2=385559&view=diff
==============================================================================
--- maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
(original)
+++ maven/doxia/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
Mon Mar 13 06:28:10 2006
@@ -62,6 +62,7 @@
         context.setTemplateName( "default-site.vm" );
         context.setTemplateClassLoader( getClassLoader() );
         context.setDecoration( decoration );
-        renderer.render( getTestFile( "src/test/site" ), getTestFile( "target/output" ),
context );
+        context.addSiteDirectory( getTestFile( "src/test/site" ) );
+        renderer.render( renderer.locateDocumentFiles( context ).values(), context, getTestFile(
"target/output" ) );
     }
 }



Mime
View raw message