You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2020/07/09 13:31:53 UTC

[maven-doxia] branch DOXIA-614/support-source-reference-in-doxia-parser created (now 0f54fdb)

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

slachiewicz pushed a change to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git.


      at 0f54fdb  [DOXIA-614] Improve Doxia::getParser return JavaDoc

This branch includes the following new commits:

     new ae4d112  [DOXIA-614] Make Parser::parse(Reader,Sink,String) the default method for modules
     new 8f574e4  [DOXIA-614] Support passing source reference to Doxia instance
     new 7df1eaf  [DOXIA-614] Fix Doxia JavaDoc comments
     new 936b27f  [DOXIA-614] Restore imports order for AbstractParser and AbstractXmlParser
     new bbff8bc  [DOXIA-614] Fix AbstractParser JavaDoc comments
     new 0f54fdb  [DOXIA-614] Improve Doxia::getParser return JavaDoc

The 6 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.



[maven-doxia] 01/06: [DOXIA-614] Make Parser::parse(Reader, Sink, String) the default method for modules

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

slachiewicz pushed a commit to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit ae4d112281aa503ce19bfa5d2ee89e6bde606f38
Author: Abel Salgado Romero <ab...@gmail.com>
AuthorDate: Sun Jun 28 17:31:33 2020 +0200

    [DOXIA-614] Make Parser::parse(Reader,Sink,String) the default method for modules
---
 .../apache/maven/doxia/parser/AbstractParser.java  | 40 ++++++++++++-----
 .../maven/doxia/parser/AbstractXmlParser.java      | 52 ++++++++--------------
 .../maven/doxia/parser/Xhtml5BaseParser.java       |  4 +-
 .../apache/maven/doxia/parser/XhtmlBaseParser.java |  4 +-
 .../apache/maven/doxia/module/fml/FmlParser.java   |  4 +-
 .../doxia/module/markdown/MarkdownParser.java      |  2 +-
 .../apache/maven/doxia/module/xdoc/XdocParser.java |  4 +-
 .../maven/doxia/module/xhtml/XhtmlParser.java      |  4 +-
 .../maven/doxia/module/xhtml/XhtmlParserTest.java  |  1 +
 .../maven/doxia/module/xhtml5/Xhtml5Parser.java    |  4 +-
 10 files changed, 61 insertions(+), 58 deletions(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
index 1745585..ae8c0a7 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
@@ -19,14 +19,6 @@ package org.apache.maven.doxia.parser;
  * under the License.
  */
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-
-import java.util.Properties;
-
 import org.apache.maven.doxia.logging.Log;
 import org.apache.maven.doxia.logging.SystemStreamLog;
 import org.apache.maven.doxia.macro.Macro;
@@ -37,6 +29,13 @@ import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
 import org.apache.maven.doxia.sink.Sink;
 import org.codehaus.plexus.component.annotations.Requirement;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.Properties;
+
 /**
  * An abstract base class that defines some convenience methods for parsers.
  * Provides a macro mechanism to give dynamic functionalities for the parsing.
@@ -179,15 +178,32 @@ public abstract class AbstractParser
     public void parse( String string, Sink sink )
         throws ParseException
     {
-        parse( new StringReader( string ), sink );
+        this.parse( string, sink, null );
     }
-    
+
+    /**
+     * {@inheritDoc}
+     *
+     * Convenience method to parse an arbitrary string and emit events into the given sink.
+     *
+     * @param string A string that provides the source input.
+     * @param sink A sink that consumes the Doxia events.
+     * @param reference A string containing the reference to the source of the input string (e.g. filename).
+     * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed.
+     * @since 1.9.2
+     */
+    public void parse( String string, Sink sink, String reference )
+        throws ParseException
+    {
+        parse( new StringReader( string ), sink, reference );
+    }
+
     /** {@inheritDoc} */
     @Override
-    public void parse( Reader source, Sink sink, String reference )
+    public void parse( Reader source, Sink sink )
         throws ParseException
     {
-        parse( source, sink );
+        parse( source, sink, null );
     }
 
     /**
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
index 224c1cf..10095d1 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
@@ -19,23 +19,6 @@ package org.apache.maven.doxia.parser;
  * under the License.
  */
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.apache.http.HttpStatus;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -49,18 +32,33 @@ import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
 import org.apache.maven.doxia.util.HtmlTools;
 import org.apache.maven.doxia.util.XmlValidator;
-
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.MXParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
-
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * An abstract class that defines some convenience methods for <code>XML</code> parsers.
  *
@@ -100,7 +98,7 @@ public abstract class AbstractXmlParser
     private boolean validate = false;
 
     /** {@inheritDoc} */
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         init();
@@ -153,7 +151,7 @@ public abstract class AbstractXmlParser
         setSecondParsing( false );
         init();
     }
-    
+
     /**
      * Initializes the parser with custom entities or other options.
      *
@@ -166,18 +164,6 @@ public abstract class AbstractXmlParser
         // nop
     }
 
-    /**
-     * {@inheritDoc}
-     *
-     * Convenience method to parse an arbitrary string and emit any xml events into the given sink.
-     */
-    @Override
-    public void parse( String string, Sink sink )
-        throws ParseException
-    {
-        super.parse( string, sink );
-    }
-
     /** {@inheritDoc} */
     @Override
     public final int getType()
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java
index 5dfc757..dd10f58 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/Xhtml5BaseParser.java
@@ -81,14 +81,14 @@ public class Xhtml5BaseParser
 
     /** {@inheritDoc} */
     @Override
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         init();
 
         try
         {
-            super.parse( source, sink );
+            super.parse( source, sink, reference );
         }
         finally
         {
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
index 36b1024..da379c2 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/XhtmlBaseParser.java
@@ -82,14 +82,14 @@ public class XhtmlBaseParser
 
     /** {@inheritDoc} */
     @Override
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         init();
 
         try
         {
-            super.parse( source, sink );
+            super.parse( source, sink, reference );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
index 6fc121b..da334a1 100644
--- a/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
+++ b/doxia-modules/doxia-module-fml/src/main/java/org/apache/maven/doxia/module/fml/FmlParser.java
@@ -89,7 +89,7 @@ public class FmlParser
     private Map<String, Object> macroParameters = new HashMap<>();
 
     /** {@inheritDoc} */
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         this.faqs = null;
@@ -118,7 +118,7 @@ public class FmlParser
             this.faqs = new Faqs();
 
             // this populates faqs
-            super.parse( tmp, sink );
+            super.parse( tmp, sink, reference );
 
             writeFaqs( sink );
         }
diff --git a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
index f40e123..9ae9706 100644
--- a/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
+++ b/doxia-modules/doxia-module-markdown/src/main/java/org/apache/maven/doxia/module/markdown/MarkdownParser.java
@@ -107,7 +107,7 @@ public class MarkdownParser
     private MarkdownHtmlParser parser;
 
     /** {@inheritDoc} */
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         try
diff --git a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
index 6efa2b5..e1b8184 100644
--- a/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
+++ b/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java
@@ -85,7 +85,7 @@ public class XdocParser
     private boolean hasTitle;
 
     /** {@inheritDoc} */
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         this.sourceContent = null;
@@ -110,7 +110,7 @@ public class XdocParser
 
         try
         {
-            super.parse( new StringReader( sourceContent ), sink );
+            super.parse( new StringReader( sourceContent ), sink, reference );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
index 00cfc8d..5c12ace 100644
--- a/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
+++ b/doxia-modules/doxia-module-xhtml/src/main/java/org/apache/maven/doxia/module/xhtml/XhtmlParser.java
@@ -333,7 +333,7 @@ public class XhtmlParser
     }
 
     /** {@inheritDoc} */
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         this.sourceContent = null;
@@ -355,7 +355,7 @@ public class XhtmlParser
 
         try
         {
-            super.parse( new StringReader( sourceContent ), sink );
+            super.parse( new StringReader( sourceContent ), sink, reference );
         }
         finally
         {
diff --git a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
index 7820fa7..ac27097 100644
--- a/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
+++ b/doxia-modules/doxia-module-xhtml/src/test/java/org/apache/maven/doxia/module/xhtml/XhtmlParserTest.java
@@ -21,6 +21,7 @@ package org.apache.maven.doxia.module.xhtml;
 
 import java.io.File;
 import java.io.FileFilter;
+import java.io.StringReader;
 import java.util.Iterator;
 import java.util.regex.Pattern;
 
diff --git a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
index 984769b..e049355 100644
--- a/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
+++ b/doxia-modules/doxia-module-xhtml5/src/main/java/org/apache/maven/doxia/module/xhtml5/Xhtml5Parser.java
@@ -334,7 +334,7 @@ public class Xhtml5Parser
     }
 
     /** {@inheritDoc} */
-    public void parse( Reader source, Sink sink )
+    public void parse( Reader source, Sink sink, String reference )
         throws ParseException
     {
         this.sourceContent = null;
@@ -356,7 +356,7 @@ public class Xhtml5Parser
 
         try
         {
-            super.parse( new StringReader( sourceContent ), sink );
+            super.parse( new StringReader( sourceContent ), sink, reference );
         }
         finally
         {


[maven-doxia] 04/06: [DOXIA-614] Restore imports order for AbstractParser and AbstractXmlParser

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

slachiewicz pushed a commit to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 936b27f6ea93cbfb2fdfe45bcb964f32cde5ab9d
Author: Abel Salgado Romero <ab...@gmail.com>
AuthorDate: Tue Jun 30 22:19:07 2020 +0200

    [DOXIA-614] Restore imports order for AbstractParser and AbstractXmlParser
---
 .../apache/maven/doxia/parser/AbstractParser.java  | 15 ++++-----
 .../maven/doxia/parser/AbstractXmlParser.java      | 36 ++++++++++++----------
 2 files changed, 27 insertions(+), 24 deletions(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
index ae8c0a7..7471ff8 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
@@ -19,6 +19,14 @@ package org.apache.maven.doxia.parser;
  * under the License.
  */
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+import java.util.Properties;
+
 import org.apache.maven.doxia.logging.Log;
 import org.apache.maven.doxia.logging.SystemStreamLog;
 import org.apache.maven.doxia.macro.Macro;
@@ -29,13 +37,6 @@ import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
 import org.apache.maven.doxia.sink.Sink;
 import org.codehaus.plexus.component.annotations.Requirement;
 
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Properties;
-
 /**
  * An abstract base class that defines some convenience methods for parsers.
  * Provides a macro mechanism to give dynamic functionalities for the parsing.
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
index 10095d1..c0b1ddb 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractXmlParser.java
@@ -19,6 +19,23 @@ package org.apache.maven.doxia.parser;
  * under the License.
  */
 
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Reader;
+import java.io.StringReader;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.LinkedHashMap;
+import java.util.Locale;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 import org.apache.http.HttpStatus;
 import org.apache.http.client.ClientProtocolException;
 import org.apache.http.client.methods.CloseableHttpResponse;
@@ -32,33 +49,18 @@ import org.apache.maven.doxia.sink.Sink;
 import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
 import org.apache.maven.doxia.util.HtmlTools;
 import org.apache.maven.doxia.util.XmlValidator;
+
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.IOUtil;
 import org.codehaus.plexus.util.StringUtils;
 import org.codehaus.plexus.util.xml.pull.MXParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
 import org.xml.sax.EntityResolver;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.LinkedHashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 /**
  * An abstract class that defines some convenience methods for <code>XML</code> parsers.
  *


[maven-doxia] 06/06: [DOXIA-614] Improve Doxia::getParser return JavaDoc

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

slachiewicz pushed a commit to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 0f54fdba577e12b1c711418b5f29881eb14d2650
Author: Abel Salgado Romero <ab...@gmail.com>
AuthorDate: Tue Jun 30 22:35:50 2020 +0200

    [DOXIA-614] Improve Doxia::getParser return JavaDoc
---
 doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
index 22018e6..17d3920 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
@@ -68,7 +68,7 @@ public interface Doxia
      * Return a parser for the given <code>parserId</code>.
      *
      * @param parserId identifier for the parser to use
-     * @return the parser defining by parserId
+     * @return the parser identified by parserId
      * @throws ParserNotFoundException if no parser could be found for the given id
      */
     Parser getParser( String parserId )


[maven-doxia] 02/06: [DOXIA-614] Support passing source reference to Doxia instance

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

slachiewicz pushed a commit to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 8f574e4314f2318b824df702e7781f037afdfeab
Author: Abel Salgado Romero <ab...@gmail.com>
AuthorDate: Sun Jun 28 19:37:58 2020 +0200

    [DOXIA-614] Support passing source reference to Doxia instance
---
 .../java/org/apache/maven/doxia/DefaultDoxia.java  | 10 +++-
 .../main/java/org/apache/maven/doxia/Doxia.java    | 16 +++++++
 .../org/apache/maven/doxia/DefaultDoxiaTest.java   | 54 ++++++++++++++++++++++
 3 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
index f8583e7..dae7ec2 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/DefaultDoxia.java
@@ -57,11 +57,19 @@ public class DefaultDoxia
     public void parse( Reader source, String parserId, Sink sink )
         throws ParserNotFoundException, ParseException
     {
+        this.parse( source, parserId, sink, null );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void parse( Reader source, String parserId, Sink sink, String reference )
+        throws ParserNotFoundException, ParseException
+    {
         Parser parser = parserManager.getParser( parserId );
 
         parser.enableLogging( new PlexusLoggerWrapper( getLogger() ) );
 
-        parser.parse( source, sink );
+        parser.parse( source, sink, reference );
     }
 
     /** {@inheritDoc} */
diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
index 837bdc2..5896684 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
@@ -53,6 +53,22 @@ public interface Doxia
         throws ParserNotFoundException, ParseException;
 
     /**
+     * Parses the given source model using a parser with given id,
+     * and emits Doxia events into the given sink.
+     *
+     * @param source not null reader that provides the source document.
+     * You could use <code>newReader</code> methods from {@link org.codehaus.plexus.util.ReaderFactory}.
+     * @param parserId Identifier for the parser to use.
+     * @param sink A sink that consumes the Doxia events.
+     * @param reference A string containing the reference to the source of the input string (e.g. filename).
+     * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException
+     * if no parser could be found for the given id.
+     * @throws org.apache.maven.doxia.parser.ParseException if the model could not be parsed.
+     */
+    void parse( Reader source, String parserId, Sink sink, String reference )
+        throws ParserNotFoundException, ParseException;
+
+    /**
      * Return a parser for the given <code>parserId</code>.
      *
      * @param parserId Identifier for the parser to use.
diff --git a/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java b/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java
new file mode 100644
index 0000000..2075b7f
--- /dev/null
+++ b/doxia-core/src/test/java/org/apache/maven/doxia/DefaultDoxiaTest.java
@@ -0,0 +1,54 @@
+package org.apache.maven.doxia;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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 org.apache.maven.doxia.parser.manager.ParserNotFoundException;
+import org.codehaus.plexus.PlexusTestCase;
+import org.junit.Test;
+
+public class DefaultDoxiaTest extends PlexusTestCase
+{
+
+    @Test
+    public void testCreatesDefaultDoxia()
+    {
+        final DefaultDoxia defaultDoxia = new DefaultDoxia();
+
+        assertNotNull( defaultDoxia );
+    }
+
+    @Test
+    public void testFailsWhenParserIdDoesNotExist() throws Exception
+    {
+        final String parserId = "a-parser";
+        final Doxia doxia = lookup( Doxia.class );
+
+        try
+        {
+            doxia.getParser( parserId );
+            fail( "Call should fail with ParserNotFoundException" );
+        }
+        catch ( ParserNotFoundException e )
+        {
+            assertEquals( "Cannot find parser with id = a-parser", e.getMessage() );
+        }
+    }
+
+}


[maven-doxia] 05/06: [DOXIA-614] Fix AbstractParser JavaDoc comments

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

slachiewicz pushed a commit to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit bbff8bcf63b3e6675b7fb38f45cdf25a34441c98
Author: Abel Salgado Romero <ab...@gmail.com>
AuthorDate: Tue Jun 30 22:33:43 2020 +0200

    [DOXIA-614] Fix AbstractParser JavaDoc comments
---
 .../apache/maven/doxia/parser/AbstractParser.java  | 38 +++++++++++-----------
 1 file changed, 19 insertions(+), 19 deletions(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
index 7471ff8..b46d6f4 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/parser/AbstractParser.java
@@ -101,7 +101,7 @@ public abstract class AbstractParser
     /**
      * {@inheritDoc}
      *
-     * @return a int.
+     * @return a int
      */
     public int getType()
     {
@@ -117,7 +117,7 @@ public abstract class AbstractParser
     /**
      * <p>isEmitComments.</p>
      *
-     * @return a boolean.
+     * @return a boolean
      */
     public boolean isEmitComments()
     {
@@ -127,11 +127,11 @@ public abstract class AbstractParser
     /**
      * Execute a macro on the given sink.
      *
-     * @param macroId An id to lookup the macro.
-     * @param request The corresponding MacroRequest.
-     * @param sink The sink to receive the events.
-     * @throws org.apache.maven.doxia.macro.MacroExecutionException if an error occurred during execution.
-     * @throws org.apache.maven.doxia.macro.manager.MacroNotFoundException if the macro could not be found.
+     * @param macroId an id to lookup the macro
+     * @param request the corresponding MacroRequest
+     * @param sink the sink to receive the events
+     * @throws org.apache.maven.doxia.macro.MacroExecutionException if an error occurred during execution
+     * @throws org.apache.maven.doxia.macro.manager.MacroNotFoundException if the macro could not be found
      */
     // Made public right now because of the structure of the APT parser and
     // all its inner classes.
@@ -148,7 +148,7 @@ public abstract class AbstractParser
     /**
      * Returns the current base directory.
      *
-     * @return The base directory.
+     * @return the base directory
      * @deprecated this does not work in multi-module builds, see DOXIA-373
      */
     protected File getBasedir()
@@ -171,9 +171,9 @@ public abstract class AbstractParser
      *
      * Convenience method to parse an arbitrary string and emit events into the given sink.
      *
-     * @param string A string that provides the source input.
-     * @param sink A sink that consumes the Doxia events.
-     * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed.
+     * @param string a string that provides the source input
+     * @param sink a sink that consumes the Doxia events
+     * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed
      * @since 1.1
      */
     public void parse( String string, Sink sink )
@@ -187,10 +187,10 @@ public abstract class AbstractParser
      *
      * Convenience method to parse an arbitrary string and emit events into the given sink.
      *
-     * @param string A string that provides the source input.
-     * @param sink A sink that consumes the Doxia events.
-     * @param reference A string containing the reference to the source of the input string (e.g. filename).
-     * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed.
+     * @param string a string that provides the source input
+     * @param sink a sink that consumes the Doxia events
+     * @param reference a string containing the reference to the source of the input string (e.g. filename)
+     * @throws org.apache.maven.doxia.parser.ParseException if the string could not be parsed
      * @since 1.9.2
      */
     public void parse( String string, Sink sink, String reference )
@@ -210,7 +210,7 @@ public abstract class AbstractParser
     /**
      * Set <code>secondParsing</code> to true, if we need a second parsing.
      *
-     * @param second True for second parsing.
+     * @param second true for second parsing
      */
     public void setSecondParsing( boolean second )
     {
@@ -220,7 +220,7 @@ public abstract class AbstractParser
     /**
      * Indicates if we are currently parsing a second time.
      *
-     * @return true if we are currently parsing a second time.
+     * @return true if we are currently parsing a second time
      * @since 1.1
      */
     protected boolean isSecondParsing()
@@ -254,7 +254,7 @@ public abstract class AbstractParser
     /**
      * Gets the current {@link MacroManager}.
      *
-     * @return The current {@link MacroManager}.
+     * @return the current {@link MacroManager}
      * @since 1.1
      */
     protected MacroManager getMacroManager()
@@ -277,7 +277,7 @@ public abstract class AbstractParser
     /**
      * The current Doxia version.
      *
-     * @return the current Doxia version as a String.
+     * @return the current Doxia version as a String
      * @since 1.2
      */
     protected static String doxiaVersion()


[maven-doxia] 03/06: [DOXIA-614] Fix Doxia JavaDoc comments

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

slachiewicz pushed a commit to branch DOXIA-614/support-source-reference-in-doxia-parser
in repository https://gitbox.apache.org/repos/asf/maven-doxia.git

commit 7df1eaf8853622f987307e43f2c8f4f41310a71b
Author: Abel Salgado Romero <ab...@gmail.com>
AuthorDate: Mon Jun 29 19:51:37 2020 +0200

    [DOXIA-614] Fix Doxia JavaDoc comments
---
 .../main/java/org/apache/maven/doxia/Doxia.java    | 33 +++++++++-------------
 1 file changed, 14 insertions(+), 19 deletions(-)

diff --git a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
index 5896684..22018e6 100644
--- a/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
+++ b/doxia-core/src/main/java/org/apache/maven/doxia/Doxia.java
@@ -41,13 +41,11 @@ public interface Doxia
      * Parses the given source model using a parser with given id,
      * and emits Doxia events into the given sink.
      *
-     * @param source not null reader that provides the source document.
-     * You could use <code>newReader</code> methods from {@link org.codehaus.plexus.util.ReaderFactory}.
-     * @param parserId Identifier for the parser to use.
-     * @param sink A sink that consumes the Doxia events.
-     * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException
-     * if no parser could be found for the given id.
-     * @throws org.apache.maven.doxia.parser.ParseException if the model could not be parsed.
+     * @param source not null reader that provides the source document
+     * @param parserId identifier for the parser to use
+     * @param sink a sink that consumes the Doxia events
+     * @throws ParserNotFoundException if no parser could be found for the given id
+     * @throws ParseException if the model could not be parsed
      */
     void parse( Reader source, String parserId, Sink sink )
         throws ParserNotFoundException, ParseException;
@@ -56,14 +54,12 @@ public interface Doxia
      * Parses the given source model using a parser with given id,
      * and emits Doxia events into the given sink.
      *
-     * @param source not null reader that provides the source document.
-     * You could use <code>newReader</code> methods from {@link org.codehaus.plexus.util.ReaderFactory}.
-     * @param parserId Identifier for the parser to use.
-     * @param sink A sink that consumes the Doxia events.
-     * @param reference A string containing the reference to the source of the input string (e.g. filename).
-     * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException
-     * if no parser could be found for the given id.
-     * @throws org.apache.maven.doxia.parser.ParseException if the model could not be parsed.
+     * @param source not null reader that provides the source document
+     * @param parserId identifier for the parser to use
+     * @param sink a sink that consumes the Doxia events
+     * @param reference string containing the reference to the source (e.g. filename)
+     * @throws ParserNotFoundException if no parser could be found for the given id
+     * @throws ParseException if the model could not be parsed
      */
     void parse( Reader source, String parserId, Sink sink, String reference )
         throws ParserNotFoundException, ParseException;
@@ -71,10 +67,9 @@ public interface Doxia
     /**
      * Return a parser for the given <code>parserId</code>.
      *
-     * @param parserId Identifier for the parser to use.
-     * @return the parser defining by parserId.
-     * @throws org.apache.maven.doxia.parser.manager.ParserNotFoundException
-     * if no parser could be found for the given id.
+     * @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;