blob: 1e6cbad1167103e519f7a1e271681f79d39bb26b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
=====================
The full Pygments API
=====================
This page describes the Pygments API.
High-level API
==============
.. module:: pygments
Functions from the :mod:`pygments` module:
.. autofunction:: lex
.. autofunction:: format
.. autofunction:: highlight
.. module:: pygments.lexers
Functions from :mod:`pygments.lexers`:
.. autofunction:: get_lexer_by_name
.. autofunction:: get_lexer_for_filename
.. autofunction:: get_lexer_for_mimetype
.. autofunction:: load_lexer_from_file
.. autofunction:: guess_lexer
.. autofunction:: guess_lexer_for_filename
.. autofunction:: get_all_lexers
.. autofunction:: find_lexer_class_by_name
.. autofunction:: find_lexer_class
.. module:: pygments.formatters
Functions from :mod:`pygments.formatters`:
.. autofunction:: get_formatter_by_name
.. autofunction:: get_formatter_for_filename
.. autofunction:: load_formatter_from_file
.. module:: pygments.styles
Functions from :mod:`pygments.styles`:
.. autofunction:: get_style_by_name
.. autofunction:: get_all_styles
.. autodata:: STYLE_MAP
.. module:: pygments.lexer
Lexers
======
The base lexer class from which all lexers are derived is:
.. autoclass:: Lexer
:members: __init__, get_tokens, get_tokens_unprocessed, analyse_text
There are several base class derived from ``Lexer`` you can use to build your lexer from:
.. autoclass:: pygments.lexer.RegexLexer
.. autoclass:: pygments.lexer.ExtendedRegexLexer
.. autoclass:: pygments.lexer.DelegatingLexer
.. module:: pygments.formatter
Formatters
==========
A formatter is derived from this class:
.. autoclass:: Formatter
:members: __init__, get_style_defs, format
.. module:: pygments.util
Utilities
=========
The :mod:`pygments.util` module has some utility functions usable for processing
command line options. All of the following functions get values from a
dictionary of options. If the value is already in the type expected by the
option, it is returned as-is. Otherwise, if the value is a string, it is first
converted to the expected type if possible.
.. autoexception:: OptionError
.. autofunction:: get_bool_opt
.. autofunction:: get_int_opt
.. autofunction:: get_list_opt
.. autofunction:: get_choice_opt
It also defines an exception:
.. autoexception:: ClassNotFound
|