svn commit: r561304 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src: main/java/org/apache/maven/doxia/module/xdoc/ test/java/org/apache/maven/doxia/module/xdoc/ test/resources/
Author: vsiveton Date: Tue Jul 31 04:58:48 2007 New Revision: 561304 URL: http://svn.apache.org/viewvc?view=rev&rev=561304 Log: DOXIA-130: Macro renaming o using 'param' tag to handle macro settings in xdoc o updated the xdoc parser to handle this o review tests to write output into files o updated test resources with the new macro declaration Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/java/org/apache/maven/doxia/module/xdoc/XdocParserTest.java maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/macro.xml maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/test/resources/toc.xml Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java?view=diff&rev=561304&r1=561303&r2=561304 == --- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java (original) +++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocParser.java Tue Jul 31 04:58:48 2007 @@ -37,6 +37,7 @@ import org.apache.maven.doxia.sink.Sink; 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; @@ -68,6 +69,12 @@ /** Used for nested lists. */ private int orderedListDepth = 0; +/** A macro name. */ +private String macroName; + +/** The macro parameters. */ +private Map macroParameters = new HashMap(); + /** [EMAIL PROTECTED] */ public void parse( Reader reader, Sink sink ) throws ParseException @@ -144,10 +151,9 @@ * @param parser A parser. * @param sink the sink to receive the events. * @throws XmlPullParserException if there's a problem parsing the model - * @throws MacroExecutionException if there's a problem executing a macro */ private void handleStartTag( XmlPullParser parser, Sink sink ) -throws XmlPullParserException, MacroExecutionException +throws XmlPullParserException { isEmptyElement = parser.isEmptyElementTag(); @@ -288,37 +294,47 @@ } } } + +// -- +// Macro +// -- + else if ( parser.getName().equals( MACRO_TAG.toString() ) ) { if ( !secondParsing ) { -String macroName = parser.getAttributeValue( null, Attribute.NAME.toString() ); - -int count = parser.getAttributeCount(); - -Map parameters = new HashMap(); - -for ( int i = 1; i < count; i++ ) -{ -parameters.put( parser.getAttributeName( i ), parser.getAttributeValue( i ) ); -} - -// TODO handles specific attributes -parameters.put( "sourceContent", sourceContent ); +macroName = parser.getAttributeValue( null, Attribute.NAME.toString() ); -XdocParser xdocParser = new XdocParser(); -xdocParser.setSecondParsing( true ); -parameters.put( "parser", xdocParser ); - -MacroRequest request = new MacroRequest( parameters, getBasedir() ); - -try +if ( StringUtils.isEmpty( macroName ) ) { -executeMacro( macroName, request, sink ); +// TODO use logging? +throw new IllegalArgumentException( "The '" + Attribute.NAME.toString() + "' attribute for the '" ++ MACRO_TAG.toString() + "' tag is required." ); } -catch ( MacroNotFoundException me ) +} +} +else if ( parser.getName().equals( Tag.PARAM.toString() ) ) +{ +if ( !secondParsing ) +{ +if ( StringUtils.isNotEmpty( macroName ) ) { -throw new MacroExecutionException( "Macro not found: " + macroName, me ); +if ( macroParameters == null ) +{ +macroParameters = new HashMap(); +} + +String paramName = parser.getAttributeValue( null, Attribute.NAME.toString() ); +
svn commit: r561313 - in /maven/doxia/site/src/site/apt: developers/index.apt macros/index.apt
Author: vsiveton Date: Tue Jul 31 05:41:35 2007 New Revision: 561313 URL: http://svn.apache.org/viewvc?view=rev&rev=561313 Log: DOXIA-130: Macro renaming o updated doc Modified: maven/doxia/site/src/site/apt/developers/index.apt maven/doxia/site/src/site/apt/macros/index.apt Modified: maven/doxia/site/src/site/apt/developers/index.apt URL: http://svn.apache.org/viewvc/maven/doxia/site/src/site/apt/developers/index.apt?view=diff&rev=561313&r1=561312&r2=561313 == --- maven/doxia/site/src/site/apt/developers/index.apt (original) +++ maven/doxia/site/src/site/apt/developers/index.apt Tue Jul 31 05:41:35 2007 @@ -155,7 +155,7 @@ public void execute( Sink sink, MacroRequest request ) throws MacroExecutionException { -String paramValue = (String) request.getParameter( "param" ); +String myValue = (String) request.getParameter( "myParam" ); ... } ... @@ -167,13 +167,15 @@ * APT - -%{my|param=value} +%{my|myParam=myValue} - * XDoc - - + + + - [] Modified: maven/doxia/site/src/site/apt/macros/index.apt URL: http://svn.apache.org/viewvc/maven/doxia/site/src/site/apt/macros/index.apt?view=diff&rev=561313&r1=561312&r2=561313 == --- maven/doxia/site/src/site/apt/macros/index.apt (original) +++ maven/doxia/site/src/site/apt/macros/index.apt Tue Jul 31 05:41:35 2007 @@ -36,13 +36,22 @@ For instance, in an APT file, you could write: - -%{echo|param=value|param2=value2} +%{echo|param1=value1|param2=value2} +- + + Similarly, it will be for xdoc file: + +- + + + + - and it will output - - param ---> value + param1 ---> value1 param2 ---> value2 - @@ -55,6 +64,15 @@ %{snippet|id=myid|url=http://myserver/path/to/file.txt} - + In a xdoc file, it will be: + +- + + + http://myserver/path/to/file.txt"/> + +- + If you need to include only a part of a file, you could add a start and end snippets. * Start and end snippets in a Java file @@ -93,7 +111,7 @@ *---+--+ || Parameter || Description | *---+--+ -| id| The id of the snippet. +| id| The id of the snippet (required). *---+--+ | url | The path of the URL to include. *---+--+ @@ -109,6 +127,16 @@ %{toc|section=2|fromDepth=0|toDepth=4} - + In a xdoc file, it will be: + +- + + + + + +- + *---+--+ || Parameter || Description | *---+--+ @@ -126,6 +154,17 @@ - %{swf|src=swf/myfile.swf|id=MyMovie|width=600|height=200} +- + + In a xdoc file, it will be: + +- + + + + + + - *---+--+
svn commit: r561315 - /maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java
Author: vsiveton Date: Tue Jul 31 05:50:41 2007 New Revision: 561315 URL: http://svn.apache.org/viewvc?view=rev&rev=561315 Log: DOXIA-130: Macro renaming o updated doc Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java Modified: maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java URL: http://svn.apache.org/viewvc/maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java?view=diff&rev=561315&r1=561314&r2=561315 == --- maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java (original) +++ maven/doxia/doxia/trunk/doxia-core/src/main/java/org/apache/maven/doxia/macro/toc/TocMacro.java Tue Jul 31 05:50:41 2007 @@ -39,7 +39,7 @@ * * section * Display the specificated section number or all sections if 0 - * (in this case, other paramaters are ignored). + * (in this case, other parameters are ignored). * Positive int, not mandatory, 0 by default. * fromDepth * Display the depth starting for the given section number. @@ -63,9 +63,13 @@ * * {SubSection 1} * * - * Similary, in an XDOC file, you could write: + * Similarly, in an XDOC file, you could write: * - *+ * + * + * + * + * * * * @plexus.component role-hint="toc"