@@ -586,6 +586,43 @@ def get_var_stack(line: str) -> list[str]:
586
586
return None
587
587
588
588
589
+ def get_placeholders (arg_list : list [str ]) -> tuple [str , str ]:
590
+ """
591
+ Function used to generate placeholders for snippets
592
+
593
+ Parameters
594
+ ----------
595
+ arg_list : list[str]
596
+ Method arguments list
597
+
598
+ Returns
599
+ -------
600
+ Tuple[str, str]
601
+ Tuple of arguments as a string and snippet string
602
+
603
+ Examples
604
+ --------
605
+ >>> get_placeholders(['x', 'y'])
606
+ ('(x, y)', '(${1:x}, ${2:y})')
607
+
608
+ >>> get_placeholders(['x=1', 'y=2'])
609
+ ('(x=1, y=2)', '(x=${1:1}, y=${2:2})')
610
+
611
+ >>> get_placeholders(['x', 'y=2', 'z'])
612
+ ('(x, y=2, z)', '(${1:x}, y=${2:2}, ${3:z})')
613
+ """
614
+ place_holders = []
615
+ for i , arg in enumerate (arg_list ):
616
+ opt_split = arg .split ("=" )
617
+ if len (opt_split ) > 1 :
618
+ place_holders .append (f"{ opt_split [0 ]} =${{{ i + 1 } :{ opt_split [1 ]} }}" )
619
+ else :
620
+ place_holders .append (f"${{{ i + 1 } :{ arg } }}" )
621
+ arg_str = f"({ ', ' .join (arg_list )} )"
622
+ arg_snip = f"({ ', ' .join (place_holders )} )"
623
+ return arg_str , arg_snip
624
+
625
+
589
626
def fortran_md (code : str , docs : str | None ):
590
627
"""Convert Fortran code to markdown
591
628
0 commit comments