Fix #6299: rst:directive directive generates waste space

This commit is contained in:
Takeshi KOMIYA 2019-04-12 21:06:15 +09:00
parent 11a4e47d62
commit 1900c729a3
3 changed files with 7 additions and 4 deletions

View File

@ -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
--------

View File

@ -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):

View File

@ -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)])