Debian Codegraph @

doc/sphinxext/inline_code_highlight.py

raw symbols SCIP
1 from docutils.core import Publisher
2 from docutils.parsers.rst.roles import code_role
3
4
5 # Monkey patch docutils to give short css names
6 # credit: http://stackoverflow.com/a/21766874/832573
7 def process_programmatic_settings(self, settings_spec,
8 settings_overrides,
9 config_section):
10 if self.settings is None:
11 defaults = (settings_overrides or {}).copy()
12 defaults.setdefault('traceback', True)
13 defaults.setdefault('syntax_highlight', 'short')
14 self.get_settings(settings_spec=settings_spec,
15 config_section=config_section,
16 **defaults)
17
18 Publisher.process_programmatic_settings = process_programmatic_settings
19
20
21 def python_role(role, rawtext, text, lineno,
22 inliner, options={}, content=[]):
23 options = {'language': 'python'}
24 return code_role(role, rawtext, text, lineno,
25 inliner, options=options, content=content)
26
27
28 def setup(app):
29 app.add_role('python', python_role)
30 app.add_role('py', python_role)