Permalink
Browse files

Version 0.4

Put a line of whitespace at the beginning and end of each snippet for improved readability
  • Loading branch information...
1 parent db69408 commit 57e4d2e296d50b94e130c18c4206b6eed9d8eaa9 @knatten knatten committed with May 1, 2012
View
2 plugin/SnippetySnip/SnippetySnip.vim
@@ -1,5 +1,5 @@
" Vim plugin for importing into a file selected lines from other files
-" Version: 0.3
+" Version: 0.4
" Last change: 2011-08-28
" Author: Anders Schau Knatten
" Contact: anders AT knatten DOT org
View
1 python/SnippetySnip/integration_test.py
@@ -3,6 +3,7 @@
class Test_IntegrationTest(unittest.TestCase):
def test_integration_test(self):
+ self.maxDiff = None
buf = open('integration_tests/example.html', 'r').readlines()
buf = [line[:-1] for line in buf]
expected = open('integration_tests/expected.html', 'r').readlines()
View
6 python/SnippetySnip/integration_tests/expected.html
@@ -1,23 +1,29 @@
<h2>Here is an example from C++</h2>
<p>
<!-- snippetysnip:integration_tests/example1.cpp:bar -->
+
int bar() {
return 0;
}
+
<!-- snippetysnip_end:integration_tests/example1.cpp:bar -->
</p>
<h2>Here is an example from Python</h2>
<p>
<!-- snippetysnip:integration_tests/example2.py:tidum -->
+
def tidum():
return 0
+
<!-- snippetysnip_end:integration_tests/example2.py:tidum -->
</p>
<h2>More from the same file, with extra text wrapping the snippet</h2>
<!-- snippetysnip:integration_tests/example1.cpp:baz:(before='[sourcecode language="cpp"]', after='[/sourcecode]') -->
+
[sourcecode language="cpp"]
int baz() {
return 0;
}
[/sourcecode]
+
<!-- snippetysnip_end:integration_tests/example1.cpp:baz -->
View
2 python/SnippetySnip/snippetysnip.py
@@ -65,13 +65,15 @@ def insert_snippets(old_buffer, snippet_getter=get_snippet):
new_buffer.append(line)
match = re.search(snippet_begin, line)
if match:
+ new_buffer.append('')
arguments = get_arguments(line)
file_name, snippet_name = match.groups()
if arguments.has_key('before'):
new_buffer.append(arguments['before'])
new_buffer.extend(snippet_getter(file_name, snippet_name).split("\n")[:-1])
if arguments.has_key('after'):
new_buffer.append(arguments['after'])
+ new_buffer.append('')
new_buffer.append(remove_arguments(line).replace("snippetysnip", "snippetysnip_end"))
end_line = find_end_line(old_buffer[line_no:], file_name, snippet_name)
if end_line != -1:
View
6 python/SnippetySnip/test.py
@@ -44,8 +44,10 @@ def test_inserts_simple_snippet(self):
expected = [
"foo",
"<!-- snippetysnip:snippy.cpp:snippet -->",
+ "",
"line1",
"line2",
+ "",
"<!-- snippetysnip_end:snippy.cpp:snippet -->",
"bar"
]
@@ -63,8 +65,10 @@ def test_replaces_simple_snippet(self):
expected = [
"foo",
"<!-- snippetysnip:snippy.cpp:snippet -->",
+ "",
"line1",
"line2",
+ "",
"<!-- snippetysnip_end:snippy.cpp:snippet -->",
"bar"
]
@@ -80,9 +84,11 @@ def test_inserts_before(self):
expected = [
"foo",
"<!-- snippetysnip:snippy.cpp:snippet:(before=\"[sourcecode language='cpp']\") -->",
+ "",
"[sourcecode language='cpp']",
"line1",
"line2",
+ "",
"<!-- snippetysnip_end:snippy.cpp:snippet -->",
"bar"
]

0 comments on commit 57e4d2e

Please sign in to comment.