mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9138 from tk0miya/9137_program_None
Add doc and testcase for program directive (refs: #9137)
This commit is contained in:
commit
1e1de0713a
@ -1680,6 +1680,9 @@ There is a set of directives allowing documenting command-line programs:
|
|||||||
then ``:option:`rm -r``` would refer to the first option, while
|
then ``:option:`rm -r``` would refer to the first option, while
|
||||||
``:option:`svn -r``` would refer to the second one.
|
``:option:`svn -r``` would refer to the second one.
|
||||||
|
|
||||||
|
If ``None`` is passed to the argument, the directive will reset the
|
||||||
|
current program name.
|
||||||
|
|
||||||
The program name may contain spaces (in case you want to document
|
The program name may contain spaces (in case you want to document
|
||||||
subcommands like ``svn add`` and ``svn commit`` separately).
|
subcommands like ``svn add`` and ``svn commit`` separately).
|
||||||
|
|
||||||
|
@ -324,6 +324,23 @@ def test_cmdoption(app):
|
|||||||
assert domain.progoptions[('ls', '-l')] == ('index', 'cmdoption-ls-l')
|
assert domain.progoptions[('ls', '-l')] == ('index', 'cmdoption-ls-l')
|
||||||
|
|
||||||
|
|
||||||
|
def test_cmdoption_for_None(app):
|
||||||
|
text = (".. program:: ls\n"
|
||||||
|
".. program:: None\n"
|
||||||
|
"\n"
|
||||||
|
".. option:: -l\n")
|
||||||
|
domain = app.env.get_domain('std')
|
||||||
|
doctree = restructuredtext.parse(app, text)
|
||||||
|
assert_node(doctree, (addnodes.index,
|
||||||
|
[desc, ([desc_signature, ([desc_name, "-l"],
|
||||||
|
[desc_addname, ()])],
|
||||||
|
[desc_content, ()])]))
|
||||||
|
assert_node(doctree[0], addnodes.index,
|
||||||
|
entries=[('pair', 'command line option; -l', 'cmdoption-l', '', None)])
|
||||||
|
assert (None, '-l') in domain.progoptions
|
||||||
|
assert domain.progoptions[(None, '-l')] == ('index', 'cmdoption-l')
|
||||||
|
|
||||||
|
|
||||||
def test_multiple_cmdoptions(app):
|
def test_multiple_cmdoptions(app):
|
||||||
text = (".. program:: cmd\n"
|
text = (".. program:: cmd\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
Loading…
Reference in New Issue
Block a user