Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sphinx-doc/sphinx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Lau <luke_lau@icloud.com>2020-06-02 19:56:01 +0300
committerLuke Lau <luke_lau@icloud.com>2020-06-03 18:35:00 +0300
commit1e7d9269e935d8e2e7cf6d962a3179b5f46a7263 (patch)
tree6088474768c4edd1cbcffc3f39a5b8912fecd2fd
parent3419079fb0d1f0eecd845eff0d12b367d34cd5e9 (diff)
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`.
-rw-r--r--sphinx/domains/std.py2
-rw-r--r--tests/roots/test-root/objects.txt4
-rw-r--r--tests/test_build_html.py2
3 files changed, 6 insertions, 2 deletions
diff --git a/sphinx/domains/std.py b/sphinx/domains/std.py
index 6dc597022..fbbed3a6b 100644
--- a/sphinx/domains/std.py
+++ b/sphinx/domains/std.py
@@ -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)
diff --git a/tests/roots/test-root/objects.txt b/tests/roots/test-root/objects.txt
index f713e076c..adb090a44 100644
--- a/tests/roots/test-root/objects.txt
+++ b/tests/roots/test-root/objects.txt
@@ -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
diff --git a/tests/test_build_html.py b/tests/test_build_html.py
index b3406b74c..8d616adaf 100644
--- a/tests/test_build_html.py
+++ b/tests/test_build_html.py
@@ -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",