@@ -68,23 +68,34 @@ def __init__(self, name, data_type, description, default_value=None):
6868
6969class MethodDoc (object ):
7070 """The documentation data of an Eluna method."""
71- @params (self = object , name = str , description = str , table = TableDict , prototypes = [str ], parameters = [ParameterDoc ], returned = [ParameterDoc ])
72- def __init__ (self , name , description , table , prototypes , parameters , returned ):
71+ @params (self = object , name = str , description = str , tables = [ TableDict ] , prototypes = [str ], parameters = [ParameterDoc ], returned = [ParameterDoc ])
72+ def __init__ (self , name , description , tables , prototypes , parameters , returned ):
7373 self .name = name
7474 self .prototypes = prototypes
75- self .table = table
75+ self .tables = tables
7676 self .parameters = parameters
7777 self .returned = returned
78-
79- if table :
80- # Generate Markdown Table
81- md_table = '| ' + ' | ' .join (table ['columns' ]) + ' |\n ' # Header
82- md_table += '| ' + ' | ' .join (['---' ] * len (table ['columns' ])) + ' |\n ' # Separator
8378
84- for row in table ['values' ]:
85- md_table += '| ' + ' | ' .join (row ) + ' |\n ' # Rows
79+ if tables :
80+ html_tables = []
81+
82+ for table in tables :
83+ print ("-------------" )
84+ # Generate Markdown Table for each table
85+ md_table = '| ' + ' | ' .join (table ['columns' ]) + ' |\n ' # Header
86+ md_table += '| ' + ' | ' .join (['---' ] * len (table ['columns' ])) + ' |\n ' # Separator
87+
88+ for row in table ['values' ]:
89+ md_table += '| ' + ' | ' .join (row ) + ' |\n ' # Rows
90+
91+ # Convert the generated Markdown table to HTML
92+ html_table = markdown .markdown (md_table , extensions = ['tables' ])
8693
87- self .table = markdown .markdown (md_table , extensions = ['tables' ])
94+ # Append the HTML table to the list
95+ html_tables .append (html_table )
96+
97+ # Combine all HTML tables into a single string (separated by two newlines)
98+ self .tables = '' .join (html_tables )
8899
89100 # Parse the description as Markdown.
90101 self .description = markdown .markdown (description )
@@ -182,7 +193,7 @@ def reset(self):
182193 self .returned = []
183194 self .method_name = None
184195 self .prototypes = []
185- self .table = {}
196+ self .tables = []
186197
187198 def handle_class_body (self , match ):
188199 text = match .group (1 )
@@ -193,19 +204,20 @@ def handle_body(self, match):
193204 self .description += text + '\n '
194205
195206 def handle_table (self , line ):
196- self . table = {
207+ new_table = {
197208 "columns" : [],
198209 "values" : []
199210 }
211+ self .tables .append (new_table )
200212
201213 def handle_table_columns (self , match ):
202- if self .table :
203- self .table ["columns" ] = match .group (1 ).split (", " )
214+ if self .tables :
215+ self .tables [ - 1 ] ["columns" ] = match .group (1 ).split (", " )
204216
205217 def handle_table_values (self , match ):
206- if self .table :
218+ if self .tables :
207219 values = re .findall (r'(?:[^,"]|"(?:\\.|[^"])*")+' , match .group (1 ))
208- self .table ["values" ].append ([v .strip (' "' ) for v in values ])
220+ self .tables [ - 1 ] ["values" ].append ([v .strip (' "' ) for v in values ])
209221
210222 def handle_param (self , match ):
211223 data_type , name , default , description = match .group (1 ), match .group (2 ), match .group (3 ), match .group (4 )
@@ -282,7 +294,7 @@ def make_prototype(parameters):
282294 # Format the method name into each prototype.
283295 self .prototypes = [proto .format (self .method_name ) for proto in self .prototypes ]
284296
285- self .methods .append (MethodDoc (self .method_name , self .description , self .table , self .prototypes , self .params , self .returned ))
297+ self .methods .append (MethodDoc (self .method_name , self .description , self .tables , self .prototypes , self .params , self .returned ))
286298
287299 # Table of which handler is used to handle each regular expressions.
288300 regex_handlers = {
@@ -313,7 +325,7 @@ def make_prototype(parameters):
313325 proto_regex : [table_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
314326 table_regex : [table_regex , table_columns_regex , param_regex , return_regex , comment_end_regex , body_regex ],
315327 table_columns_regex : [table_values_regex , param_regex , return_regex , comment_end_regex , body_regex ],
316- table_values_regex : [table_values_regex , param_regex , return_regex , comment_end_regex , body_regex ],
328+ table_values_regex : [table_values_regex , table_regex , param_regex , return_regex , comment_end_regex , body_regex ],
317329 param_regex : [table_regex , param_regex , return_regex , comment_end_regex , body_regex ],
318330 return_regex : [return_regex , comment_end_regex ],
319331 comment_end_regex : [end_regex ],
0 commit comments