@@ -35,6 +35,8 @@ def dict_to_restructured_text(yaml_data):
3535 rst_output .append (' ' + key3 )
3636 rst_output .append (' ' + value3 )
3737 rst_output .append ('' )
38+ rst_output .append ('returns' )
39+ rst_output .append (' ' + value2 ['returns' ] + '\n ' )
3840 # rst_output.append(f"\n\n{value2['parameters']}\n\n")
3941 return '\n ' .join (rst_output )
4042
@@ -49,12 +51,11 @@ def parse_string_to_dict(input_string):
4951 line = line [4 :]
5052 if line .startswith (" " ):
5153 if current_key is not None :
52- result_dict [current_key ] += line
54+ result_dict [current_key ] += line + ' \n '
5355 else :
5456 current_key = line
5557 if current_key not in result_dict :
5658 result_dict [current_key ] = ''
57-
5859 for k in result_dict :
5960 result_dict [k ] = result_dict [k ].strip ().strip ('\n ' )
6061 result_dict [k ] = " " .join (result_dict [k ].split ())
@@ -64,13 +65,21 @@ def parse_string_to_dict(input_string):
6465
6566def process_docstring (docstr ):
6667 start_reading_attr = False
68+ start_reading_returns = False
6769 lines = docstr .split ('\n ' )
6870
6971 attributes = ''
7072 description = ''
73+ returns = ''
7174 read_desc = True
75+ read_returns = False
7276 for line in lines :
7377 if 'Parameters' in line :
78+ read_params = True
79+ read_desc = False
80+ if 'Returns' in line :
81+ read_returns = True
82+ read_params = False
7483 read_desc = False
7584 if read_desc :
7685 description += line + ' '
@@ -79,12 +88,20 @@ def process_docstring(docstr):
7988 continue
8089 if 'radar_list' in line :
8190 start_reading_attr = False
82-
91+ if read_returns :
92+ if '-------' in line :
93+ start_reading_returns = True
94+ continue
95+ if 'ind_rad' in line :
96+ start_reading_returns = False
97+ if start_reading_returns :
98+ returns += line + '\n '
8399 if start_reading_attr :
84100 attributes += line + '\n '
85101
86102 dic = {'description' : " " .join (description .split ()),
87- 'parameters' : parse_string_to_dict (attributes )}
103+ 'parameters' : parse_string_to_dict (attributes ),
104+ 'returns' : returns .strip ()}
88105 return dic
89106
90107
0 commit comments