On Sep 2, 2008, at 10:54 PM, Sergiu Dumitriu wrote:
vmassol (SVN) wrote:
Author: vmassol
Date: 2008-09-02 12:18:10 +0200 (Tue, 02 Sep 2008)
New Revision: 12357
Added:
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/block/AbstractVerbatimBlock.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/block/InlineVerbatimBlock.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/block/StandaloneVerbatimBlock.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/block/VerbatimBlock.java
platform/core/trunk/xwiki-rendering/src/test/resources/verbatim/
platform/core/trunk/xwiki-rendering/src/test/resources/verbatim/
verbatim1.test
platform/core/trunk/xwiki-rendering/src/test/resources/verbatim/
verbatim2.test
platform/core/trunk/xwiki-rendering/src/test/resources/verbatim/
verbatim3.test
Removed:
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/internal/macro/nowiki/
platform/core/trunk/xwiki-rendering/src/test/resources/macros/
macronowiki.test
Modified:
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/block/EscapeBlock.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/internal/parser/doxia/DoxiaGeneratorListener.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/internal/parser/wikimodel/WikiModelGeneratorListener.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/internal/parser/wikimodel/XDOMGeneratorListener.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/listener/Listener.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/listener/ListenerDelegate.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/renderer/EventsRenderer.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/renderer/XWikiSyntaxRenderer.java
platform/core/trunk/xwiki-rendering/src/main/java/org/xwiki/
rendering/renderer/xhtml/XHTMLRenderer.java
platform/core/trunk/xwiki-rendering/src/main/resources/META-INF/
plexus/components.xml
platform/core/trunk/xwiki-rendering/src/test/java/org/xwiki/
rendering/RenderingTests.java
Log:
XWIKI-2634: Various tasks for the new rendering implementation
* Added support for verbatim.
* Removed nowiki macro which is no longer necessary
I'm starting to dislike the way renderers are done. They have many
methods to handle each type of element, the renderer classes are
already
becoming large, and introducing a new element requires changing many
classes. Isn't there a better way to do this?
All I know is that it's the way done by both Doxia and WikiModel (and
WikiModel has been redone 2 or 3 times already).
One would be to have just an onEvent method, and
then the XYZRenderer
would forward the call to a specific class responsible for handling
that
type of event. The downside is that we'll have many small classes and
large configuration files, but the advantage is that unimplemented
elements won't throw exceptions, but use a generic event handler.
I don't know which way is better, fewer huge classes, or more tiny
classes. If the syntax will become *very* stable soon, then I guess
the
current way is good, too.
A syntax has to be very stable IMO. It's not something meant to evolve
either (or very little). Actually I could add all the methods in one
go but I wanted to understand each of them and understand the need for
them before adding them so I'm doing this incrementally.
We're getting close to the max number of methods in the Listener
interface:
- 3-4 more for tables
- 3-4 more for definition lists if we want to handle that
I agree with you but I think the current design is ok because:
- the syntax is fixed and finite
- it's not so big (We currently have 30 methods, wikimodel has 50 so
eventually we could reach that number)
- it's very clear. It's easy to read and understand.
- that's the way done by wikimodel/Doxia so the mapping is clear too.
Re generic event handler we can have that too with the current design
if we want but that's not something we want IMO since it means the
listener just won't work.
That said what you propose is tempting. I'd need to think more about
it but it does mean lots and lots of classes. For a single renderer
this means something like 40 classes. Right now we have only 4
renderers (Events, XWiki syntax, XHTML and Tex). So that's already 160
classes. In the future we'll have about 10 (RTF, PDF, etc). Imagine,
that's 400 classes! That looks a bit too much maybe?
Let's think more about it.
If the syntax is almost complete, then let's leave it like this.
--
Sergiu Dumitriu