diff options
Diffstat (limited to 'tests/test_domain_rst.py')
| -rw-r--r-- | tests/test_domain_rst.py | 63 |
1 files changed, 61 insertions, 2 deletions
diff --git a/tests/test_domain_rst.py b/tests/test_domain_rst.py index 3310b5752..207ff1ff3 100644 --- a/tests/test_domain_rst.py +++ b/tests/test_domain_rst.py @@ -10,8 +10,7 @@ from sphinx import addnodes from sphinx.addnodes import ( - desc, desc_addname, desc_content, desc_name, desc_optional, desc_parameter, - desc_parameterlist, desc_returns, desc_signature + desc, desc_addname, desc_annotation, desc_content, desc_name, desc_signature ) from sphinx.domains.rst import parse_directive from sphinx.testing import restructuredtext @@ -69,6 +68,66 @@ def test_rst_directive_with_argument(app): domain="rst", objtype="directive", noindex=False) +def test_rst_directive_option(app): + text = ".. rst:directive:option:: foo" + doctree = restructuredtext.parse(app, text) + assert_node(doctree, (addnodes.index, + [desc, ([desc_signature, desc_name, ":foo:"], + [desc_content, ()])])) + assert_node(doctree[0], + entries=[("single", ":foo: (directive option)", + "directive:option--foo", "", "F")]) + assert_node(doctree[1], addnodes.desc, desctype="directive:option", + domain="rst", objtype="directive:option", noindex=False) + + +def test_rst_directive_option_with_argument(app): + text = ".. rst:directive:option:: foo: bar baz" + doctree = restructuredtext.parse(app, text) + assert_node(doctree, (addnodes.index, + [desc, ([desc_signature, ([desc_name, ":foo:"], + [desc_annotation, " bar baz"])], + [desc_content, ()])])) + assert_node(doctree[0], + entries=[("single", ":foo: (directive option)", + "directive:option--foo", "", "F")]) + assert_node(doctree[1], addnodes.desc, desctype="directive:option", + domain="rst", objtype="directive:option", noindex=False) + + +def test_rst_directive_option_type(app): + text = (".. rst:directive:option:: foo\n" + " :type: directives.flags\n") + doctree = restructuredtext.parse(app, text) + assert_node(doctree, (addnodes.index, + [desc, ([desc_signature, ([desc_name, ":foo:"], + [desc_annotation, " (directives.flags)"])], + [desc_content, ()])])) + assert_node(doctree[0], + entries=[("single", ":foo: (directive option)", + "directive:option--foo", "", "F")]) + assert_node(doctree[1], addnodes.desc, desctype="directive:option", + domain="rst", objtype="directive:option", noindex=False) + + +def test_rst_directive_and_directive_option(app): + text = (".. rst:directive:: foo\n" + "\n" + " .. rst:directive:option:: bar\n") + doctree = restructuredtext.parse(app, text) + assert_node(doctree, (addnodes.index, + [desc, ([desc_signature, desc_name, ".. foo::"], + [desc_content, (addnodes.index, + desc)])])) + assert_node(doctree[1][1][0], + entries=[("pair", "foo (directive); :bar: (directive option)", + "directive:option-foo-bar", "", "B")]) + assert_node(doctree[1][1][1], ([desc_signature, desc_name, ":bar:"], + [desc_content, ()])) + assert_node(doctree[1][1][1], addnodes.desc, desctype="directive:option", + domain="rst", objtype="directive:option", noindex=False) + + def test_rst_role(app): text = ".. rst:role:: ref" doctree = restructuredtext.parse(app, text) |
