summaryrefslogtreecommitdiff
path: root/doc/docs/lexerdevelopment.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/docs/lexerdevelopment.rst')
-rw-r--r--doc/docs/lexerdevelopment.rst18
1 files changed, 13 insertions, 5 deletions
diff --git a/doc/docs/lexerdevelopment.rst b/doc/docs/lexerdevelopment.rst
index 2c868440..fd6e76b9 100644
--- a/doc/docs/lexerdevelopment.rst
+++ b/doc/docs/lexerdevelopment.rst
@@ -88,10 +88,16 @@ 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`.
-First, change to the current directory containing the Pygments source code:
+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. You
+will need to have either an unpacked source tarball, or (preferably) a copy
+cloned from BitBucket.
.. code-block:: console
@@ -101,11 +107,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: