File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff 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 " )
You can’t perform that action at this time.
0 commit comments