Hi someone said "show me the code" so I'm diving in. I'm trying to make parserTests work without the database (without installing anything). I'm basically just going through the code running it, fixing and error, then running until the next error.
Now I'm brand new to MediaWiki but I've done a lot of programming in lots of languages. Including a bit of PHP. Seems to me like there's an awful lot of global functions which is a bit worrying. Maybe this is just the normal way to do things in PHP but it seems a bit worrying to me because it could mean spaghetti code. Umm... documentation isn't great but I've seen worse (like Mozilla).
But.. the biggest thing seems to be that the database kind of permeates the whole code... I can see why parserTests' author wrote separating it from the database as a @todo... and it's a bit tricky. I'm trying to do that now, writing fake classes and stuff in there. We'll see if it works out. A good long-term project might be to refactor so that the database is well isolated from the rest of the code. So that, for example, you could rip out the database and insert something else, or like for parserTests, run some parts of the code without a database at all. That's especially useful for unit tests :-)
(For example I tried to include "commandLine.inc" and it wouldn't go because there's no database. I made a "commandLineSimple.inc" and ripped out all the database code.)
I've hit a point now where the Parser access User functions. With a command line test there's not going to be a user, so I could either fake one, or I could temporarily modify the parser.
It seems like this might be a good place to insert an intermediate parsing format (something between the article{wikitext, ...} and the final HTML.
--simon
S. Woodside wrote:
I've hit a point now where the Parser access User functions. With a command line test there's not going to be a user, so I could either fake one, or I could temporarily modify the parser.
If there's something in Parser that accesses a user directly it perhaps should be migrated to ParserOptions, as that's what it's for.
It seems like this might be a good place to insert an intermediate parsing format (something between the article{wikitext, ...} and the final HTML.
There's a couple attempts at this floating around, not sure what the state is.
-- brion vibber (brion @ pobox.com)
Brion Vibber wrote:
S. Woodside wrote:
It seems like this might be a good place to insert an intermediate parsing format (something between the article{wikitext, ...} and the final HTML.
There's a couple attempts at this floating around, not sure what the state is.
Perfect opportunity for yet another shameless plug of mine :-)
http://magnusmanske.de/wiki2xml/w2x.php
converts wikitext into XML. It can work directly off wikitext, or using an existing MediaWiki installation as source, in which case it can automatically resolve templates.
It probably needs some testing for bugs, but generally seems to work quite well.
Code is in CVS, module "wiki2xml", directory "php".
Magnus
wikitech-l@lists.wikimedia.org