diff --git a/docopt/__init__.py b/docopt/__init__.py index c735337..60310d9 100644 --- a/docopt/__init__.py +++ b/docopt/__init__.py @@ -711,9 +711,7 @@ def parse_defaults(docstring: str) -> list[Option]: defaults = [] for s in parse_section("options:", docstring): options_literal, _, s = s.partition(":") - if " " in options_literal: - _, _, options_literal = options_literal.partition(" ") - assert options_literal.lower().strip() == "options" + assert options_literal.lower().endswith("options") split = re.split(r"\n[ \t]*(-\S+?)", "\n" + s)[1:] split = [s1 + s2 for s1, s2 in zip(split[::2], split[1::2])] for s in split: diff --git a/tests/test_docopt.py b/tests/test_docopt.py index 0df70de..9056fba 100644 --- a/tests/test_docopt.py +++ b/tests/test_docopt.py @@ -643,6 +643,7 @@ def test_language_errors(): [ pytest.param("Usage: prog\n Options: --foo\n"), pytest.param("Usage: prog\n Advanced Options: --foo\n"), + pytest.param("Usage: prog\n Very Advanced Options: --foo\n"), ], ) def test_docopt_reports_options_in_usage_section(doc: str):