maven-doxia-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vincent Siveton" <vincent.sive...@gmail.com>
Subject Re: svn commit: r564180 - in /maven/doxia: doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/ doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/ doxia/trunk/doxia-core/src/main/java/org/apache/maven
Date Thu, 09 Aug 2007 19:33:10 GMT
Hi Dennis,

2007/8/9, Dennis Lundberg <dennisl@apache.org>:
> Shouldn't FmlParser extend AbstractXmlParser?

Yes! It is on my todo list ;)

Cheers,

Vincent

> vsiveton@apache.org wrote:
> > Author: vsiveton
> > Date: Thu Aug  9 05:15:44 2007
> > New Revision: 564180
> >
> > URL: http://svn.apache.org/viewvc?view=rev&rev=564180
> > Log:
> > DOXIA-133: default XML encoding (UTF-8) or XML encoding set in XML files is ignored:
inputEncoding is used instead
> > Submitted by: Herve Boutemy
> > Reviewed by: Vincent Siveton
> >
> > o applied with modifications discussed on this issue
> > o added/updated javadoc
> >
> > Modified:
> >     maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
> >     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
> >     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
> >     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
> >     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractTextParser.java
> >     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
> >     maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/Parser.java
> >     maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java
> >     maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
> >     maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java
> >
> > Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
(original)
> > +++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
Thu Aug  9 05:15:44 2007
> > @@ -22,6 +22,7 @@
> >  import org.apache.maven.doxia.Doxia;
> >  import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
> >  import org.apache.maven.doxia.parser.ParseException;
> > +import org.apache.maven.doxia.parser.Parser;
> >  import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
> >  import org.apache.maven.doxia.site.decoration.DecorationModel;
> >  import org.apache.maven.doxia.module.site.SiteModule;
> > @@ -53,10 +54,9 @@
> >   * @since 1.0
> >   * @plexus.component role-hint="default"
> >   */
> > -public class
> > -        DefaultSiteRenderer
> > -        extends AbstractLogEnabled
> > -        implements Renderer
> > +public class DefaultSiteRenderer
> > +    extends AbstractLogEnabled
> > +    implements Renderer
> >  {
> >      // ----------------------------------------------------------------------
> >      // Requirements
> > @@ -92,6 +92,7 @@
> >      // Renderer implementation
> >      // ----------------------------------------------------------------------
> >
> > +    /** {@inheritDoc} */
> >      public void render( Collection documents,
> >                          SiteRenderingContext siteRenderingContext,
> >                          File outputDirectory )
> > @@ -106,6 +107,7 @@
> >          }
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public Map locateDocumentFiles( SiteRenderingContext siteRenderingContext )
> >              throws IOException, RendererException
> >      {
> > @@ -278,6 +280,7 @@
> >          }
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public void renderDocument( Writer writer,
> >                                  RenderingContext renderingContext,
> >                                  SiteRenderingContext context )
> > @@ -285,16 +288,17 @@
> >      {
> >          SiteRendererSink sink = new SiteRendererSink( renderingContext );
> >
> > -        String fullPathDoc = new File( renderingContext.getBasedir(), renderingContext.getInputName()
).getPath();
> > +        File doc = new File( renderingContext.getBasedir(), renderingContext.getInputName()
);
> >
> >          try
> >          {
> >              Reader reader = null;
> > +            Parser parser = doxia.getParser( renderingContext.getParserId() );
> >
> >              // DOXIA-111: the filter used here must be checked generally.
> >              if ( renderingContext.getAttribute( "velocity" ) != null )
> >              {
> > -                String resource = new File( fullPathDoc ).getAbsolutePath();
> > +                String resource = doc.getAbsolutePath();
> >
> >                  try
> >                  {
> > @@ -322,7 +326,17 @@
> >              }
> >              else
> >              {
> > -                reader = new InputStreamReader( new FileInputStream( fullPathDoc
), context.getInputEncoding() );
> > +                switch ( parser.getType() )
> > +                {
> > +                    case Parser.XML_TYPE:
> > +                        reader = ReaderFactory.newXmlReader( doc );
> > +                        break;
> > +
> > +                    case Parser.TXT_TYPE:
> > +                    case Parser.UNKNOWN_TYPE:
> > +                    default:
> > +                        reader = ReaderFactory.newReader( doc, context.getInputEncoding()
);
> > +                }
> >              }
> >
> >              doxia.parse( reader, renderingContext.getParserId(), sink );
> > @@ -331,12 +345,15 @@
> >          }
> >          catch ( ParserNotFoundException e )
> >          {
> > -            throw new RendererException( "Error getting a parser for " + fullPathDoc
+ ": " + e.getMessage() );
> > +            throw new RendererException( "Error getting a parser for " + doc +
": " + e.getMessage() );
> >          }
> >          catch ( ParseException e )
> >          {
> > -            getLogger().error( "Error parsing " + fullPathDoc + ": line [" + e.getLineNumber()
+ "] " + e.getMessage(),
> > -                    e );
> > +            getLogger().error( "Error parsing " + doc + ": line [" + e.getLineNumber()
+ "] " + e.getMessage(), e );
> > +        }
> > +        catch ( IOException e )
> > +        {
> > +            getLogger().error( "Error parsing " + doc + " to detect encoding",
e );
> >          }
> >          finally
> >          {
> > @@ -423,6 +440,7 @@
> >          return context;
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public void generateDocument( Writer writer,
> >                                    SiteRendererSink sink,
> >                                    SiteRenderingContext siteRenderingContext )
> > @@ -495,6 +513,7 @@
> >          }
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public SiteRenderingContext createContextForSkin( File skinFile,
> >                                                        Map attributes,
> >                                                        DecorationModel decoration,
> > @@ -534,6 +553,7 @@
> >          return context;
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public SiteRenderingContext createContextForTemplate( File templateFile,
> >                                                            File skinFile,
> >                                                            Map attributes,
> > @@ -569,6 +589,7 @@
> >          }
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public void copyResources( SiteRenderingContext siteContext,
> >                                 File resourcesDirectory,
> >                                 File outputDirectory )
> >
> > Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
Thu Aug  9 05:15:44 2007
> > @@ -31,10 +31,10 @@
> >   * Simple implementation of the Doxia interface:
> >   * uses a ParserManager to lookup a parser.
> >   *
> > - * @plexus.component
> > - *
> >   * @author Jason van Zyl
> > - * @version $Id:DefaultDoxia.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov
2005) brett $
> > + * @version $Id$
> > + * @since 1.0
> > + * @plexus.component
> >   */
> >  public class DefaultDoxia
> >      implements Doxia
> > @@ -57,5 +57,12 @@
> >          Parser parser = parserManager.getParser( parserId );
> >
> >          parser.parse( source, sink );
> > +    }
> > +
> > +    /** {@inheritDoc} */
> > +    public Parser getParser( String parserId )
> > +        throws ParserNotFoundException
> > +    {
> > +        return parserManager.getParser( parserId );
> >      }
> >  }
> >
> > Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
Thu Aug  9 05:15:44 2007
> > @@ -20,6 +20,7 @@
> >   */
> >
> >  import org.apache.maven.doxia.parser.ParseException;
> > +import org.apache.maven.doxia.parser.Parser;
> >  import org.apache.maven.doxia.parser.manager.ParserNotFoundException;
> >  import org.apache.maven.doxia.sink.Sink;
> >
> > @@ -29,7 +30,8 @@
> >   * Basic interface of the Doxia framework.
> >   *
> >   * @author Jason van Zyl
> > - * @version $Id:Doxia.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005)
brett $
> > + * @version $Id$
> > + * @since 1.0
> >   */
> >  public interface Doxia
> >  {
> > @@ -50,4 +52,14 @@
> >      void parse( Reader source, String parserId, Sink sink )
> >          throws ParserNotFoundException, ParseException;
> >
> > +    /**
> > +     * Return a parser for the given <code>parserId</code>.
> > +     *
> > +     * @param parserId Identifier for the parser to use.
> > +     * @return the parser defining by parserId.
> > +     * @throws ParserNotFoundException if no parser could be found
> > +     * for the given id.
> > +     */
> > +    Parser getParser( String parserId )
> > +        throws ParserNotFoundException;
> >  }
> >
> > Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
Thu Aug  9 05:15:44 2007
> > @@ -46,6 +46,12 @@
> >      /** @plexus.requirement */
> >      protected MacroManager macroManager;
> >
> > +    /** {@inheritDoc} */
> > +    public int getType()
> > +    {
> > +        return UNKNOWN_TYPE;
> > +    }
> > +
> >      /**
> >       * Execute a macro on the given sink.
> >       *
> >
> > Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractTextParser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractTextParser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractTextParser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractTextParser.java
Thu Aug  9 05:15:44 2007
> > @@ -32,6 +32,9 @@
> >      extends AbstractParser
> >      implements TextMarkup
> >  {
> > -
> > +    /** {@inheritDoc} */
> > +    public final int getType()
> > +    {
> > +        return TXT_TYPE;
> > +    }
> >  }
> > -
> >
> > Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
Thu Aug  9 05:15:44 2007
> > @@ -62,6 +62,12 @@
> >          }
> >      }
> >
> > +    /** {@inheritDoc} */
> > +    public final int getType()
> > +    {
> > +        return XML_TYPE;
> > +    }
> > +
> >      /**
> >       * Parse the model from the XmlPullParser into the given sink.
> >       *
> >
> > Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/Parser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/Parser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/Parser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/parser/Parser.java
Thu Aug  9 05:15:44 2007
> > @@ -37,6 +37,15 @@
> >      /** The Plexus lookup role. */
> >      String ROLE = Parser.class.getName();
> >
> > +    /** Unknown parser type */
> > +    int UNKNOWN_TYPE = 0;
> > +
> > +    /** Text parser type */
> > +    int TXT_TYPE = 1;
> > +
> > +    /** XML parser type */
> > +    int XML_TYPE = 2;
> > +
> >      /** Used for table cells: justify center. */
> >      int JUSTIFY_CENTER = 0;
> >
> > @@ -55,4 +64,12 @@
> >       */
> >      void parse( Reader source, Sink sink )
> >          throws ParseException;
> > +
> > +    /**
> > +     * The parser type value could be {@link #UNKNOWN_TYPE}, {@link #TXT_TYPE}
or
> > +     * {@link #XML_TYPE}.
> > +     *
> > +     * @return the type of Parser
> > +     */
> > +    int getType();
> >  }
> >
> > Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-confluence/src/main/java/org/apache/maven/doxia/module/confluence/ConfluenceParser.java
Thu Aug  9 05:15:44 2007
> > @@ -29,7 +29,7 @@
> >  import org.apache.maven.doxia.module.confluence.parser.HorizontalRuleBlockParser;
> >  import org.apache.maven.doxia.module.confluence.parser.table.TableBlockParser;
> >  import org.apache.maven.doxia.module.confluence.parser.list.ListBlockParser;
> > -import org.apache.maven.doxia.parser.AbstractParser;
> > +import org.apache.maven.doxia.parser.AbstractTextParser;
> >  import org.apache.maven.doxia.parser.ParseException;
> >  import org.apache.maven.doxia.sink.Sink;
> >
> > @@ -38,9 +38,17 @@
> >  import java.util.Iterator;
> >  import java.util.List;
> >
> > -/** @plexus.component role-hint="confluence" */
> > +/**
> > + * Parse the <a href="http://www.atlassian.com/software/confluence/">Confluence</a>.
> > + * See <a href="http://confluence.atlassian.com/display/CONF25/Confluence+Notation+Guide+Overview">
> > + * Confluence Notation Guide Overview</a>
> > + *
> > + * @version $Id$
> > + * @since 1.0
> > + * plexus.component role-hint="confluence"
> > + */
> >  public class ConfluenceParser
> > -    extends AbstractParser
> > +    extends AbstractTextParser
> >  {
> >      private BlockParser[] parsers;
> >
> > @@ -109,6 +117,7 @@
> >          return blocks;
> >      }
> >
> > +    /** {@inheritDoc} */
> >      public synchronized void parse( Reader reader,
> >                                      Sink sink )
> >          throws ParseException
> >
> > Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
Thu Aug  9 05:15:44 2007
> > @@ -38,15 +38,14 @@
> >   * Parse a fml model and emit events into the specified doxia Sink.
> >   *
> >   * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
> > - * @version $Id:FmlParser.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005)
brett $
> > + * @version $Id$
> > + * @since 1.0
> >   * @plexus.component role-hint="fml"
> >   */
> >  public class FmlParser
> >      implements Parser
> >  {
> > -    /**
> > -     * @see org.apache.maven.doxia.parser.Parser#parse(java.io.Reader, org.apache.maven.doxia.sink.Sink)
> > -     */
> > +    /** {@inheritDoc} */
> >      public void parse( Reader reader, Sink sink )
> >          throws ParseException
> >      {
> > @@ -72,6 +71,12 @@
> >          {
> >              throw new ParseException( "Error creating sink: " + e.getMessage(),
e );
> >          }
> > +    }
> > +
> > +    /** {@inheritDoc} */
> > +    public int getType()
> > +    {
> > +        return XML_TYPE;
> >      }
> >
> >      /**
> >
> > Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java
> > URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java?view=diff&rev=564180&r1=564179&r2=564180
> > ==============================================================================
> > --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java
(original)
> > +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-twiki/src/main/java/org/apache/maven/doxia/module/twiki/TWikiParser.java
Thu Aug  9 05:15:44 2007
> > @@ -28,7 +28,7 @@
> >  import org.apache.maven.doxia.module.twiki.parser.SectionBlockParser;
> >  import org.apache.maven.doxia.module.twiki.parser.TableBlockParser;
> >  import org.apache.maven.doxia.module.twiki.parser.TextParser;
> > -import org.apache.maven.doxia.parser.AbstractParser;
> > +import org.apache.maven.doxia.parser.AbstractTextParser;
> >  import org.apache.maven.doxia.parser.ParseException;
> >  import org.apache.maven.doxia.sink.Sink;
> >  import org.apache.maven.doxia.util.ByLineReaderSource;
> > @@ -44,10 +44,12 @@
> >   * twiki file format</a>
> >   *
> >   * @author Juan F. Codagnone
> > + * @version $Id$
> > + * @since 1.0
> >   * @plexus.component role="org.apache.maven.doxia.parser.Parser" role-hint="twiki"
> > - * @since Oct 31, 2005
> >   */
> > -public class TWikiParser extends AbstractParser
> > +public class TWikiParser
> > +    extends AbstractTextParser
> >  {
> >      /**
> >       * paragraph parser. stateless
> > @@ -126,7 +128,7 @@
> >              for ( int i = 0; i < parsers.length; i++ )
> >              {
> >                  final BlockParser parser = parsers[i];
> > -
> > +
> >                  if ( parser.accept( line ) )
> >                  {
> >                      accepted = true;
> > @@ -144,10 +146,7 @@
> >          return ret;
> >      }
> >
> > -    /**
> > -     * @see org.apache.maven.doxia.parser.Parser#parse(java.io.Reader,
> > -     *      org.apache.maven.doxia.sink.Sink)
> > -     */
> > +    /** {@inheritDoc} */
> >      public final synchronized void parse( final Reader reader, final Sink sink
)
> >          throws ParseException
> >      {
> > @@ -175,7 +174,7 @@
> >          for ( Iterator it = blocks.iterator(); it.hasNext(); )
> >          {
> >              final Block block = (Block) it.next();
> > -
> > +
> >              block.traverse( sink );
> >          }
> >          sink.body_();
> >
> >
> >
>
>
> --
> Dennis Lundberg
>

Mime
View raw message