summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2016-02-15 08:39:51 +0100
committerGeorg Brandl <georg@python.org>2016-02-15 08:39:51 +0100
commit3f7d5c58d1f87959b241daa554abdbf5613d7ba5 (patch)
treef61cfe45d0560e0da7f0ae903e1588fd88c564e2 /doc
parent5cc92cf8771627278cdb7b374ba0a101fad72bd2 (diff)
downloadpygments-3f7d5c58d1f87959b241daa554abdbf5613d7ba5.tar.gz
Add a few more introductory words to lexerdev.
Diffstat (limited to 'doc')
-rw-r--r--doc/docs/lexerdevelopment.rst14
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: