Skip to content

Commit 4fde3d6

Browse files
committed
cuda_core: drop unused enum doc cleanup helper
Remove the old Doxygen ``::`` normalization path now that error explanations no longer depend on dict-vs-docstring parity checks. This keeps the helper focused on the cleanup rules that still affect user-facing CUDAError messages. Made-with: Cursor
1 parent 8b0c526 commit 4fde3d6

File tree

2 files changed

+9
-36
lines changed

2 files changed

+9
-36
lines changed

cuda_core/cuda/core/_utils/enum_explanations_helpers.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
the 12.x backport line at ``cuda-bindings`` 12.9.6, and in the mainline 13.x
99
series at ``cuda-bindings`` 13.2.0. This module decides which source to use
1010
and normalizes generated docstrings so user-facing ``CUDAError`` messages stay
11-
close to the long-form explanation prose.
11+
presentable.
1212
13-
The cleanup rules here were derived while validating docstring-vs-dict parity
14-
in PR #1805. Keep them narrow and remove them when codegen / fallback support is
15-
no longer needed.
13+
The cleanup rules here were derived while validating generated enum docstrings
14+
in PR #1805. Keep them narrow and remove them when codegen quirks or fallback
15+
support are no longer needed.
1616
"""
1717

1818
from __future__ import annotations
@@ -43,25 +43,11 @@ def _binding_version_has_usable_enum_docstrings(version: tuple[int, int, int]) -
4343
)
4444

4545

46-
def _strip_doxygen_double_colon_prefixes(s: str) -> str:
47-
"""Remove Doxygen-style ``::`` before CUDA identifiers (not C++ ``Foo::Bar`` scope).
48-
49-
The frozen fallback tables come from CUDA header comments and therefore use
50-
Doxygen ``::name`` references. Generated enum ``__doc__`` text uses Sphinx
51-
roles instead, so parity checks need a small amount of normalization.
52-
"""
53-
prev = None
54-
while prev != s:
55-
prev = s
56-
s = re.sub(r"(?<![A-Za-z0-9_])::+([A-Za-z_][A-Za-z0-9_]*)", r"\1", s)
57-
return s
58-
59-
6046
def _fix_hyphenation_wordwrap_spacing(s: str) -> str:
6147
"""Remove spaces around hyphens introduced by line wrapping in generated ``__doc__`` text.
6248
6349
This is a narrow workaround for wrapped forms such as ``non- linear`` that
64-
otherwise differ from the single-line fallback prose.
50+
would otherwise look awkward in user-facing messages.
6551
"""
6652
prev = None
6753
while prev != s:
@@ -74,10 +60,10 @@ def _fix_hyphenation_wordwrap_spacing(s: str) -> str:
7460
def clean_enum_member_docstring(doc: str | None) -> str | None:
7561
"""Turn an enum member ``__doc__`` into plain text.
7662
77-
The generated enum docstrings are already close to the fallback explanation
78-
prose, but not byte-identical: they may contain Sphinx inline roles, line
79-
wrapping, or a small known codegen defect. Normalize only those differences
80-
so the text is suitable for user-facing error messages.
63+
The generated enum docstrings are already close to user-facing prose, but
64+
they may contain Sphinx inline roles, line wrapping, or a small known
65+
codegen defect. Normalize only those differences so the text is suitable
66+
for error messages.
8167
"""
8268
if doc is None:
8369
return None

cuda_core/tests/test_utils_enum_explanations_helpers.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from cuda.core._utils.enum_explanations_helpers import (
88
DocstringBackedExplanations,
99
_binding_version_has_usable_enum_docstrings,
10-
_strip_doxygen_double_colon_prefixes,
1110
clean_enum_member_docstring,
1211
)
1312

@@ -63,18 +62,6 @@ def test_clean_enum_member_docstring_none_input():
6362
assert clean_enum_member_docstring(None) is None
6463

6564

66-
@pytest.mark.parametrize(
67-
("raw", "expected"),
68-
[
69-
pytest.param("see ::CUDA_SUCCESS", "see CUDA_SUCCESS", id="type_ref"),
70-
pytest.param("Foo::Bar unchanged", "Foo::Bar unchanged", id="cpp_scope_preserved"),
71-
pytest.param("::cuInit() and ::CUstream", "cuInit() and CUstream", id="multiple_prefixes"),
72-
],
73-
)
74-
def test_strip_doxygen_double_colon_prefixes(raw, expected):
75-
assert _strip_doxygen_double_colon_prefixes(raw) == expected
76-
77-
7865
def test_docstring_backed_get_returns_default_for_non_enum_code():
7966
lut = DocstringBackedExplanations(_FakeEnumType({}))
8067
assert lut.get(-1) is None

0 commit comments

Comments
 (0)