diff options
| author | Georg Brandl <georg@python.org> | 2016-02-15 08:39:51 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2016-02-15 08:39:51 +0100 |
| commit | c8509eca357a8978216447a99b6ae3294ea17ba2 (patch) | |
| tree | 9e8b9b03562017b9b746bf958bafe31ab809a244 /doc | |
| parent | 8933a64a6eaf30645af5170b69c09904c4217b6c (diff) | |
| download | pygments-git-c8509eca357a8978216447a99b6ae3294ea17ba2.tar.gz | |
Add a few more introductory words to lexerdev.
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/docs/lexerdevelopment.rst | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/doc/docs/lexerdevelopment.rst b/doc/docs/lexerdevelopment.rst index 2c868440..02d466a3 100644 --- a/doc/docs/lexerdevelopment.rst +++ b/doc/docs/lexerdevelopment.rst @@ -88,8 +88,12 @@ one. Adding and testing a new lexer ============================== -To make Pygments aware of your new lexer, you have to perform the following -steps: +Using a lexer that is not part of Pygments can be done via the Python API. You +can import and instantiate the lexer, and pass it to :func:`pygments.highlight`. + +To prepare your new lexer for inclusion in the Pygments distribution, so that it +will be found when passing filenames or lexer aliases from the command line, you +have to perform the following steps. First, change to the current directory containing the Pygments source code: @@ -101,11 +105,13 @@ Select a matching module under ``pygments/lexers``, or create a new module for your lexer class. Next, make sure the lexer is known from outside of the module. All modules in -the ``pygments.lexers`` specify ``__all__``. For example, ``esoteric.py`` sets:: +the ``pygments.lexers`` package specify ``__all__``. For example, +``esoteric.py`` sets:: __all__ = ['BrainfuckLexer', 'BefungeLexer', ...] -Simply add the name of your lexer class to this list. +Add the name of your lexer class to this list (or create the list if your lexer +is the only class in the module). Finally the lexer can be made publicly known by rebuilding the lexer mapping: |
