Skip to content

Commit cbebba0

Browse files
committed
cuda_bindings: fix Interactions __doc__ workaround and CUDART_DRIVER parity
Replace malformed \n:py:obj: (non-raw string so \n matches a real newline) with quoted "Interactions " before generic Sphinx stripping. Strip CUDART_DRIVER from normalized dict text for compare-only parity with cleaned __doc__ (manpage token vs title-only). Add a clean_enum_member_docstring example for the broken cross-ref. Made-with: Cursor
1 parent 1ce9bc8 commit cbebba0

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

cuda_bindings/tests/test_enum_explanations.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ def _explanation_dict_text_for_cleaned_doc_compare(value) -> str:
6060
s = _strip_doxygen_double_colon_prefixes(s)
6161
s = re.sub(r"\s+", " ", s).strip()
6262
s = _fix_hyphenation_wordwrap_spacing(s)
63+
# Manpage token only in dict text; cleaned __doc__ cites the section title alone.
64+
s = s.replace("CUDART_DRIVER ", "")
6365
return s
6466

6567

@@ -101,6 +103,9 @@ def clean_enum_member_docstring(doc: str | None) -> str | None:
101103
if doc is None:
102104
return None
103105
s = doc
106+
# Work around codegen bug (cudaErrorIncompatibleDriverContext):
107+
# malformed :py:obj before `with`. Please remove after fix.
108+
s = s.replace("\n:py:obj:`~.Interactions`", ' "Interactions ')
104109
# Sphinx roles with a single backtick-delimited target (most common on these enums).
105110
# Strip the role and keep the inner text; drop leading ~. used for same-module refs.
106111
s = re.sub(
@@ -136,6 +141,11 @@ def clean_enum_member_docstring(doc: str | None) -> str | None:
136141
pytest.param("[Deprecated]\n", "[Deprecated]", id="deprecated_line"),
137142
pytest.param("non- linear", "non-linear", id="hyphen_space_after"),
138143
pytest.param("word -word", "word-word", id="hyphen_space_before"),
144+
pytest.param(
145+
'Please see\n:py:obj:`~.Interactions`with the CUDA Driver API" for more information.',
146+
'Please see "Interactions with the CUDA Driver API" for more information.',
147+
id="codegen_broken_interactions_role",
148+
),
139149
],
140150
)
141151
def test_clean_enum_member_docstring_examples(raw, expected):

0 commit comments

Comments
 (0)