I started working on a 'section edit' buttons plugin this weekend....
While the syntax plugins make adding new syntax look relatively easy,
modifying existing syntax can be really messy. The problem with the the
way 'section edits' are currently rendered is that they are coupled
very tightly with the 'header' and 'document_end' renderers. To change
the 'section edits' a syntax plugin would have to override 'header' and
'document_end' (replicating all their other code). This looked ugly...
'document_end' does not have a pattern to match, and 'header' uses a
private method '_addCall' to add multiple instructions to the
'instructions list'. For a plugin to replicate this code, it would have
to do things a plugin (probably) should not be doing.... Eventually I
noticed the 'PARSER_HANDLER_DONE' action event which led to this
approach.
Here is the description from a patch I just wrote to decouple the
'section edit' buttons from other code. I think it is better than what
we have now, however I would like some feedback from anyone who has
spent serious time with DokuWiki's parser/handler/renderer code.
decouple section edit from header in renderer:
This patch achieves a partial decoupling of the section edit buttons
from the header syntax. A new 'section_edit' instruction is added to
the
instruction list. The default set of these instructions is generated
from
the header handler and the _finalize function. A generic
'section_edit'
renderer is now part of the renderer.
To rewrite the section semantics, add, or remove section edit buttons
the
header handler and renderer no longer need to be modified. Changes
can be
dynamically made to the section edit buttons through the
'PARSER_HANDLER_DONE'
action event. An action plugin that registers this event can then
modify
the calls list of the handler object before it is rendered.
In short, this patch makes it possible to change the behavior of the
section
edit buttons without having to change unrelated code. This patch
should be
entirely transparent to DokuWiki users and cleanly written plugins.
The patch is attached as a tar gzip'ed file generated with 'darcs send
-o <name>'.
Regards, Ben Coburn
------------------- silicodon.net -------------------