Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit 2227190

Browse files
committed
wip
1 parent 47368b1 commit 2227190

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

gapic/utils/rst.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from gapic.utils.lines import wrap
2323

24-
@functools.lru_cache(maxsize=2048)
24+
@functools.lru_cache(maxsize=None)
2525
def _convert_pandoc(text: str, columns: int, source_format: str) -> str:
2626
"""Cached helper to run pypandoc with specific column width.
2727
@@ -31,6 +31,7 @@ def _convert_pandoc(text: str, columns: int, source_format: str) -> str:
3131
return pypandoc.convert_text(text, 'rst',
3232
format=source_format,
3333
extra_args=['--columns=%d' % columns],
34+
verify_format=False,
3435
).strip()
3536

3637

@@ -62,7 +63,7 @@ def rst(
6263
# do not convert it.
6364
# (This makes code generation significantly faster; calling out to pandoc
6465
# is by far the most expensive thing we do.)
65-
if not re.search(r"[|*`_[\]]", text):
66+
if not re.search(r"(?<!\w)_|_(?!\w)|[|*`\[\]]", text):
6667
answer = wrap(
6768
text,
6869
indent=indent,

tests/unit/utils/test_rst.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ def test_rst_formatted():
3232
assert convert_text.call_count == 1
3333
assert convert_text.mock_calls[0][1][1] == "rst"
3434
assert convert_text.mock_calls[0][2]["format"] == "commonmark"
35+
assert convert_text.mock_calls[0][2]["verify_format"] is False
36+
37+
38+
def test_rst_snake_case():
39+
with mock.patch.object(pypandoc, "convert_text") as convert_text:
40+
s = "some_variable_name"
41+
assert utils.rst(s) == s
42+
assert convert_text.call_count == 0
3543

3644

3745
def test_rst_add_newline():

0 commit comments

Comments
 (0)