@@ -358,16 +358,33 @@ def resize_length(text, max_length=100, initial_indent="", subsequent_indent="",
358358 Resized text.
359359 """
360360 text = text .replace (" ." , "." )
361+ while "\n \n \n " in text :
362+ text = text .replace ("\n \n \n " , "\n \n " )
363+
361364 wrapper = textwrap .TextWrapper (
362365 width = max_length ,
363366 break_long_words = False ,
364367 initial_indent = initial_indent ,
365368 subsequent_indent = subsequent_indent ,
366369 )
367- if list is False :
368- return wrapper .fill (text = text )
370+
371+ if "\n \n " in text :
372+ text = text .split ("\n \n " )
373+ else :
374+ text = [text ]
375+
376+ for i , paragraph in enumerate (text ):
377+ text [i ] = wrapper .fill (text = paragraph )
378+
379+ if len (text ) > 1 :
380+ output = "\n \n " .join (text )
369381 else :
370- return wrapper .wrap (text = text )
382+ output = text [0 ]
383+
384+ if list is True :
385+ output = output .splitlines ()
386+
387+ return output
371388
372389
373390# ############################################################################
@@ -669,7 +686,6 @@ class OrderedList(Element):
669686
670687 def to_rst (self , indent = "" , max_length = 100 , links = None , base_url = None ):
671688 """Return a string to enable converting the element to an RST format."""
672- # indent += " " * 4
673689 ordered_list = []
674690 for item in self :
675691 if item .tag in item_needing_links_base_url :
@@ -835,7 +851,7 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
835851 )
836852 items .append (str_item )
837853
838- rst_item = " " .join (items ) + "\n "
854+ rst_item = " " .join (items ) + "\n \n "
839855
840856 return rst_item
841857
@@ -876,7 +892,7 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None):
876892 content = f"{ self [0 ]} "
877893 elif self .role == "italic" :
878894 # TODO: this isn't the correct way of making text itallic
879- content = f"` { self [0 ]} ` "
895+ content = f"{ self [0 ]} "
880896 # elif self.role == 'var':
881897 # content = f"``{self[0]}`` "
882898 else :
@@ -999,11 +1015,12 @@ def to_rst(self, indent="", max_length=100):
9991015 return rst_item
10001016
10011017
1002- def resize_element_list (text , max_length = 100 ):
1018+ def resize_element_list (text , max_length = 100 , indent = "" ):
10031019 element_list = re .finditer (r"^\* " , text )
1004- subsequent_indent = " " * 2
1020+ initial_indent = indent + " "
1021+ subsequent_indent = indent + " " * 2
10051022 element_list = resize_length (
1006- text , max_length , initial_indent = "" , subsequent_indent = subsequent_indent
1023+ text , max_length , initial_indent = initial_indent , subsequent_indent = subsequent_indent
10071024 )
10081025 return element_list
10091026
@@ -1040,10 +1057,10 @@ def to_rst(self, indent="", max_length=100, links=None, base_url=None, fcache=No
10401057 if type (item ) != str and len (item .children ) > 1 and type (item [1 ]) != str :
10411058 intersection_types = set (NO_RESIZE_LIST ).intersection (set (item [1 ].children_types ))
10421059 if len (intersection_types ) == 0 :
1043- rst_item = resize_element_list (rst_item , max_length )
1060+ rst_item = resize_element_list (rst_item , max_length , indent = indent )
10441061
10451062 else :
1046- rst_item = resize_element_list (rst_item , max_length )
1063+ rst_item = resize_element_list (rst_item , max_length , indent = indent )
10471064 active_items .append (rst_item )
10481065
10491066 return "\n " .join (active_items ) + "\n "
@@ -1740,11 +1757,9 @@ def terms(self, terms):
17401757 def raw_args (self ):
17411758 """Raws containing the command arguments."""
17421759 cmd = str (self )
1743- cmd = cmd .replace ("&fname_arg;" , self ._terms ["fname_arg" ])
1744- cmd = cmd .replace ("&fname1_arg;" , self ._terms ["fname1_arg" ])
1745- cmd = cmd .replace ("&fname2_arg;" , self ._terms ["fname2_arg" ])
1746- cmd = cmd .replace ("&pn006p;" , self ._terms ["pn006p" ])
1747- cmd = cmd .replace ("&ansysBrand;" , self ._terms ["ansysBrand" ])
1760+ for term in self ._terms .keys ():
1761+ if type (self ._terms [term ]) == str :
1762+ cmd = cmd .replace (f"&{ term } ;" , self ._terms [term ])
17481763 cmd = cmd .replace ("``" , "" )
17491764 split_args = cmd .split ("," )[1 :]
17501765 return split_args
@@ -2419,32 +2434,26 @@ def resized_description(
24192434 if description is None :
24202435 description = self ._description
24212436
2422- if "* " in description :
2423- output = description .split ("\n " )
2424- else :
2425- output = resize_length (
2426- description , max_length , initial_indent = indent , subsequent_indent = indent , list = True
2427- )
2437+ output = resize_length (
2438+ description , max_length , initial_indent = indent , subsequent_indent = indent , list = True
2439+ )
24282440
24292441 return output
24302442
2431- def to_py_docstring (
2432- self , max_length = 100 , indent = "" , links = None , base_url = None , fcache = None
2433- ) -> List [str ]:
2443+ def to_py_docstring (self , max_length = 100 , links = None , base_url = None , fcache = None ) -> List [str ]:
24342444 """Return a list of string to enable converting the element to an RST format."""
24352445 if self .py_arg_name != "" :
2436- docstring = [f'{ indent } { self .py_arg_name } : { str_types (self .types , " or " )} ' ]
2446+ docstring = [f'{ self .py_arg_name } : { str_types (self .types , " or " )} ' ]
24372447 if isinstance (self ._description , str ):
24382448 rst_description = self ._description
24392449 else :
24402450 rst_description = self ._description .to_rst (
2441- indent = indent ,
24422451 max_length = max_length ,
24432452 links = links ,
24442453 base_url = base_url ,
24452454 fcache = fcache ,
24462455 )
2447- description_indent = " " * 4 + indent
2456+ description_indent = " " * 4
24482457 if not "* " in rst_description :
24492458 list_description = self .resized_description (
24502459 rst_description , max_length , description_indent
@@ -2453,11 +2462,12 @@ def to_py_docstring(
24532462 rst_description = textwrap .indent (rst_description , description_indent )
24542463 list_description = rst_description .split ("\n " )
24552464
2456- docstring = [f'{ indent } { self .py_arg_name } : { str_types (self .types , " or " )} ' ]
2465+ docstring = [f'{ self .py_arg_name } : { str_types (self .types , " or " )} ' ]
24572466 docstring .extend (list_description )
24582467
24592468 else :
24602469 docstring = []
2470+
24612471 return docstring
24622472
24632473
@@ -2787,7 +2797,8 @@ def py_docstring(self, custom_functions: CustomFunctions) -> str:
27872797 ):
27882798 items += ["" ] + custom_functions .py_returns [self .py_name ]
27892799 if self .notes is not None :
2790- items += ["" ] + self .py_notes (custom_functions )
2800+ items += ["" ]
2801+ items .extend (self .py_notes (custom_functions ))
27912802 if custom_functions is not None and (
27922803 self .py_name in custom_functions .py_names
27932804 and self .py_name in custom_functions .py_examples
@@ -3024,7 +3035,7 @@ def py_notes(self, custom_functions: CustomFunctions = None):
30243035 else :
30253036 notes = self .notes .to_rst ()
30263037
3027- if "flat-table" not in "" . join ( notes ) and ".. code::" not in "" . join ( notes ) :
3038+ if "flat-table" not in notes and ".. code::" not in notes :
30283039 notes = resize_length (notes , self ._max_length , list = True )
30293040 lines .extend (notes )
30303041 else :
@@ -3079,7 +3090,7 @@ def __repr__(self):
30793090
30803091 return "\n " .join (lines )
30813092
3082- def py_parm (self , custom_functions = None , indent = "" , links = None , base_url = None , fcache = None ):
3093+ def py_parm (self , custom_functions = None , links = None , base_url = None , fcache = None ):
30833094 """Python parameter's string."""
30843095 lines = []
30853096 arg_desc = self .arg_desc
@@ -3096,9 +3107,7 @@ def py_parm(self, custom_functions=None, indent="", links=None, base_url=None, f
30963107 lines .append ("-" * 10 )
30973108 for argument in arg_desc :
30983109 lines .extend (
3099- argument .to_py_docstring (
3100- self ._max_length , indent , links , base_url , fcache
3101- )
3110+ argument .to_py_docstring (self ._max_length , links , base_url , fcache )
31023111 )
31033112 lines .append ("" )
31043113 else :
@@ -3107,9 +3116,7 @@ def py_parm(self, custom_functions=None, indent="", links=None, base_url=None, f
31073116 elif len (arg_desc ) > 0 :
31083117 lines .append ("-" * 10 )
31093118 for argument in arg_desc :
3110- lines .extend (
3111- argument .to_py_docstring (self ._max_length , indent , links , base_url , fcache )
3112- )
3119+ lines .extend (argument .to_py_docstring (self ._max_length , links , base_url , fcache ))
31133120 lines .append ("" )
31143121 return lines
31153122
0 commit comments