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/07/17 22:45:48 UTC
svn commit: r557051 - in
/maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Author: ltheussl
Date: Tue Jul 17 13:45:47 2007
New Revision: 557051
URL: http://svn.apache.org/viewvc?view=rev&rev=557051
Log:
Various fixes to Xdoc parser:
- don't emit anchor for section titles (should be done by a sink if desired)
- handle <h4>, <h5>, <h6> tags as section3, section4, section5
- distinguish between un-ordered and ordered list items
- only use the colspan attribute of table (header) cells if it is non-null
- add lineBreak, horizontalRule, monospaced, definition list and img parsing
- don't emit text events if text is just white space
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/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java
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=557051&r1=557050&r2=557051
==============================================================================
--- 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 17 13:45:47 2007
@@ -29,6 +29,7 @@
import org.apache.maven.doxia.parser.AbstractParser;
import org.apache.maven.doxia.parser.ParseException;
import org.apache.maven.doxia.sink.Sink;
+
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.xml.pull.MXParser;
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -49,6 +50,8 @@
private boolean isLink;
private boolean isAnchor;
+ private boolean isEmptyElement;
+ private int orderedListDepth = 0;
public void parse( Reader reader, Sink sink )
throws ParseException
@@ -98,9 +101,6 @@
}
else if ( parser.getName().equals( "section" ) )
{
- sink.anchor( parser.getAttributeValue( null, "name" ) );
- sink.anchor_();
-
sink.section1();
sink.sectionTitle1();
@@ -111,9 +111,6 @@
}
else if ( parser.getName().equals( "subsection" ) )
{
- sink.anchor( parser.getAttributeValue( null, "name" ) );
- sink.anchor_();
-
sink.section2();
sink.sectionTitle2();
@@ -122,6 +119,19 @@
sink.sectionTitle2_();
}
+ // TODO section3 section4 section5
+ else if ( parser.getName().equals( "h4" ) )
+ {
+ sink.sectionTitle3();
+ }
+ else if ( parser.getName().equals( "h5" ) )
+ {
+ sink.sectionTitle4();
+ }
+ else if ( parser.getName().equals( "h6" ) )
+ {
+ sink.sectionTitle5();
+ }
else if ( parser.getName().equals( "p" ) )
{
sink.paragraph();
@@ -137,10 +147,31 @@
else if ( parser.getName().equals( "ol" ) )
{
sink.numberedList( Sink.NUMBERING_DECIMAL );
+ orderedListDepth++;
}
else if ( parser.getName().equals( "li" ) )
{
- sink.listItem();
+ if ( orderedListDepth == 0 )
+ {
+ sink.listItem();
+ }
+ else
+ {
+ sink.numberedListItem();
+ }
+ }
+ else if ( parser.getName().equals( "dl" ) )
+ {
+ sink.definitionList();
+ }
+ else if ( parser.getName().equals( "dt" ) )
+ {
+ sink.definitionListItem();
+ sink.definedTerm();
+ }
+ else if ( parser.getName().equals( "dd" ) )
+ {
+ sink.definition();
}
else if ( parser.getName().equals( "properties" ) )
{
@@ -154,6 +185,10 @@
{
sink.italic();
}
+ else if ( parser.getName().equals( "tt" ) )
+ {
+ sink.monospaced();
+ }
else if ( parser.getName().equals( "a" ) )
{
String href = parser.getAttributeValue( null, "href" );
@@ -217,16 +252,65 @@
}
else if ( parser.getName().equals( "th" ) )
{
- sink.tableHeaderCell(parser.getAttributeValue( null, "colspan" ));
+ String colspan = parser.getAttributeValue( null, "colspan" );
+ if ( colspan == null)
+ {
+ sink.tableHeaderCell();
+ }
+ else
+ {
+ sink.tableHeaderCell( colspan );
+ }
}
else if ( parser.getName().equals( "td" ) )
{
- sink.tableCell(parser.getAttributeValue( null, "colspan" ));
+ String colspan = parser.getAttributeValue( null, "colspan" );
+ if ( colspan == null)
+ {
+ sink.tableCell();
+ }
+ else
+ {
+ sink.tableCell( colspan );
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Empty elements: <br/>, <hr/> and <img />
+ // ----------------------------------------------------------------------
+
+ else if ( parser.getName().equals( "br" ) )
+ {
+ sink.lineBreak();
+ }
+ else if ( parser.getName().equals( "hr" ) )
+ {
+ sink.horizontalRule();
+ }
+ else if ( parser.getName().equals( "img" ) )
+ {
+ String src = parser.getAttributeValue( null, "src" );
+ String alt = parser.getAttributeValue( null, "alt" );
+
+ sink.figure();
+ sink.figureGraphics( src );
+
+ if ( alt != null )
+ {
+ sink.figureCaption();
+ sink.text( alt );
+ sink.figureCaption_();
+ }
+
+ sink.figure_();
}
else
{
handleRawText( sink, parser );
}
+
+ isEmptyElement = parser.isEmptyElementTag();
+
}
else if ( eventType == XmlPullParser.END_TAG )
{
@@ -261,10 +345,31 @@
else if ( parser.getName().equals( "ol" ) )
{
sink.numberedList_();
+ orderedListDepth--;
}
else if ( parser.getName().equals( "li" ) )
{
- sink.listItem_();
+ if ( orderedListDepth == 0 )
+ {
+ sink.listItem_();
+ }
+ else
+ {
+ sink.numberedListItem_();
+ }
+ }
+ else if ( parser.getName().equals( "dl" ) )
+ {
+ sink.definitionList_();
+ }
+ else if ( parser.getName().equals( "dt" ) )
+ {
+ sink.definedTerm_();
+ }
+ else if ( parser.getName().equals( "dd" ) )
+ {
+ sink.definition_();
+ sink.definitionListItem_();
}
else if ( parser.getName().equals( "properties" ) )
{
@@ -278,6 +383,10 @@
{
sink.italic_();
}
+ else if ( parser.getName().equals( "tt" ) )
+ {
+ sink.monospaced_();
+ }
else if ( parser.getName().equals( "a" ) )
{
if ( isLink )
@@ -329,7 +438,19 @@
{
sink.section2_();
}
- else
+ else if ( parser.getName().equals( "h4" ) )
+ {
+ sink.sectionTitle3_();
+ }
+ else if ( parser.getName().equals( "h5" ) )
+ {
+ sink.sectionTitle4_();
+ }
+ else if ( parser.getName().equals( "h6" ) )
+ {
+ sink.sectionTitle5_();
+ }
+ else if ( !isEmptyElement )
{
sink.rawText( "</" );
@@ -337,14 +458,19 @@
sink.rawText( ">" );
}
+ else
+ {
+ isEmptyElement = false;
+ }
- // ----------------------------------------------------------------------
- // Sections
- // ----------------------------------------------------------------------
}
else if ( eventType == XmlPullParser.TEXT )
{
- sink.text( parser.getText() );
+ String text = parser.getText();
+ if ( !"".equals( text.trim() ) )
+ {
+ sink.text( text );
+ }
}
eventType = parser.next();
Modified: maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.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/XdocSink.java?view=diff&rev=557051&r1=557050&r2=557051
==============================================================================
--- maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java (original)
+++ maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc/XdocSink.java Tue Jul 17 13:45:47 2007
@@ -257,7 +257,7 @@
{
markup( "<section name=\"" );
}
- else
+ else if ( depth == 2 )
{
markup( "<subsection name=\"" );
}
@@ -265,12 +265,40 @@
private void onSectionTitle( int depth )
{
+ if ( depth == 3 )
+ {
+ markup( "<h4>" );
+ }
+ else if ( depth == 4 )
+ {
+ markup( "<h5>" );
+ }
+ else if ( depth == 5 )
+ {
+ markup( "<h6>" );
+ }
+
titleFlag = true;
}
private void onSectionTitle_( int depth )
{
- markup( "\">" );
+ if ( depth == 1 || depth == 2 )
+ {
+ markup( "\">" );
+ }
+ else if ( depth == 3 )
+ {
+ markup( "</h4>" );
+ }
+ else if ( depth == 4 )
+ {
+ markup( "</h5>" );
+ }
+ else if ( depth == 5 )
+ {
+ markup( "</h6>" );
+ }
titleFlag = false;
}
@@ -281,7 +309,7 @@
{
markup( "</section>" );
}
- else
+ else if ( depth == 2 )
{
markup( "</subsection>" );
}
@@ -358,7 +386,7 @@
public void definitionList()
{
- markup( "<dl compact=\"compact\">" + EOL );
+ markup( "<dl>" + EOL );
}
public void definitionList_()
@@ -369,12 +397,12 @@
public void definedTerm()
{
- markup( "<dt><b>" );
+ markup( "<dt>" );
}
public void definedTerm_()
{
- markup( "</b></dt>" + EOL );
+ markup( "</dt>" + EOL );
}
public void definition()
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc: XdocParser.java XdocSink.java
Posted by Jason van Zyl <ja...@maven.org>.
On 21 Jul 07, at 9:51 PM 21 Jul 07, Vincent Siveton wrote:
> Hi Lukas,
>
> Could you correct it or revert it?
>
Once that's done I can try out the new plexus single jar setup. It
appears to be working for the maven bootstrap and if I can properly
try out doxia and it works I can roll it all in.
> Thanks,
>
> Vincent
>
> 2007/7/19, Dennis Lundberg <de...@apache.org>:
>> I've gotten 3 messages informing of failures in
>> org.apache.maven.doxia.siterenderer.DefaultSiteRendererTest
>>
>> but when I look in the mail-archive I see 5 messages.
>>
>> Subject:
>> [continuum] BUILD FAILURE: Doxia Site Renderer Component
>>
>>
>> I have missed several (Maven-mailing-list) messages lately, but I
>> thought it was something wrong with my mail-provider, since the
>> messages
>> are available in the archives.
>>
>> Lukas Theussl wrote:
>> > I know, I am subscribed, did I miss it?
>> >
>> > -Lukas
>> >
>> >
>> > Dennis Lundberg wrote:
>> >> Lukas Theussl wrote:
>> >>
>> >>> It seems like I did break something after all: the site-
>> renderer test
>> >>> now fails (btw, I only noticed it by accident on the continuum
>> page,
>> >>> there was no notification sent?).
>> >>
>> >>
>> >> The notifications are sent to notifications@maven.apache.org
>> >>
>> >>
>> >> <snip/>
>> >>
>>
>>
>> --
>> Dennis Lundberg
>>
Thanks,
Jason
----------------------------------------------------------
Jason van Zyl
Founder and PMC Chair, Apache Maven
jason at sonatype dot com
----------------------------------------------------------
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Posted by Lukas Theussl <lt...@apache.org>.
Yes, yes, yes.. :)
Sorry, I didn't mean to to leave that dangling but I was somewhat
unavailable this weekend, - I'll try to fix it tonight.
I guess I will revert at least part of my commits so we can get alpha-9
out with the previous behavior, but IMO we'll have to break a few things
for beta-1.
-Lukas
Vincent Siveton wrote:
> Hi Lukas,
>
> Could you correct it or revert it?
>
> Thanks,
>
> Vincent
>
> 2007/7/19, Dennis Lundberg <de...@apache.org>:
>
>> I've gotten 3 messages informing of failures in
>> org.apache.maven.doxia.siterenderer.DefaultSiteRendererTest
>>
>> but when I look in the mail-archive I see 5 messages.
>>
>> Subject:
>> [continuum] BUILD FAILURE: Doxia Site Renderer Component
>>
>>
>> I have missed several (Maven-mailing-list) messages lately, but I
>> thought it was something wrong with my mail-provider, since the messages
>> are available in the archives.
>>
>> Lukas Theussl wrote:
>> > I know, I am subscribed, did I miss it?
>> >
>> > -Lukas
>> >
>> >
>> > Dennis Lundberg wrote:
>> >> Lukas Theussl wrote:
>> >>
>> >>> It seems like I did break something after all: the site-renderer test
>> >>> now fails (btw, I only noticed it by accident on the continuum page,
>> >>> there was no notification sent?).
>> >>
>> >>
>> >> The notifications are sent to notifications@maven.apache.org
>> >>
>> >>
>> >> <snip/>
>> >>
>>
>>
>> --
>> Dennis Lundberg
>>
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc: XdocParser.java XdocSink.java
Posted by Vincent Siveton <vi...@gmail.com>.
Hi Lukas,
Could you correct it or revert it?
Thanks,
Vincent
2007/7/19, Dennis Lundberg <de...@apache.org>:
> I've gotten 3 messages informing of failures in
> org.apache.maven.doxia.siterenderer.DefaultSiteRendererTest
>
> but when I look in the mail-archive I see 5 messages.
>
> Subject:
> [continuum] BUILD FAILURE: Doxia Site Renderer Component
>
>
> I have missed several (Maven-mailing-list) messages lately, but I
> thought it was something wrong with my mail-provider, since the messages
> are available in the archives.
>
> Lukas Theussl wrote:
> > I know, I am subscribed, did I miss it?
> >
> > -Lukas
> >
> >
> > Dennis Lundberg wrote:
> >> Lukas Theussl wrote:
> >>
> >>> It seems like I did break something after all: the site-renderer test
> >>> now fails (btw, I only noticed it by accident on the continuum page,
> >>> there was no notification sent?).
> >>
> >>
> >> The notifications are sent to notifications@maven.apache.org
> >>
> >>
> >> <snip/>
> >>
>
>
> --
> Dennis Lundberg
>
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Posted by Dennis Lundberg <de...@apache.org>.
I've gotten 3 messages informing of failures in
org.apache.maven.doxia.siterenderer.DefaultSiteRendererTest
but when I look in the mail-archive I see 5 messages.
Subject:
[continuum] BUILD FAILURE: Doxia Site Renderer Component
I have missed several (Maven-mailing-list) messages lately, but I
thought it was something wrong with my mail-provider, since the messages
are available in the archives.
Lukas Theussl wrote:
> I know, I am subscribed, did I miss it?
>
> -Lukas
>
>
> Dennis Lundberg wrote:
>> Lukas Theussl wrote:
>>
>>> It seems like I did break something after all: the site-renderer test
>>> now fails (btw, I only noticed it by accident on the continuum page,
>>> there was no notification sent?).
>>
>>
>> The notifications are sent to notifications@maven.apache.org
>>
>>
>> <snip/>
>>
--
Dennis Lundberg
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Posted by Lukas Theussl <lt...@apache.org>.
I know, I am subscribed, did I miss it?
-Lukas
Dennis Lundberg wrote:
> Lukas Theussl wrote:
>
>> It seems like I did break something after all: the site-renderer test
>> now fails (btw, I only noticed it by accident on the continuum page,
>> there was no notification sent?).
>
>
> The notifications are sent to notifications@maven.apache.org
>
>
> <snip/>
>
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Posted by Dennis Lundberg <de...@apache.org>.
Lukas Theussl wrote:
> It seems like I did break something after all: the site-renderer test
> now fails (btw, I only noticed it by accident on the continuum page,
> there was no notification sent?).
The notifications are sent to notifications@maven.apache.org
<snip/>
--
Dennis Lundberg
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Posted by Lukas Theussl <lt...@apache.org>.
It seems like I did break something after all: the site-renderer test
now fails (btw, I only noticed it by accident on the continuum page,
there was no notification sent?).
It doesn't seem logical though to me, maybe this should be fixed in the
site renderer. Anyway, if I don't come up with a better solution, I'll
revert that part.
-Lukas
Lukas Theussl wrote:
> The TOCMacro only generates the links, not the anchors, there is a test
> case for it (and I didn't break it! :) ). Logically, I would say it's a
> low-level sink (eg the SiteRendererSink) that should put the anchors in
> place, not the parser (also I don't see eg the AptParser emit any
> anchors for section titles, does it?). Section anchors only make sense
> in an end-user presentation format (xhtml, pdf), you don't want explicit
> anchors to clutter your xdoc or apt sources. But then, I'm not sure I
> didn't break anything, I never used the macro.
>
> -Lukas
>
>
> Vincent Siveton wrote:
>
>> Hi Lukas,
>>
>> 2007/7/17, ltheussl@apache.org <lt...@apache.org>:
>>
>>> Author: ltheussl
>>> Date: Tue Jul 17 13:45:47 2007
>>> New Revision: 557051
>>>
>>> URL: http://svn.apache.org/viewvc?view=rev&rev=557051
>>> Log:
>>> Various fixes to Xdoc parser:
>>> - don't emit anchor for section titles (should be done by a sink if
>>> desired)
>>
>>
>>
>> I think it was handle by the TOCMacro. Could you have a glance on this?
>>
>>> - handle <h4>, <h5>, <h6> tags as section3, section4, section5
>>> - distinguish between un-ordered and ordered list items
>>> - only use the colspan attribute of table (header) cells if it is
>>> non-null
>>> - add lineBreak, horizontalRule, monospaced, definition list and img
>>> parsing
>>> - don't emit text events if text is just white space
>>>
>>
>> Great! Thanks for these!
>>
>> Cheers,
>>
>> Vincent
>>
>> [SNIP]
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc:
XdocParser.java XdocSink.java
Posted by Lukas Theussl <lt...@apache.org>.
The TOCMacro only generates the links, not the anchors, there is a test
case for it (and I didn't break it! :) ). Logically, I would say it's a
low-level sink (eg the SiteRendererSink) that should put the anchors in
place, not the parser (also I don't see eg the AptParser emit any
anchors for section titles, does it?). Section anchors only make sense
in an end-user presentation format (xhtml, pdf), you don't want explicit
anchors to clutter your xdoc or apt sources. But then, I'm not sure I
didn't break anything, I never used the macro.
-Lukas
Vincent Siveton wrote:
> Hi Lukas,
>
> 2007/7/17, ltheussl@apache.org <lt...@apache.org>:
>
>> Author: ltheussl
>> Date: Tue Jul 17 13:45:47 2007
>> New Revision: 557051
>>
>> URL: http://svn.apache.org/viewvc?view=rev&rev=557051
>> Log:
>> Various fixes to Xdoc parser:
>> - don't emit anchor for section titles (should be done by a sink if
>> desired)
>
>
> I think it was handle by the TOCMacro. Could you have a glance on this?
>
>> - handle <h4>, <h5>, <h6> tags as section3, section4, section5
>> - distinguish between un-ordered and ordered list items
>> - only use the colspan attribute of table (header) cells if it is
>> non-null
>> - add lineBreak, horizontalRule, monospaced, definition list and img
>> parsing
>> - don't emit text events if text is just white space
>>
>
> Great! Thanks for these!
>
> Cheers,
>
> Vincent
>
> [SNIP]
Re: svn commit: r557051 - in /maven/doxia/doxia/trunk/doxia-modules/doxia-module-xdoc/src/main/java/org/apache/maven/doxia/module/xdoc: XdocParser.java XdocSink.java
Posted by Vincent Siveton <vi...@gmail.com>.
Hi Lukas,
2007/7/17, ltheussl@apache.org <lt...@apache.org>:
> Author: ltheussl
> Date: Tue Jul 17 13:45:47 2007
> New Revision: 557051
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=557051
> Log:
> Various fixes to Xdoc parser:
> - don't emit anchor for section titles (should be done by a sink if desired)
I think it was handle by the TOCMacro. Could you have a glance on this?
> - handle <h4>, <h5>, <h6> tags as section3, section4, section5
> - distinguish between un-ordered and ordered list items
> - only use the colspan attribute of table (header) cells if it is non-null
> - add lineBreak, horizontalRule, monospaced, definition list and img parsing
> - don't emit text events if text is just white space
>
Great! Thanks for these!
Cheers,
Vincent
[SNIP]