summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstrank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-03-12 11:36:05 +0000
committerstrank <strank@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-03-12 11:36:05 +0000
commit94d9ff0e44c139a924a2a45d081d2aeca342811a (patch)
tree5a492f9290e4c4f370a0993c3f52a85713de4fac
parent33fa19979381c41ba619ce55bb1411056bc82e28 (diff)
downloaddocutils-include-after-until.tar.gz
renamed after/until options to start-after/end-beforeinclude-after-until
git-svn-id: http://svn.code.sf.net/p/docutils/code/branches/include-after-until@5014 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
-rw-r--r--docs/ref/rst/directives.txt4
-rw-r--r--docutils/parsers/rst/directives/misc.py22
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_include.py58
3 files changed, 42 insertions, 42 deletions
diff --git a/docs/ref/rst/directives.txt b/docs/ref/rst/directives.txt
index 36b38fe86..f99bcdd8a 100644
--- a/docs/ref/rst/directives.txt
+++ b/docs/ref/rst/directives.txt
@@ -1371,11 +1371,11 @@ __ substitutions.html
The following options are recognized:
-``after`` : text to find in the external data file
+``start-after`` : text to find in the external data file
Only the content after the first occurrence of the specified text
will be included.
-``until`` : text to find in the external data file
+``end-before`` : text to find in the external data file
Only the content before the first occurrence of the specified text
(but after any ``after`` text) will be included.
diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py
index 79bc4a28a..5d5d34729 100644
--- a/docutils/parsers/rst/directives/misc.py
+++ b/docutils/parsers/rst/directives/misc.py
@@ -32,8 +32,8 @@ class Include(Directive):
final_argument_whitespace = True
option_spec = {'literal': directives.flag,
'encoding': directives.encoding,
- 'after': directives.unchanged_required,
- 'until': directives.unchanged_required}
+ 'start-after': directives.unchanged_required,
+ 'end-before': directives.unchanged_required}
standard_include_path = os.path.join(os.path.dirname(states.__file__),
'include')
@@ -68,24 +68,24 @@ class Include(Directive):
raise self.severe(
'Problem with "%s" directive:\n%s: %s'
% (self.name, error.__class__.__name__, error))
- # For after/until there are no restrictions on newlines in match-text,
+ # start-after/end-before: no restrictions on newlines in match-text,
# and no restrictions on matching inside lines vs. line boundaries
- after_text = self.options.get('after', None)
+ after_text = self.options.get('start-after', None)
if after_text:
# skip content in include_text before *and incl.* a matching text
after_index = include_text.find(after_text)
if after_index < 0:
- raise self.severe('Problem with "after" option of "%s" '
+ raise self.severe('Problem with "start-after" option of "%s" '
'directive:\nText not found.' % self.name)
include_text = include_text[after_index + len(after_text):]
- until_text = self.options.get('until', None)
- if until_text:
+ before_text = self.options.get('end-before', None)
+ if before_text:
# skip content in include_text after *and incl.* a matching text
- until_index = include_text.find(until_text)
- if until_index < 0:
- raise self.severe('Problem with "until" option of "%s" '
+ before_index = include_text.find(before_text)
+ if before_index < 0:
+ raise self.severe('Problem with "end-before" option of "%s" '
'directive:\nText not found.' % self.name)
- include_text = include_text[:until_index]
+ include_text = include_text[:before_index]
if self.options.has_key('literal'):
literal_block = nodes.literal_block(include_text, include_text,
source=path)
diff --git a/test/test_parsers/test_rst/test_directives/test_include.py b/test/test_parsers/test_rst/test_directives/test_include.py
index e55797eb1..5a6f7bbc3 100755
--- a/test/test_parsers/test_rst/test_directives/test_include.py
+++ b/test/test_parsers/test_rst/test_directives/test_include.py
@@ -394,38 +394,38 @@ Nonexistent standard include data file:
.. include:: <nonexistent>
""" % nonexistent_rel],
["""\
-Include after-until Test
+Include start-after/end-before Test
.. include:: %s
- :after: .. start here
- :until: .. stop here
+ :start-after: .. start here
+ :end-before: .. stop here
A paragraph.
""" % include12,
"""\
<document source="test data">
<paragraph>
- Include after-until Test
+ Include start-after/end-before Test
<paragraph>
In include12.txt (after "start here", before "stop here")
<paragraph>
A paragraph.
"""],
["""\
-Include after-until Test, single option variant
+Include start-after/end-before Test, single option variant
.. include:: %s
- :until: .. start here
+ :end-before: .. start here
.. include:: %s
- :after: .. stop here
+ :start-after: .. stop here
A paragraph.
""" % (include12, include12),
"""\
<document source="test data">
<paragraph>
- Include after-until Test, single option variant
+ Include start-after/end-before Test, single option variant
<paragraph>
In include12.txt (but before "start here")
<paragraph>
@@ -434,18 +434,18 @@ A paragraph.
A paragraph.
"""],
["""\
-Include after/until multi-line test.
+Include start-after/end-before multi-line test.
.. include:: %s
- :after: From: me
- To: you
- :until: -------
- -- mork of ork
+ :start-after: From: me
+ To: you
+ :end-before: -------
+ -- mork of ork
.. include:: %s
- :after: From: me
- To: you
- :until:
+ :start-after: From: me
+ To: you
+ :end-before:
-------
-- mork of ork
@@ -454,41 +454,41 @@ A paragraph.
"""\
<document source="test data">
<paragraph>
- Include after/until multi-line test.
+ Include start-after/end-before multi-line test.
<system_message level="4" line="3" source="test data" type="SEVERE">
<paragraph>
- Problem with "until" option of "include" directive:
+ Problem with "end-before" option of "include" directive:
Text not found.
<literal_block xml:space="preserve">
.. include:: %s
- :after: From: me
- To: you
- :until: -------
- -- mork of ork
+ :start-after: From: me
+ To: you
+ :end-before: -------
+ -- mork of ork
<paragraph>
In include13.txt (between header and signature)
<paragraph>
A paragraph.
""" % include13],
["""\
-Error handling test; "until" error handling tested in previous test.
+Error handling test; "end-before" error handling tested in previous test.
.. include:: %s
- :after: bad string
- :until: mork of ork
+ :start-after: bad string
+ :end-before: mork of ork
""" % include13,
"""\
<document source="test data">
<paragraph>
- Error handling test; "until" error handling tested in previous test.
+ Error handling test; "end-before" error handling tested in previous test.
<system_message level="4" line="3" source="test data" type="SEVERE">
<paragraph>
- Problem with "after" option of "include" directive:
+ Problem with "start-after" option of "include" directive:
Text not found.
<literal_block xml:space="preserve">
.. include:: %s
- :after: bad string
- :until: mork of ork
+ :start-after: bad string
+ :end-before: mork of ork
""" % include13],
]