eric6/ThirdParty/Pygments/pygments/plugin.py

changeset 6942
2602857055c5
parent 6651
e8f3b5568b21
child 7547
21b0534faebc
equal deleted inserted replaced
6941:f99d60d6b59b 6942:2602857055c5
1 # -*- coding: utf-8 -*-
2 """
3 pygments.plugin
4 ~~~~~~~~~~~~~~~
5
6 Pygments setuptools plugin interface. The methods defined
7 here also work if setuptools isn't installed but they just
8 return nothing.
9
10 lexer plugins::
11
12 [pygments.lexers]
13 yourlexer = yourmodule:YourLexer
14
15 formatter plugins::
16
17 [pygments.formatters]
18 yourformatter = yourformatter:YourFormatter
19 /.ext = yourformatter:YourFormatter
20
21 As you can see, you can define extensions for the formatter
22 with a leading slash.
23
24 syntax plugins::
25
26 [pygments.styles]
27 yourstyle = yourstyle:YourStyle
28
29 filter plugin::
30
31 [pygments.filter]
32 yourfilter = yourfilter:YourFilter
33
34
35 :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
36 :license: BSD, see LICENSE for details.
37 """
38 LEXER_ENTRY_POINT = 'pygments.lexers'
39 FORMATTER_ENTRY_POINT = 'pygments.formatters'
40 STYLE_ENTRY_POINT = 'pygments.styles'
41 FILTER_ENTRY_POINT = 'pygments.filters'
42
43
44 def iter_entry_points(group_name):
45 try:
46 import pkg_resources
47 except (ImportError, IOError):
48 return []
49
50 return pkg_resources.iter_entry_points(group_name)
51
52
53 def find_plugin_lexers():
54 for entrypoint in iter_entry_points(LEXER_ENTRY_POINT):
55 yield entrypoint.load()
56
57
58 def find_plugin_formatters():
59 for entrypoint in iter_entry_points(FORMATTER_ENTRY_POINT):
60 yield entrypoint.name, entrypoint.load()
61
62
63 def find_plugin_styles():
64 for entrypoint in iter_entry_points(STYLE_ENTRY_POINT):
65 yield entrypoint.name, entrypoint.load()
66
67
68 def find_plugin_filters():
69 for entrypoint in iter_entry_points(FILTER_ENTRY_POINT):
70 yield entrypoint.name, entrypoint.load()

eric ide

mercurial