Skip to content

Commit 2599bfb

Browse files
authored
Differentiate between upper and lower cases in ids (#32)
1 parent 2637f83 commit 2599bfb

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

roots/test-lower-upper-refs/conf.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
from pathlib import Path
5+
6+
sys.path.insert(0, str(Path(__file__).parent))
7+
extensions = ["sphinx_argparse_cli"]
8+
nitpicky = True

roots/test-lower-upper-refs/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.. sphinx_argparse_cli::
2+
:module: parser
3+
:func: make

roots/test-lower-upper-refs/parser.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import annotations
2+
3+
from argparse import ArgumentParser
4+
5+
6+
def make() -> ArgumentParser:
7+
parser = ArgumentParser(prog="basic")
8+
parser.add_argument("-d")
9+
parser.add_argument("-D")
10+
return parser

src/sphinx_argparse_cli/_logic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747

4848

4949
def make_id(key: str) -> str:
50-
return "-".join(key.split()).rstrip("-").lower()
50+
return "-".join(key.split()).rstrip("-")
5151

5252

5353
logger = getLogger(__name__)

tests/test_logic.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def test_group_title_prefix_prog_replacement(build_outcome: str) -> None:
157157
@pytest.mark.sphinx(buildername="html", testroot="group-title-prefix-custom-subcommands")
158158
def test_group_title_prefix_custom_sub_commands(build_outcome: str, opt_grp_name: tuple[str, str]) -> None:
159159
grp, anchor = opt_grp_name
160-
assert '<h2>complex Exclusive<a class="headerlink" href="#complex-exclusive"' in build_outcome
160+
assert '<h2>complex Exclusive<a class="headerlink" href="#complex-Exclusive"' in build_outcome
161161
assert '<h2>complex custom (f)<a class="headerlink" href="#complex-first-(f)"' in build_outcome
162162
msg = '<h3>complex custom positional arguments<a class="headerlink" href="#complex-first-positional-arguments"'
163163
assert msg in build_outcome
@@ -173,7 +173,7 @@ def test_group_title_prefix_custom_sub_commands(build_outcome: str, opt_grp_name
173173
@pytest.mark.sphinx(buildername="html", testroot="group-title-prefix-empty-subcommands")
174174
def test_group_title_prefix_empty_sub_commands(build_outcome: str, opt_grp_name: tuple[str, str]) -> None:
175175
grp, anchor = opt_grp_name
176-
assert '<h2>complex Exclusive<a class="headerlink" href="#complex-exclusive"' in build_outcome
176+
assert '<h2>complex Exclusive<a class="headerlink" href="#complex-Exclusive"' in build_outcome
177177
assert '<h2>complex (f)<a class="headerlink" href="#complex-first-(f)"' in build_outcome
178178
msg = '<h3>complex positional arguments<a class="headerlink" href="#complex-first-positional-arguments"'
179179
assert msg in build_outcome
@@ -187,7 +187,7 @@ def test_group_title_prefix_empty_sub_commands(build_outcome: str, opt_grp_name:
187187
@pytest.mark.sphinx(buildername="html", testroot="group-title-empty-prefixes")
188188
def test_group_title_empty_prefixes(build_outcome: str, opt_grp_name: tuple[str, str]) -> None:
189189
grp, anchor = opt_grp_name
190-
assert '<h2>Exclusive<a class="headerlink" href="#complex-exclusive"' in build_outcome
190+
assert '<h2>Exclusive<a class="headerlink" href="#complex-Exclusive"' in build_outcome
191191
assert '<h2>(f)<a class="headerlink" href="#complex-first-(f)"' in build_outcome
192192
assert '<h3>positional arguments<a class="headerlink" href="#complex-first-positional-arguments"' in build_outcome
193193
assert f'<h3>{grp}<a class="headerlink" href="#complex-first-{anchor}"' in build_outcome
@@ -198,7 +198,7 @@ def test_group_title_empty_prefixes(build_outcome: str, opt_grp_name: tuple[str,
198198
def test_group_title_prefix_sub_command_replacement(build_outcome: str, opt_grp_name: tuple[str, str]) -> None:
199199
grp, anchor = opt_grp_name
200200
assert f'<h2>bar {grp}<a class="headerlink" href="#bar-{anchor}"' in build_outcome
201-
assert '<h2>bar Exclusive<a class="headerlink" href="#bar-exclusive"' in build_outcome
201+
assert '<h2>bar Exclusive<a class="headerlink" href="#bar-Exclusive"' in build_outcome
202202
assert '<h2>bar baronlyroot (f)<a class="headerlink" href="#bar-root-first-(f)"' in build_outcome
203203
assert '<h3>bar baronlyroot first positional arguments<a class="headerlink"' in build_outcome
204204

@@ -207,3 +207,9 @@ def test_group_title_prefix_sub_command_replacement(build_outcome: str, opt_grp_
207207
def test_store_true_false(build_outcome: str) -> None:
208208
assert "False" not in build_outcome
209209
assert "True" not in build_outcome
210+
211+
212+
@pytest.mark.sphinx(buildername="html", testroot="lower-upper-refs")
213+
def test_lower_upper_refs(build_outcome: str) -> None:
214+
assert '<p id="basic--d"><a class="reference internal" href="#basic--d" title="basic -d">' in build_outcome
215+
assert '<p id="basic--D"><a class="reference internal" href="#basic--D" title="basic -D">' in build_outcome

0 commit comments

Comments
 (0)