@@ -37,7 +37,7 @@ def _add_usage_section(md_file: MdUtils, parser: _argparse.ArgumentParser) -> No
3737 usage_string = parser .format_usage () if parser .format_usage () is not None else ""
3838 md_file .insert_code (usage_string , language = "bash" )
3939
40- def _format_action_for_table_row (action : _argparse .Action ) -> List [str ]:
40+ def _format_action_for_table_row (action : _argparse .Action , parser : _argparse . ArgumentParser ) -> List [str ]:
4141 """
4242 Formats a single argparse.Action into a list of 4 strings for the arguments table.
4343 Handles both optional and positional arguments based on action.option_strings.
@@ -72,8 +72,11 @@ def _format_action_for_table_row(action: _argparse.Action) -> List[str]:
7272 # Help text string formatting
7373 if action .help is None :
7474 help_text_str = inline_code ("None" )
75+ elif action .help == _argparse .SUPPRESS :
76+ help_text_str = ""
7577 else :
76- help_text_str = str (action .help ).replace ("\n " , " " )
78+ formatter = parser ._get_formatter ()
79+ help_text_str = formatter ._expand_help (action ).replace ("\n " , " " )
7780
7881 return [short_opt_str , long_opt_str , default_cell_str , help_text_str ]
7982
@@ -93,7 +96,7 @@ def _build_arguments_table_data(parser: _argparse.ArgumentParser) -> List[str]:
9396
9497 # This pass is primarily for optionals.
9598 # _format_action_for_table_row handles based on action.option_strings
96- table_rows_data .append (_format_action_for_table_row (action ))
99+ table_rows_data .append (_format_action_for_table_row (action , parser ))
97100 seen_action_ids .add (id (action ))
98101
99102 # Second Pass (Positionals): Iterate through parser._actions
@@ -105,7 +108,7 @@ def _build_arguments_table_data(parser: _argparse.ArgumentParser) -> List[str]:
105108
106109 # If it has no option_strings, it's a positional argument
107110 if not action .option_strings :
108- table_rows_data .append (_format_action_for_table_row (action ))
111+ table_rows_data .append (_format_action_for_table_row (action , parser ))
109112 # No need to add to seen_action_ids here as this is the final pass for this action
110113
111114 # Flatten the table_rows_data with the header
0 commit comments