How to create Pygments extension for Sphinx

Glenn Hutchings zondo42 at googlemail.com
Tue Oct 14 13:01:49 EDT 2008


Hi there Pythonistas...

I'm writing documentation for a non-Python program using Sphinx
(http://sphinx.pocoo.org), which is great.  The program has an input
file syntax suitable for highlighting using Pygments (http://
pygments.org), but, obviously, Pygments knows nothing about it.  I've
created a Pygments lexer which should highlight things, but how do I
tell Pygments about the new lexer, short of manually adding the Python
source to the Pygments "lexers" directory (clearly the Wrong Thing)?

I've scoured Sphinx, Pygments and setuptools documentation, and
seemingly the only way is to register a setuptools 'entry point' in
the setup() function -- but that implies I'm installing a Python
package, which I'm not.  Do I have to create one, or is there another
way?

Glenn



More information about the Python-list mailing list