summaryrefslogtreecommitdiff
path: root/sphinx/directives/code.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2015-12-20 22:44:32 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2015-12-20 22:44:32 +0900
commit4234c88f21f7f2a120a8d3df8aea1244ee8e2986 (patch)
tree9214f63aaae12161b020185d5baffa1f9f115e0d /sphinx/directives/code.py
parentbf1cc7099670d5a9ac1019b704d36ea1ab4bae13 (diff)
downloadsphinx-git-4234c88f21f7f2a120a8d3df8aea1244ee8e2986.tar.gz
Fix #2113: Allow ``:class:`` option to code-block directive
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r--sphinx/directives/code.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index f31ba7a99..5b4bcde6d 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -93,6 +93,7 @@ class CodeBlock(Directive):
'lineno-start': int,
'emphasize-lines': directives.unchanged_required,
'caption': directives.unchanged_required,
+ 'class': directives.class_option,
'name': directives.unchanged,
}
@@ -119,6 +120,7 @@ class CodeBlock(Directive):
literal['language'] = self.arguments[0]
literal['linenos'] = 'linenos' in self.options or \
'lineno-start' in self.options
+ literal['classes'] += self.options.get('class', [])
extra_args = literal['highlight_args'] = {}
if hl_lines is not None:
extra_args['hl_lines'] = hl_lines
@@ -165,6 +167,7 @@ class LiteralInclude(Directive):
'append': directives.unchanged_required,
'emphasize-lines': directives.unchanged_required,
'caption': directives.unchanged,
+ 'class': directives.class_option,
'name': directives.unchanged,
'diff': directives.unchanged_required,
}
@@ -322,6 +325,7 @@ class LiteralInclude(Directive):
retnode['linenos'] = 'linenos' in self.options or \
'lineno-start' in self.options or \
'lineno-match' in self.options
+ retnode['classes'] += self.options.get('class', [])
extra_args = retnode['highlight_args'] = {}
if hl_lines is not None:
extra_args['hl_lines'] = hl_lines