Skip to content

Commit f8ab8a8

Browse files
committed
improve summary splits to prevent a doc warning
1 parent 90a1adc commit f8ab8a8

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

api-docs/source/conf.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,19 @@ def generaterst():
174174
if first_line and not first_line.startswith(classname + "("):
175175
summary = first_line
176176
if len(summary) > 100:
177-
summary = summary[:97] + "..."
177+
# Find a good break point to avoid cutting off Sphinx directives
178+
truncate_at = 97
179+
# Look for space before truncation to avoid breaking words
180+
if ' ' in summary[80:97]:
181+
space_pos = summary.rfind(' ', 80, 97)
182+
if space_pos > 80:
183+
truncate_at = space_pos
184+
# Check if we're in the middle of a Sphinx directive
185+
if ':py:' in summary[truncate_at-10:truncate_at+10]:
186+
directive_start = summary.rfind(':py:', 0, truncate_at)
187+
if directive_start != -1:
188+
truncate_at = directive_start
189+
summary = summary[:truncate_at] + "..."
178190

179191
modulefile.write(f" * - :{role}:`{inspect.getmodule(classref).__name__}.{classname}`\n")
180192
modulefile.write(f" - {summary}\n")

0 commit comments

Comments
 (0)