Made start (copy of the Trac2MediaWiki) plugin:
trac-
tracwiki2sphinx-
tracwiki2sphinx-vi
DONE with standalone MediaWiki converter
Approaches:
- adapt something like this to generate rst, it deals in trac APIs for converters and formatters so offers some higher lever wins over bare regexp handling, at expense of getting intimate with Trac API
- the dependence on trac makes for more complicated development and testing : knocked this for six with standalone converter
- XMLRPC access not so useful here, depends on impinging on the Trac conversion machinery that normally creats html from wikitext, and instead creates rst
http://pypi.python.org/pypi/trac2rst
- quick and dirty regexp based
- this nicely fits with XMLRPC access to the wikitext
- https://bitbucket.org/pcaro/trac2rst/src/9d1b605ac030/src/trac2rst/core.py
- would need to add support for my common trac wiki usage patterns
Checkout the trac source
Formatters such as Trac2MediaWiki work by extending the trac.wiki.formatter.Formatter with a large-ish number of specialization formatter methods. Crucial part of trac.wiki.formatter.Formatter subclasses, are the internal handlers with method signature convention _<type>_formatter(match, fullmatch). The formatter methods as invoked by the handle_match method.
# -- Wiki engine
def handle_match(self, fullmatch):
for itype, match in fullmatch.groupdict().items():
if match and not itype in self.wikiparser.helper_patterns:
# Check for preceding escape character '!'
if match[0] == '!':
return escape(match[1:])
if itype in self.wikiparser.external_handlers:
external_handler = self.wikiparser.external_handlers[itype]
return external_handler(self, match, fullmatch)
else:
internal_handler = getattr(self, '_%s_formatter' % itype)
return internal_handler(match, fullmatch)
The formatter is plugged into trac component system via:
class Trac2MediaWikiPlugin(Component):
implements(IContentConverter)
Need to find Sphinx/RST equivalent representation of Trac metadata, and preserve this in migration:
https://groups.google.com/forum/?fromgroups#!topic/sphinx-dev/Hszmw8clhrM
Investigate in env.sphinxext.taglist looks like only specific metadata keys are read
Need a Sphinx extension to handle this, maybe use standard top of doc fieldlist:
:tags: Red, Green, Blue
And/or extension (assuming can grab the page context and get the metadats tags on that page with local)
.. taglist:: :local:
* http://sphinx.pocoo.org/markup/misc.html
Trac taglists are dynamic and provide links to pages featuring those tags,
- how to do that possible in Sphinx ?