Debian Codegraph @

IPython/sphinxext/ipython_console_highlighting.py

raw
1 """
2 reST directive for syntax-highlighting ipython interactive sessions.
3
4 """
5
6 from sphinx import highlighting
7 from ipython_pygments_lexers import IPyLexer
8
9
10 def setup(app):
11 """Setup as a sphinx extension."""
12
13 # This is only a lexer, so adding it below to pygments appears sufficient.
14 # But if somebody knows what the right API usage should be to do that via
15 # sphinx, by all means fix it here. At least having this setup.py
16 # suppresses the sphinx warning we'd get without it.
17 metadata = {"parallel_read_safe": True, "parallel_write_safe": True}
18 return metadata
19
20
21 # Register the extension as a valid pygments lexer.
22 # Alternatively, we could register the lexer with pygments instead. This would
23 # require using setuptools entrypoints: http://pygments.org/docs/plugins
24
25 ipy3 = IPyLexer()
26
27 highlighting.lexers["ipython"] = ipy3
28 highlighting.lexers["ipython3"] = ipy3