import os import re # Usage: # //? Is defining what the file content is used for. # //- Is struct documentation # //! Is function/method documentation # Assuming there are ALWAYS proper content under the comments and they are properly labeled, no empty or missing comments. Missing comments are not that bad, empty ones are. #Configurable text values def_value_label="(Default value)" def_ret_label="Returns:" def_linked_label="Next linked list element" def_param_label="Parameters:" def_no_ret_label="(Has no return value)" def_no_par_label="(Has no input parameters)" def_comment_label="Integer"; pointer_label="(Pointer)"; static_var_ids=[] static_comments=[] #Hungarian values '''def_value_label="(Kezdő érték)" def_ret_label="Kimenet:" def_linked_label="(A lista következő eleme)" def_param_label="Paraméterek:" def_no_ret_label="(Nincs visszatérési értéke)" def_no_par_label="(Nincsenek függvény paraméterek)" def_comment_label="TODO"; pointer_label="(Pointer)"; static_var_ids=["int","vector2d","double","player","scoremanager","fontsurface","bulletmanager","asteroidmanager","explosionmanager","mainmenu","context","renderer","renderingcontext","deathscreen","scoremarker","toplistscreen","highscoreman","scoreman","bullet","asteroid","explosion","button"] static_comments=["Egész szám","2 dimenziós vektor","Egy valós érték","Játékos","A pontszám kezelő","Referencia a betűfelületre","Referencia a lövedékkezelőre","Referencia az aszteroida kezelőre","Referencia a robbanás kezelőre","A főmenü","A rajzoló kontextus","Az SDL renderer","A rajzoló kontextus","A halálképernyő","Referencia a pontszámjelzőre","Referencia a toplista menüjére","A dicsőséglista","Referencia a pontszámkezelőre","Referencia a lövedékre","Referencia az aszteroidára","Referencia a robbanásra","Referencia a gombra"] ''' def get_return_and_params(func_str): # Match the return type, function name, and parameter list match = re.match(r'(\w[\w\s\*]+)\s+(\w+)\s*\(([^)]*)\)', func_str) if not match: return None, None return_type = match.group(1).strip() params_str = match.group(3).strip() params = [param.strip() for param in params_str.split(',') if param.strip()] return return_type, params def get_cur_comment(par): is_pointer="" tpar=par.lower() if "*" in tpar: is_pointer=pointer_label iter=0 for n in static_var_ids: if n in tpar: return static_comments[iter]+" "+is_pointer; iter+=1 return def_comment_label+" "+is_pointer; def generate_doc_data(file_path,afile): new_comments="" in_struct=False t_struct_desc="" in_void=True ret_t="" params_t=[] cur_comment="" try: with open(file_path, 'r', encoding='utf-8', errors='ignore') as file: for line in file: t_line="" if in_void==True: t_line=line t_line=t_line.replace(';',':') t_line=t_line.replace('(','(') t_line=t_line.replace(')',')') new_comments+="
- ") t_line+='