summaryrefslogtreecommitdiff
path: root/sphinx/directives/code.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-02-07 23:42:54 +0100
committerGeorg Brandl <georg@python.org>2010-02-07 23:42:54 +0100
commit53988fa17f5432c0b3ea6e9e1aa495a6a6b8a502 (patch)
treea39ffac7574e01aa1e90eab7a170911f5085d22b /sphinx/directives/code.py
parentbe1f7103cb94ad4000cb495b501066b7a568b24e (diff)
parent29bcbce1f0c7ffe190fdd73a14d96bc7edbc15d8 (diff)
downloadsphinx-53988fa17f5432c0b3ea6e9e1aa495a6a6b8a502.tar.gz
merge with 0.6
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r--sphinx/directives/code.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py
index f5a8f8af..5f2fd51e 100644
--- a/sphinx/directives/code.py
+++ b/sphinx/directives/code.py
@@ -81,12 +81,15 @@ class LiteralInclude(Directive):
final_argument_whitespace = False
option_spec = {
'linenos': directives.flag,
+ 'tab-width': int,
'language': directives.unchanged_required,
'encoding': directives.encoding,
'pyobject': directives.unchanged_required,
'lines': directives.unchanged_required,
'start-after': directives.unchanged_required,
'end-before': directives.unchanged_required,
+ 'prepend': directives.unchanged_required,
+ 'append': directives.unchanged_required,
}
def run(self):
@@ -150,7 +153,9 @@ class LiteralInclude(Directive):
lines = [lines[i] for i in linelist]
startafter = self.options.get('start-after')
- endbefore = self.options.get('end-before')
+ endbefore = self.options.get('end-before')
+ prepend = self.options.get('prepend')
+ append = self.options.get('append')
if startafter is not None or endbefore is not None:
use = not startafter
res = []
@@ -164,7 +169,14 @@ class LiteralInclude(Directive):
res.append(line)
lines = res
+ if prepend:
+ lines.insert(0, prepend + '\n')
+ if append:
+ lines.append(append + '\n')
+
text = ''.join(lines)
+ if self.options.get('tab-width'):
+ text = text.expandtabs(self.options['tab-width'])
retnode = nodes.literal_block(text, text, source=fn)
retnode.line = 1
if self.options.get('language', ''):