You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2022/08/04 20:10:32 UTC

[maven-doxia] branch DOXIA-670 updated (d4fa4717 -> 22fdc617)

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a change to branch DOXIA-670
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git


 discard d4fa4717 [DOXIA-670] Remove code duplication in XdocSink
     new 22fdc617 [DOXIA-670] Remove code duplication in XdocSink

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d4fa4717)
            \
             N -- N -- N   refs/heads/DOXIA-670 (22fdc617)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


[maven-doxia] 01/01: [DOXIA-670] Remove code duplication in XdocSink

Posted by mi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch DOXIA-670
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 22fdc617993925fb3e4f788ef01336402d89dda8
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Thu Aug 4 22:08:24 2022 +0200

    [DOXIA-670] Remove code duplication in XdocSink
---
 .../org/apache/maven/doxia/sink/impl/TextSink.java |   4 +-
 .../apache/maven/doxia/module/xdoc/XdocSink.java   | 138 ---------------------
 .../maven/doxia/module/xdoc/XdocSinkTest.java      |  19 +--
 .../doxia-module-xdoc/src/test/resources/test.xml  |   4 +-
 4 files changed, 17 insertions(+), 148 deletions(-)

diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java
index b5a34f76..5ed83e75 100644
--- a/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/sink/impl/TextSink.java
@@ -968,7 +968,9 @@ public class TextSink
                 attributes.getAttribute( SinkEventAttributes.DECORATION ).toString() );
         }
 
-        write( "begin:verbatim, boxed: " + boxed );
+        // TODO Cannot properly detect this when Xdoc is parsed, see DOXIA-670
+        // write( "begin:verbatim, boxed: " + boxed );
+        write( "begin:verbatim" );
     }
 
     @Override
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
index de012612..5634df22 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
@@ -382,119 +382,6 @@ public class XdocSink
     //
     // -----------------------------------------------------------------------
 
-    /**
-     * {@inheritDoc}
-     *
-     * @see XdocMarkup#SOURCE_TAG
-     * @see javax.swing.text.html.HTML.Tag#PRE
-     * @param attributes a {@link org.apache.maven.doxia.sink.SinkEventAttributes} object.
-     */
-    public void verbatim( SinkEventAttributes attributes )
-    {
-        setVerbatimFlag( true );
-
-        MutableAttributeSet atts = SinkUtils.filterAttributes(
-                attributes, SinkUtils.SINK_VERBATIM_ATTRIBUTES  );
-
-
-        if ( atts == null )
-        {
-            atts = new SinkEventAttributeSet();
-        }
-
-        boolean boxed = false;
-
-        if ( atts.isDefined( SinkEventAttributes.DECORATION ) )
-        {
-            boxed = "boxed".equals( atts.getAttribute( SinkEventAttributes.DECORATION ) );
-        }
-
-        boxedFlag = boxed;
-        atts.removeAttribute( SinkEventAttributes.DECORATION );
-
-        if ( boxed )
-        {
-            writeStartTag( SOURCE_TAG, atts );
-        }
-        else
-        {
-            atts.removeAttribute( Attribute.ALIGN.toString() );
-            writeStartTag( PRE, atts );
-        }
-    }
-
-    /**
-     * {@inheritDoc}
-     *
-     * @see XdocMarkup#SOURCE_TAG
-     * @see javax.swing.text.html.HTML.Tag#PRE
-     */
-    public void verbatim_()
-    {
-        if ( boxedFlag )
-        {
-            writeEndTag( SOURCE_TAG );
-        }
-        else
-        {
-            writeEndTag( PRE );
-        }
-
-        setVerbatimFlag( false );
-
-        boxedFlag = false;
-    }
-
-    /**
-     * The default align is <code>center</code>.
-     *
-     * {@inheritDoc}
-     * @see javax.swing.text.html.HTML.Tag#TABLE
-     */
-    public void tableRows( int[] justification, boolean grid )
-    {
-        // similar to super.tableRows( justification, grid ) but without class.
-
-        this.tableRows = true;
-
-        setCellJustif( justification );
-
-        if ( this.tableAttributes == null )
-        {
-            this.tableAttributes = new SinkEventAttributeSet( 0 );
-        }
-
-        MutableAttributeSet att = new SinkEventAttributeSet();
-
-        if ( !tableAttributes.isDefined( Attribute.BORDER.toString() ) )
-        {
-            att.addAttribute( Attribute.BORDER, ( grid ? "1" : "0" ) );
-        }
-
-        att.addAttributes( tableAttributes );
-
-        tableAttributes.removeAttributes( tableAttributes );
-
-        writeStartTag( TABLE, att );
-    }
-
-    /**
-     * The default valign is <code>top</code>.
-     *
-     * {@inheritDoc}
-     *
-     * @see javax.swing.text.html.HTML.Tag#TR
-     */
-    public void tableRow()
-    {
-        MutableAttributeSet att = new SinkEventAttributeSet();
-        att.addAttribute( Attribute.VALIGN, "top" );
-
-        writeStartTag( TR, att );
-
-        setCellCount( 0 );
-    }
-
     /**
      * <p>close.</p>
      */
@@ -505,31 +392,6 @@ public class XdocSink
         init();
     }
 
-    /**
-     * Adds a link with an optional target.
-     *
-     * @param name the link name.
-     * @param target the link target, may be null.
-     */
-    public void link( String name, String target )
-    {
-        if ( isHeadFlag() )
-        {
-            return;
-        }
-
-        MutableAttributeSet att = new SinkEventAttributeSet();
-
-        att.addAttribute( Attribute.HREF, HtmlTools.escapeHTML( name ) );
-
-        if ( target != null )
-        {
-            att.addAttribute( Attribute.TARGET, target );
-        }
-
-        writeStartTag( A, att );
-    }
-
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
diff --git a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
index 3e8613f8..f40dfd55 100644
--- a/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
+++ b/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocSinkTest.java
@@ -20,6 +20,7 @@ package org.apache.maven.doxia.module.xdoc;
  */
 
 import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.SinkEventAttributes;
 import org.apache.maven.doxia.sink.impl.AbstractSinkTest;
 import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
 import org.junit.jupiter.api.Test;
@@ -27,6 +28,8 @@ import org.junit.jupiter.api.Test;
 import java.io.StringWriter;
 import java.io.Writer;
 
+import javax.swing.text.html.HTML.Attribute;
+
 import static org.apache.maven.doxia.util.HtmlTools.escapeHTML;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 
@@ -232,8 +235,8 @@ public class XdocSinkTest
     /** {@inheritDoc} */
     protected String getTableBlock( String cell, String caption )
     {
-        return "<table border=\"0\"><caption>" + caption
-                + "</caption>\n<tr valign=\"top\">\n<td align=\"center\">" + cell + "</td></tr></table>";
+        return "<table border=\"0\" class=\"bodyTable\"><caption>" + caption
+                + "</caption>\n<tr class=\"a\">\n<td align=\"center\">" + cell + "</td></tr></table>";
     }
 
     /** {@inheritDoc} */
@@ -275,7 +278,7 @@ public class XdocSinkTest
     /** {@inheritDoc} */
     protected String getVerbatimBlock( String text )
     {
-        return "<source>" + text + "</source>";
+        return "<div class=\"source\">\n<pre>" + text + "</pre></div>";
     }
 
     /** {@inheritDoc} */
@@ -400,7 +403,7 @@ public class XdocSinkTest
             sink.close();
         }
 
-        assertEquals( "<pre></pre><source></source>\n<pre width=\"20%\"></pre>", writer.toString() );
+        assertEquals( "<div>\n<pre></pre></div>\n<div class=\"source\">\n<pre></pre></div>\n<div>\n<pre width=\"20%\"></pre></div>", writer.toString() );
     }
 
     /**
@@ -416,9 +419,11 @@ public class XdocSinkTest
         {
             sink = new XdocSink( writer );
 
-            sink.link( "name", (String) null );
+            sink.link( "name" );
             sink.link_();
-            sink.link( "name", "nirvana" );
+            SinkEventAttributes attrs = new SinkEventAttributeSet();
+            attrs.addAttribute( Attribute.TARGET, "nirvana" );
+            sink.link( "name", attrs );
             sink.link_();
         }
         finally
@@ -426,7 +431,7 @@ public class XdocSinkTest
             sink.close();
         }
 
-        assertEquals( "<a href=\"name\"></a><a href=\"name\" target=\"nirvana\"></a>", writer.toString() );
+        assertEquals( "<a href=\"name\"></a><a target=\"nirvana\" href=\"name\"></a>", writer.toString() );
     }
 
     /** {@inheritDoc} */
diff --git a/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml b/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml
index 8acb9059..15383ccf 100644
--- a/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml
+++ b/doxia-modules/doxia-module-xdoc/src/test/resources/test.xml
@@ -51,7 +51,7 @@
           <li>List item 3. Force end of list:</li>
         </ul>
 
-        <source>Verbatim text not contained in list item 3</source>
+        <div class="source"><pre>Verbatim text not contained in list item 3</pre></div>
 
         <ol style="list-style-type: decimal">
           <li>Numbered item 1. <ol style="list-style-type: upper-alpha">
@@ -72,7 +72,7 @@
           <dt>
             <b>Defined term 2</b>
           </dt>
-          <dd>of definition list. <source>Verbatim text in a box </source>
+          <dd>of definition list. <div class="source"><pre>Verbatim text in a box</pre></div>
           </dd>
         </dl>