@@ -68,8 +68,8 @@ 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 , tables = [TableDict ], prototypes = [str ], parameters = [ParameterDoc ], returned = [ParameterDoc ])
72- def __init__ (self , name , description , tables , prototypes , parameters , returned ):
71+ @params (self = object , name = str , description = str , tables = [TableDict ], prototypes = [str ], warning = [ str ], parameters = [ParameterDoc ], returned = [ParameterDoc ])
72+ def __init__ (self , name , description , tables , prototypes , warning , parameters , returned ):
7373 self .name = name
7474 self .prototypes = prototypes
7575 self .tables = tables
@@ -110,6 +110,9 @@ def __init__(self, name, description, tables, prototypes, parameters, returned):
110110 self .short_description = self .description .split ('</p>' )[0 ][3 :]
111111 # If it has a description, it is "documented".
112112 self .documented = self .description != ''
113+ # Parse the warning as Markdown, but remote <p> tags
114+ self .warning = markdown .markdown (warning )
115+ self .warning = re .sub (r'^<p>(.*?)</p>$' , r'\1' , self .warning , flags = re .DOTALL )
113116
114117 """Helper function to parse table dictionaries. Only used in Register methods for now."""
115118 def _format_dict_values (self , d ):
@@ -171,6 +174,9 @@ class ClassParser(object):
171174 table_columns_regex = re .compile (r"\s*\*\s@columns\s*\[(.+)\]" )
172175 table_values_regex = re .compile (r"\s*\*\s@values\s*\[(.+?)\]" )
173176
177+ # Regex for catching warning tags
178+ warning_regex = re .compile (r"""\s*\*\s*@warning\s+(.+)""" , re .X )
179+
174180 param_regex = re .compile (r"""\s*\*\s@param\s # The @param tag starts with opt. whitespace followed by "* @param ".
175181 ([^\s]+)\s(\w+)? # The data type, a space, and the name of the param.
176182 (?:\s=\s([^\s:]+))? # The default value: a space, =, and a value that can include periods but stops at whitespace or a colon.
@@ -207,6 +213,7 @@ def reset(self):
207213
208214 # These are used to piece together the next `Method`.
209215 self .description = ''
216+ self .warning = ''
210217 self .params = []
211218 self .returned = []
212219 self .method_name = None
@@ -253,6 +260,10 @@ def handle_table_values(self, match):
253260 # Append the processed values to the last table
254261 self .tables [- 1 ]["values" ].append (processed_values )
255262
263+ def handle_warning (self , match ):
264+ warning = match .group (1 )
265+ self .warning += warning
266+
256267 def handle_param (self , match ):
257268 data_type , name , default , description = match .group (1 ), match .group (2 ), match .group (3 ), match .group (4 )
258269 self .params .append (ParameterDoc (name , data_type , description , default ))
@@ -328,7 +339,7 @@ def make_prototype(parameters):
328339 # Format the method name into each prototype.
329340 self .prototypes = [proto .format (self .method_name ) for proto in self .prototypes ]
330341
331- self .methods .append (MethodDoc (self .method_name , self .description , self .tables , self .prototypes , self .params , self .returned ))
342+ self .methods .append (MethodDoc (self .method_name , self .description , self .tables , self .prototypes , self .warning , self . params , self .returned ))
332343
333344 # Table of which handler is used to handle each regular expressions.
334345 regex_handlers = {
@@ -340,6 +351,7 @@ def make_prototype(parameters):
340351 table_regex : handle_table ,
341352 table_columns_regex : handle_table_columns ,
342353 table_values_regex : handle_table_values ,
354+ warning_regex : handle_warning ,
343355 param_regex : handle_param ,
344356 return_regex : handle_return ,
345357 proto_regex : handle_proto ,
@@ -354,13 +366,14 @@ def make_prototype(parameters):
354366 class_start_regex : [class_end_regex , class_body_regex ],
355367 class_body_regex : [class_end_regex , class_body_regex ],
356368 class_end_regex : [],
357- start_regex : [table_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
358- body_regex : [table_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
359- proto_regex : [table_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
360- table_regex : [table_regex , table_columns_regex , param_regex , return_regex , comment_end_regex , body_regex ],
361- table_columns_regex : [table_values_regex , param_regex , return_regex , comment_end_regex , body_regex ],
362- table_values_regex : [table_values_regex , table_regex , param_regex , return_regex , comment_end_regex , body_regex ],
363- param_regex : [table_regex , param_regex , return_regex , comment_end_regex , body_regex ],
369+ start_regex : [table_regex , warning_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
370+ body_regex : [table_regex , warning_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
371+ proto_regex : [table_regex , warning_regex , param_regex , return_regex , proto_regex , comment_end_regex , body_regex ],
372+ table_regex : [table_regex , table_columns_regex , warning_regex , param_regex , return_regex , comment_end_regex , body_regex ],
373+ table_columns_regex : [table_values_regex , warning_regex , param_regex , return_regex , comment_end_regex , body_regex ],
374+ table_values_regex : [table_values_regex , table_regex , warning_regex , param_regex , return_regex , comment_end_regex , body_regex ],
375+ warning_regex : [table_values_regex , table_regex , warning_regex , param_regex , return_regex , comment_end_regex , body_regex ],
376+ param_regex : [table_regex , warning_regex , param_regex , return_regex , comment_end_regex , body_regex ],
364377 return_regex : [return_regex , comment_end_regex ],
365378 comment_end_regex : [end_regex ],
366379 end_regex : [],
0 commit comments