Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/pygments/plugin.py : 43%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# -*- coding: utf-8 -*-
2"""
3 pygments.plugin
4 ~~~~~~~~~~~~~~~
6 Pygments setuptools plugin interface. The methods defined
7 here also work if setuptools isn't installed but they just
8 return nothing.
10 lexer plugins::
12 [pygments.lexers]
13 yourlexer = yourmodule:YourLexer
15 formatter plugins::
17 [pygments.formatters]
18 yourformatter = yourformatter:YourFormatter
19 /.ext = yourformatter:YourFormatter
21 As you can see, you can define extensions for the formatter
22 with a leading slash.
24 syntax plugins::
26 [pygments.styles]
27 yourstyle = yourstyle:YourStyle
29 filter plugin::
31 [pygments.filter]
32 yourfilter = yourfilter:YourFilter
35 :copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
36 :license: BSD, see LICENSE for details.
37"""
38LEXER_ENTRY_POINT = 'pygments.lexers'
39FORMATTER_ENTRY_POINT = 'pygments.formatters'
40STYLE_ENTRY_POINT = 'pygments.styles'
41FILTER_ENTRY_POINT = 'pygments.filters'
44def iter_entry_points(group_name):
45 try:
46 import pkg_resources
47 except (ImportError, IOError):
48 return []
50 return pkg_resources.iter_entry_points(group_name)
53def find_plugin_lexers():
54 for entrypoint in iter_entry_points(LEXER_ENTRY_POINT):
55 yield entrypoint.load()
58def find_plugin_formatters():
59 for entrypoint in iter_entry_points(FORMATTER_ENTRY_POINT):
60 yield entrypoint.name, entrypoint.load()
63def find_plugin_styles():
64 for entrypoint in iter_entry_points(STYLE_ENTRY_POINT):
65 yield entrypoint.name, entrypoint.load()
68def find_plugin_filters():
69 for entrypoint in iter_entry_points(FILTER_ENTRY_POINT):
70 yield entrypoint.name, entrypoint.load()