summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-04-12 21:06:15 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-04-14 18:32:40 +0900
commit1900c729a3e940af49706dabb36addbc6a076ecb (patch)
tree854f2f14510cea0e2cc55cf4abfa9cede8501959
parent11a4e47d6295b40ca02f3d2dd0e6e021568c150f (diff)
downloadsphinx-git-1900c729a3e940af49706dabb36addbc6a076ecb.tar.gz
Fix #6299: rst:directive directive generates waste space
-rw-r--r--CHANGES1
-rw-r--r--sphinx/domains/rst.py5
-rw-r--r--tests/test_domain_rst.py5
3 files changed, 7 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 4246d035f..2b11b4613 100644
--- a/CHANGES
+++ b/CHANGES
@@ -79,6 +79,7 @@ Bugs fixed
is consisted by non-ASCII characters
* #6213: ifconfig: contents after headings are not shown
* commented term in glossary directive is wrongly recognized
+* #6299: rst domain: rst:directive directive generates waste space
Testing
--------
diff --git a/sphinx/domains/rst.py b/sphinx/domains/rst.py
index 716b50105..60f6cf5a8 100644
--- a/sphinx/domains/rst.py
+++ b/sphinx/domains/rst.py
@@ -80,7 +80,10 @@ def parse_directive(d):
if not m:
return (dir, '')
parsed_dir, parsed_args = m.groups()
- return (parsed_dir.strip(), ' ' + parsed_args.strip())
+ if parsed_args.strip():
+ return (parsed_dir.strip(), ' ' + parsed_args.strip())
+ else:
+ return (parsed_dir.strip(), '')
class ReSTDirective(ReSTMarkup):
diff --git a/tests/test_domain_rst.py b/tests/test_domain_rst.py
index f6ea11619..3310b5752 100644
--- a/tests/test_domain_rst.py
+++ b/tests/test_domain_rst.py
@@ -23,7 +23,7 @@ def test_parse_directive():
assert s == ('foö', '')
s = parse_directive(' .. foö :: ')
- assert s == ('foö', ' ')
+ assert s == ('foö', '')
s = parse_directive('.. foö:: args1 args2')
assert s == ('foö', ' args1 args2')
@@ -48,8 +48,7 @@ def test_rst_directive(app):
text = ".. rst:directive:: .. toctree::"
doctree = restructuredtext.parse(app, text)
assert_node(doctree, (addnodes.index,
- [desc, ([desc_signature, ([desc_name, ".. toctree::"],
- [desc_addname, " "])],
+ [desc, ([desc_signature, desc_name, ".. toctree::"],
[desc_content, ()])]))
assert_node(doctree[0],
entries=[("single", "toctree (directive)", "directive-toctree", "", None)])