Hey,
(This is take 2 on this subject, as the last thread derailed into parser
internals discussions which have rather little to do with the Validator
extension. I also added some dev docs [1] which are likely to provide a
better picture of the extensions function.)
Over the past year I've been working on an extension to facilitate parameter
handling in MediaWiki, with a focus on parser hooks. It's titled
Validator[0], which currently is a bit misleading since it enables a
lot more then
simple validation. As the only thing this extension does is facilitate
parameter handling in other extensions, I think it makes sense to include it
into core, or at least in the default MediaWiki distribution. To be clear,
the subject of this request is only the parameter handling code of the
Validator extension. It also contains parser hooks for error handling and
automatic documentation generation, but I'm not proposing to put these into
core (they can easily be split off).
I created this extension out of frustration as an extension developer that
to create a parser hook, you need to do the same plumbing over and over
again, and have to write a whole mess of parsing and validation code that is
similar for almost every parser hook. Of course this is doable, but it's
error prone, causes small differences in how exactly parameters are handled
in different parser hooks (not very nice for the end users), and is hard to
maintain. If you have done this a few times, it becomes rather obvious that
a more generic framework to handle parameters would be a big win. You want
to describe a parameter, not all the details of how it should be handled.
Using Validator is somewhat similar to how API classes and their
getParameters methods work, but more powerful and extensible. I just wrote
up some documentation on how to create your own implementation using
Validator here [1]. If anything is unclear, please let me know.
Putting this functionality in core would be a big help to everyone writing
new parameter handling code, and would enable cleaning up existing
implementations where this is desired. As this functionality does not
replace anything in core, putting it in would not disrupt anything. I'm
willing to do the little work required to merge Validator into core.
I'd very much appreciate if some people gave useful feedback on the
extension in relation to its main functionality, parameter handling, and if
this makes sense to put into core or not. If you want to discuss anything
parser related, please start your own thread :)
[0]
https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:
Validator
[1]
https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:Validator#I…
Cheers
--
Jeroen De Dauw
http://www.bn2vs.com
Don't panic. Don't be evil.
--