-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DOXIA-614] support source reference in doxia parser #35
Changes from all commits
a55438b
e8f8c82
bca3f5f
b33226c
50104e4
6c076ba
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,7 +101,7 @@ public abstract class AbstractParser | |
/** | ||
* {@inheritDoc} | ||
* | ||
* @return a int. | ||
* @return a int | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd just delete this, if there's nothing more to say than the type |
||
*/ | ||
public int getType() | ||
{ | ||
|
@@ -117,7 +117,7 @@ public void setEmitComments( boolean emitComments ) | |
/** | ||
* <p>isEmitComments.</p> | ||
* | ||
* @return a boolean. | ||
* @return a boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
*/ | ||
public boolean isEmitComments() | ||
{ | ||
|
@@ -127,11 +127,11 @@ public boolean isEmitComments() | |
/** | ||
* 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 void executeMacro( String macroId, MacroRequest request, Sink sink ) | |
/** | ||
* 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,29 +171,46 @@ protected File getBasedir() | |
* | ||
* 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 ) | ||
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 ); | ||
} | ||
|
||
/** | ||
* 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 ) | ||
{ | ||
|
@@ -203,7 +220,7 @@ public void setSecondParsing( boolean second ) | |
/** | ||
* 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() | ||
|
@@ -237,7 +254,7 @@ protected Log getLog() | |
/** | ||
* Gets the current {@link MacroManager}. | ||
* | ||
* @return The current {@link MacroManager}. | ||
* @return the current {@link MacroManager} | ||
* @since 1.1 | ||
*/ | ||
protected MacroManager getMacroManager() | ||
|
@@ -260,7 +277,7 @@ protected void init() | |
/** | ||
* 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() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's hard to follow from the diff, but are any of the apparent method signature changes real? Or is it just Github diff being funky? If these are real changes is it possible to add overloads with the old variants that pass null for reference? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really. To see the changes probably, the image in the PR description summarizes the changes (@ means overrride method), at least it helped me to track the changes. The only solution I saw was to replace 2 args method by the 3 args in all implementations and call the 3 args in the |
||
throws ParseException | ||
{ | ||
init(); | ||
|
||
try | ||
{ | ||
super.parse( source, sink ); | ||
super.parse( source, sink, reference ); | ||
} | ||
finally | ||
{ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ); | ||
slachiewicz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
fail( "Call should fail with ParserNotFoundException" ); | ||
} | ||
catch ( ParserNotFoundException e ) | ||
{ | ||
assertEquals( "Cannot find parser with id = a-parser", e.getMessage() ); | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably doesn't matter a great deal, but adding methods to interfaces is not backwards compatible