Let option directive support args in the form of foo[=bar]

This slightly tweaks the regex so that command line flags of the form
foo[=N] are properly split up. This is useful for any programs that can
take `--foo` as a flag on its own as well as with an extra argument
`--foo=12`.
This commit is contained in:
Luke Lau 2020-06-02 17:56:01 +01:00
parent 3419079fb0
commit 1e7d9269e9
3 changed files with 6 additions and 2 deletions

View File

@ -43,7 +43,7 @@ logger = logging.getLogger(__name__)
# RE for option descriptions
option_desc_re = re.compile(r'((?:/|--|-|\+)?[^\s=]+)(=?\s*.*)')
option_desc_re = re.compile(r'((?:/|--|-|\+)?[^\s=[]+)(=?\s*.*)')
# RE for grammar tokens
token_re = re.compile(r'`(\w+)`', re.U)

View File

@ -180,7 +180,9 @@ Others
.. option:: arg
Link to :option:`perl +p`, :option:`--ObjC++`, :option:`--plugin.option`, :option:`create-auth-token` and :option:`arg`
.. option:: -j[=N]
Link to :option:`perl +p`, :option:`--ObjC++`, :option:`--plugin.option`, :option:`create-auth-token`, :option:`arg` and :option:`-j`
.. program:: hg

View File

@ -331,6 +331,8 @@ def test_html4_output(app, status, warning):
'create-auth-token'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-arg-arg']/code/span",
'arg'),
(".//a[@class='reference internal'][@href='#cmdoption-perl-j']/code/span",
'-j'),
(".//a[@class='reference internal'][@href='#cmdoption-hg-arg-commit']/code/span",
'hg'),
(".//a[@class='reference internal'][@href='#cmdoption-hg-arg-commit']/code/span",