You are viewing a plain text version of this content. The canonical link for it is here.
Posted to doxia-commits@maven.apache.org by lt...@apache.org on 2007/08/15 15:09:18 UTC

svn commit: r566139 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex: pom.xml src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java

Author: ltheussl
Date: Wed Aug 15 06:09:17 2007
New Revision: 566139

URL: http://svn.apache.org/viewvc?view=rev&rev=566139
Log:
Use new test classes, make testing independent of apt-module. Avoid constructor throwing Exception.

Modified:
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/pom.xml
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
    maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/pom.xml
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/pom.xml?view=diff&rev=566139&r1=566138&r2=566139
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/pom.xml (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/pom.xml Wed Aug 15 06:09:17 2007
@@ -8,13 +8,4 @@
   <artifactId>doxia-module-latex</artifactId>
   <name>Doxia :: Latex Module</name>
   <description>A Doxia module for LaTeX source documents.</description>
-
-  <dependencies>
-    <dependency>
-      <groupId>org.apache.maven.doxia</groupId>
-      <artifactId>doxia-module-apt</artifactId>
-      <version>${projectVersion}</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>  
 </project>

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java?view=diff&rev=566139&r1=566138&r2=566139
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/main/java/org/apache/maven/doxia/module/latex/LatexSink.java Wed Aug 15 06:09:17 2007
@@ -76,16 +76,13 @@
     // ----------------------------------------------------------------------
 
     public LatexSink( Writer out )
-        throws IOException
     {
-        this( out, IOUtil.toString( getDefaultSinkCommands() ), IOUtil.toString( getDefaultPreamble() ) );
+        this( out, defaultSinkCommands(), defaultPreamble() );
     }
 
     public LatexSink( Writer out, String sinkCommands, String preamble )
     {
-        this.out = new LineBreaker( out );
-        this.sinkCommands = sinkCommands;
-        this.preamble = preamble;
+        this( out, sinkCommands, preamble, false );
     }
 
     public LatexSink( Writer out, String sinkCommands, String preamble, boolean fragmentDocument )
@@ -166,7 +163,7 @@
             markup( getDocumentEnd() );
         }
 
-        out.flush();
+        flush();
     }
 
     // ----------------------------------------------------------------------
@@ -518,6 +515,7 @@
 
     public void sectionTitle_()
     {
+        // TODO: closing bracket?
         markup( "}" + EOL + EOL );
     }
 
@@ -844,4 +842,37 @@
     {
         return LatexSink.class.getResource( "default_preamble.tex" ).openStream();
     }
+
+    public static String defaultSinkCommands()
+    {
+        String commands = "";
+
+        try
+        {
+            commands = IOUtil.toString( getDefaultSinkCommands() );
+        }
+        catch ( IOException ioe )
+        {
+            // TODO: log
+        }
+
+        return commands;
+    }
+
+    public static String defaultPreamble()
+    {
+        String preamble = "";
+
+        try
+        {
+            preamble = IOUtil.toString( getDefaultPreamble() );
+        }
+        catch ( IOException ioe )
+        {
+            // TODO: log
+        }
+
+        return preamble;
+    }
+
 }

Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java?view=diff&rev=566139&r1=566138&r2=566139
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-latex/src/test/java/org/apache/maven/doxia/module/latex/LatexSinkTest.java Wed Aug 15 06:09:17 2007
@@ -19,46 +19,209 @@
  * under the License.
  */
 
+import java.io.Writer;
+
 import org.apache.maven.doxia.module.latex.LatexSink;
-import org.apache.maven.doxia.module.apt.AptParser;
 import org.apache.maven.doxia.sink.Sink;
-import org.apache.maven.doxia.sink.AbstractSinkTestCase;
+import org.apache.maven.doxia.sink.AbstractSinkTest;
 import org.apache.maven.doxia.parser.Parser;
 
-import java.io.Reader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @version $Id:LatexSinkTest.java 348605 2005-11-24 12:02:44 +1100 (Thu, 24 Nov 2005) brett $
  */
 public class LatexSinkTest
-    extends AbstractSinkTestCase
+    extends AbstractSinkTest
 {
     protected String outputExtension()
     {
         return "tex";
     }
 
-    protected Parser createParser()
+    protected Sink createSink( Writer writer )
+    {
+        return new LatexSink( writer );
+    }
+
+    /** {@inheritDoc} */
+    protected String getTitleBlock( String title )
+    {
+        return "\\ptitle{" + title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getAuthorBlock( String author )
+    {
+        return "\\pauthor{" + author + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getDateBlock( String date )
+    {
+        return "\\pdate{" + date + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getHeadBlock()
+    {
+        return LatexSink.defaultSinkCommands()
+            + "\\documentclass[a4paper]{article}"
+            + LatexSink.defaultPreamble()
+            + "\\begin{document}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getBodyBlock()
+    {
+        return "\\end{document}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSectionTitleBlock( String title )
+    {
+        // TODO: closing bracket?
+        return title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection1Block( String title )
+    {
+        return "\\psectioni{" + title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection2Block( String title )
+    {
+        return "\\psectionii{" + title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection3Block( String title )
+    {
+        return "\\psectioniii{" + title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection4Block( String title )
+    {
+        return "\\psectioniv{" + title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getSection5Block( String title )
+    {
+        return "\\psectionv{" + title + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getListBlock( String item )
+    {
+        return "\\begin{plist}\\item{} " + item + "\\end{plist}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getNumberedListBlock( String item )
     {
-        return new AptParser();
+        return "\\begin{pnumberedlist}\\renewcommand{\\theenumi}{\\roman{enumi}}\\item{} " + item + "\\end{pnumberedlist}";
     }
 
-    protected Sink createSink()
-        throws Exception
+    /** {@inheritDoc} */
+    protected String getDefinitionListBlock( String definum, String definition )
     {
-        return new LatexSink( getTestWriter() );
+        return "\\begin{pdefinitionlist}\\item[\\mbox{" + definum + "}] " + definition + "\\end{pdefinitionlist}";
     }
 
-    protected Reader getTestReader()
-        throws Exception
+    /** {@inheritDoc} */
+    protected String getFigureBlock( String source, String caption )
     {
-        InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( "test.apt" );
+        return "\\begin{pfigure}\\pfiguregraphics{" + source + "}\\pfigurecaption{" + caption + "}\\end{pfigure}";
+    }
 
-        InputStreamReader reader = new InputStreamReader( is );
+    /** {@inheritDoc} */
+    protected String getTableBlock( String cell, String caption )
+    {
+        // TODO: something's wrong
+        return "\\begin{ptable}\\begin{ptablerows}{c}\\begin{pcell}{c}cell\\end{pcell}\\\\\\end{ptablerows}\\ptablecaption{Table caption}\\end{ptable}";
+    }
 
-        return reader;
+    /** {@inheritDoc} */
+    protected String getParagraphBlock( String text )
+    {
+        return text;
     }
+
+    /** {@inheritDoc} */
+    protected String getVerbatimBlock( String text )
+    {
+        return "\\begin{pverbatimbox}\\begin{verbatim}" + text + "\\end{verbatim}\\end{pverbatimbox}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getHorizontalRuleBlock()
+    {
+        return "\\phorizontalrule";
+    }
+
+    /** {@inheritDoc} */
+    protected String getPageBreakBlock()
+    {
+        return "\\newpage";
+    }
+
+    /** {@inheritDoc} */
+    protected String getAnchorBlock( String anchor )
+    {
+        return "\\panchor{" + anchor + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getLinkBlock( String link, String text )
+    {
+        return "\\plink{" + text + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getItalicBlock( String text )
+    {
+        return "\\pitalic{" + text + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getBoldBlock( String text )
+    {
+        return "\\pbold{" + text + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getMonospacedBlock( String text )
+    {
+        return "\\pmonospaced{" + text + "}";
+    }
+
+    /** {@inheritDoc} */
+    protected String getLineBreakBlock()
+    {
+        return "\\newline";
+    }
+
+    /** {@inheritDoc} */
+    protected String getNonBreakingSpaceBlock()
+    {
+        return "~";
+    }
+
+    /** {@inheritDoc} */
+    protected String getTextBlock( String text )
+    {
+        // TODO: how to retrieve those outside the sink?
+        return "\\textasciitilde , =, \\symbol{45}, +, *, [, ], \\symbol{60}, \\symbol{62}, \\{,\\}, \\textbackslash";
+    }
+
+    /** {@inheritDoc} */
+    protected String getRawTextBlock( String text )
+    {
+        // TODO: not implemented
+        return "";
+    }
+
 }