@@ -360,6 +360,11 @@ def resize_length(text, max_length=100, initial_indent="", subsequent_indent="",
360360 while "\n \n \n " in text :
361361 text = text .replace ("\n \n \n " , "\n \n " )
362362
363+ # Remove extra whitespace before period
364+ text = ponctuaction_whitespace (text , "." )
365+ # Remove extra whitespace before comma
366+ text = ponctuaction_whitespace (text , "," )
367+
363368 wrapper = textwrap .TextWrapper (
364369 width = max_length ,
365370 break_long_words = False ,
@@ -723,12 +728,12 @@ class Member(Element):
723728
724729
725730def ponctuaction_whitespace (text , ponctuation ):
726- pattern = r". \S\h+\{ponctuation}" .format (ponctuation = ponctuation )
731+ pattern = r"\S\h+\{ponctuation}" .format (ponctuation = ponctuation )
727732 extra_space = re .findall (pattern , text )
728733 if extra_space :
729734 for character in list (set (extra_space )): # remove duplicates in extra_space list
730735 assigned_character = character [0 ]
731- if assigned_character in ["*" , ")" ]:
736+ if assigned_character in ["*" , ")" , "?" ]:
732737 pattern = r"\{assigned_character}\h+\{ponctuation}" .format (
733738 assigned_character = assigned_character , ponctuation = ponctuation
734739 )
@@ -860,6 +865,7 @@ def __repr__(self):
860865 def to_rst (self , indent = "" , max_length = 100 , links = None , base_url = None , fcache = None ):
861866 """Return a string to enable converting the element to an RST format."""
862867 items = []
868+ skip_resize = False
863869 for item in self :
864870 if isinstance (item , Element ):
865871 if isinstance (item , Variablelist ):
@@ -873,6 +879,7 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
873879 fcache = fcache ,
874880 )
875881 )
882+ skip_resize = True
876883 else :
877884 if item .tag in item_needing_all :
878885 items .append (
@@ -897,16 +904,18 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
897904 else :
898905 items .append (item .to_rst (indent = indent , max_length = max_length ))
899906 else :
900- str_item = resize_length (
901- str (item ),
902- max_length = max_length ,
903- initial_indent = indent ,
904- subsequent_indent = indent ,
905- )
906- items .append (str_item )
907+ items .append (str (item ))
907908
908909 rst_item = " " .join (items ) + "\n \n "
909910
911+ if not skip_resize :
912+ rst_item = resize_length (
913+ rst_item ,
914+ max_length = max_length ,
915+ initial_indent = indent ,
916+ subsequent_indent = indent ,
917+ )
918+
910919 return rst_item
911920
912921
@@ -2562,10 +2571,6 @@ def to_py_docstring(self, max_length=100, links=None, base_url=None, fcache=None
25622571 fcache = fcache ,
25632572 )
25642573 rst_description = replace_terms (rst_description , self ._terms )
2565- # Remove extra whitespace before period
2566- rst_description = ponctuaction_whitespace (rst_description , "." )
2567- # Remove extra whitespace before comma
2568- rst_description = ponctuaction_whitespace (rst_description , "," )
25692574
25702575 description_indent = " " * 4
25712576 if not " * " in rst_description :
@@ -3116,7 +3121,7 @@ def trail_replacer(match):
31163121 docstr = re .sub (r"bgcolor=\S\S\S\S\S\S\S\S\S\S? " , "" , docstr )
31173122 docstr = re .sub (r"bgcolor=\S\S\S\S\S\S\S\S\S\S?" , "" , docstr )
31183123 docstr = re .sub (r"_cellfont Shading=\S\S\S\S\S\S\S\S" , "" , docstr )
3119- docstr = re .sub (r"Caret.+ \?" , "" , docstr )
3124+ docstr = re .sub (r"Caret.* \?" , "" , docstr )
31203125 docstr = docstr .replace ("–" , "-" )
31213126 docstr = docstr .replace (". . ." , "..." )
31223127 docstr = replace_asterisks (docstr )
0 commit comments