def serialize_class(filename): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen.compounddef documentation_class = getclass(clazz.compoundname.text) #f = open('documentation/' + classname + ".html.mako",'w') #index.write("[" + classname + "](" + classname + ".html)\n\n") #f.write( '<%inherit file="_templates/documentation.mako" />\n' ) #f.write( '___' + classname + "___\n" ) inheritsfrom = [] if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: #if section.get("kind") == public TODO: access, virtual, pure virtual if member.get("kind") == 'enum': pass else: #f.write( "$$code(lang=c++)\n" ) if member.get("kind") == 'variable': var = documentation_class.var_by_name(member.name.text) if not var: var = DocsVar(0) var.name = member.name.text var.access = member.get("prot") var.version_started = currentversion var.version_deprecated = "" var.constant = member.get("mutable")=="no" var.static = member.get("static") var.clazz = documentation_class.name var.type = member.type.ref.text if hasattr(member.type,'ref') else member.type.text documentation_class.var_list.append(var) #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" ) if member.get("kind") == 'function': argstring = str(member.argsstring.text) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text returns = ("" if returns is None else returns) method = documentation_class.function_by_signature(member.name.text, returns, params) method.static = member.get("static") method.clazz = documentation_class.name method.access = member.get("prot") method.returns = returns #method.description = method.description.replace("~~~~{.brush: cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") method.description = method.description.replace('<p>','').replace('</p>','').replace('<code>','').replace('</code>','').replace('<pre>','') if method.new: method.version_started = currentversion #f.write( str(member.type.text) + " " + str(member.name.text) + str(member.argsstring.text) + "\n" ) #f.write( "$$/code\n\n\n\n" ) #f.close() setclass(documentation_class)
def serialize_class(filename): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen.compounddef docs_class = getclass(clazz.compoundname.text) inheritsfrom = [] if clazz.find('derivedcompoundref') != None: inheritsfrom = clazz.derivedcompoundref if clazz.find('sectiondef') != None: for section in clazz.sectiondef: for member in section.memberdef: if member.get("kind") == 'enum': pass else: if member.get("kind") == 'variable': var = docs_class.var_by_name(member.name.text) if not var: var = DocsVar(0) var.name = member.name.text var.access = member.get("prot") var.version_started = currentversion var.version_deprecated = "" var.constant = member.get("mutable") == "no" var.static = member.get("static") var.clazz = docs_class.name var.type = member.type.ref.text if hasattr( member.type, 'ref') else member.type.text docs_class.var_list.append(var) if member.get("kind") == 'function': argstring = str(member.argsstring.text) params = argstring[argstring.find('(') + 1:argstring.rfind(')')] returns = member.type.ref.text if hasattr( member.type, 'ref') else member.type.text returns = ("" if returns is None else returns) method = docs_class.function_by_signature( member.name.text, returns, params) method.static = member.get("static") method.clazz = docs_class.name method.access = member.get("prot") method.returns = returns if method.new: method.version_started = currentversion setclass(docs_class)
def serialize_class(filename): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen.compounddef documentation_class = getclass(clazz.compoundname.text) inheritsfrom = [] if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: if member.get("kind") == 'enum': pass else: if member.get("kind") == 'variable': var = documentation_class.var_by_name(member.name.text) if not var: var = DocsVar(0) var.name = member.name.text var.access = member.get("prot") var.version_started = currentversion var.version_deprecated = "" var.constant = member.get("mutable")=="no" var.static = member.get("static") var.clazz = documentation_class.name var.type = member.type.ref.text if hasattr(member.type,'ref') else member.type.text documentation_class.var_list.append(var) if member.get("kind") == 'function': argstring = str(member.argsstring.text) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text returns = ("" if returns is None else returns) method = documentation_class.function_by_signature(member.name.text, returns, params) method.static = member.get("static") method.clazz = documentation_class.name method.access = member.get("prot") method.returns = returns if method.new: method.version_started = currentversion setclass(documentation_class)
def serialize_class(filename,is_addon=False): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen_compound.parse(filename).compounddef #doxygen.compounddef documentation_class = getclass(clazz.compoundname) current_variables_list = [] current_methods_list = [] #f = open('documentation/' + classname + ".html.mako",'w') #index.write("[" + classname + "](" + classname + ".html)\n\n") #f.write( '<%inherit file="_templates/documentation.mako" />\n' ) #f.write( '___' + classname + "___\n" ) inheritsfrom = [] #if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref documentation_class.detailed_inline_description = "" #clazz_for_description = doxygen_compound.parse(filename).compounddef for p in clazz.briefdescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph(p) documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + "\n" for p in clazz.detaileddescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph(p) #if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: #if section.get("kind") == public TODO: access, virtual, pure virtual if member.kind == 'enum': pass else: #f.write( "$$code(lang=c++)\n" ) if member.kind == 'variable': var = documentation_class.var_by_name(member.name) if not var: var = DocsVar(0) var.name = member.name var.access = member.prot var.version_started = currentversion var.version_deprecated = "" var.constant = member.mutable=="no" var.static = member.static!="no" var.clazz = documentation_class.name #member.type.ref.text if hasattr(member.type,'ref') else member.type.text var.type = "" try: for e in member.type_.content_: if type(e.value) == doxygen_compound.refTextType: var.type = var.type + e.value.valueOf_ else: var.type = var.type + e.value + " " except: pass current_variables_list.append(var) #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" ) if member.kind == 'function' and member.name.find("OF_DEPRECATED_MSG")==-1: #print member.name argstring = str(member.argsstring) params = argstring[argstring.find('(')+1:argstring.rfind(')')] returns = "" try: for e in member.type_.content_: if type(e.value) == doxygen_compound.refTextType: returns = returns + e.value.valueOf_ else: returns = returns + e.value except: pass returns = ("" if returns is None else returns) method = documentation_class.function_by_signature(member.name, returns, params) method.static = member.static!="no" method.clazz = documentation_class.name method.access = member.prot method.returns = returns #method.description = method.description.replace("~~~~{.brush: cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") method.description = method.description.replace('<p>','').replace('</p>','').replace('<code>','').replace('</code>','').replace('<pre>','') if method.new: print "new method " + method.name + " in " + method.clazz method.version_started = currentversion method.inlined_description = "" for p in member.briefdescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph(p) method.inlined_description = method.inlined_description + "\n" for p in member.detaileddescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph(p) current_methods_list.append(method) #f.write( str(member.type.text) + " " + str(member.name.text) + str(member.argsstring.text) + "\n" ) """if member.name.text.find("OF_DEPRECATED_MSG")!=-1: print "found deprecated function " + member.name.text print "argstring = " + str(member.argsstring.text) print "params = " + member.argsstring.text[member.argsstring.text.find('(')+1:member.argsstring.text.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text print "returns = " + ("" if returns is None else returns)""" #f.write( "$$/code\n\n\n\n" ) #f.close() deprecated_methods = [] for method in documentation_class.function_list: if method.name.find("OF_DEPRECATED_MSG")!=-1: deprecated_methods.append(method) for method in deprecated_methods: documentation_class.function_list.remove(method); class_name_printed = False for method in documentation_class.function_list: if not method in current_methods_list: if method.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "\n\n\n\n" print "removing method " + method.returns + " " + method.name + "(" + method.parameters + ")" print "with description:" print method.description documentation_class.function_list = current_methods_list for var in documentation_class.var_list: if not var in current_variables_list: if var.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "removing " + var.name print "with description:" print var.description documentation_class.var_list = current_variables_list documentation_class.function_list.sort(key=lambda function: function.name) documentation_class.var_list.sort(key=lambda variable: variable.name) setclass(documentation_class,is_addon)
def serialize_class(cursor, is_addon=False, parent=None, alternative_class_spelling = None): clazz = cursor class_spelling = alternative_class_spelling if alternative_class_spelling is not None else clazz.spelling classname = (parent + "::" if parent is not None else "") + class_spelling documentation_class = getclass(classname) current_variables_list = [] current_methods_list = [] methods_for_fuzzy_search = [] documentation_class.extends = [] for child in clazz.get_children(): if child.kind == CursorKind.CXX_BASE_SPECIFIER: if child.spelling.find("class") == 0: baseclass = child.spelling.split(' ')[1] documentation_class.extends.append(baseclass) else: documentation_class.extends.append(child.spelling) documentation_class.detailed_inline_description = parse_docs(clazz) for member in clazz.get_children(): if member.kind == CursorKind.CLASS_DECL or member.kind == CursorKind.CLASS_TEMPLATE or member.kind == CursorKind.STRUCT_DECL: if member.access_specifier.name.lower() == 'public' and class_spelling + "::" + member.spelling not in visited_classes: for child in member.get_children(): if is_variable(child) or is_method(child): if classname[-1] == '_': serialize_class(member,is_addon,classname[:-1]) visited_classes.append(classname[:-1] + "::" + member.spelling) else: serialize_class(member,is_addon,classname) visited_classes.append(classname + "::" + member.spelling) break elif member.kind == CursorKind.UNION_DECL: for union_member in member.get_children(): if is_variable(union_member): var = parse_variable(documentation_class, clazz, union_member) current_variables_list.append(var) if union_member.kind == CursorKind.STRUCT_DECL: for union_struct_member in union_member.get_children(): if is_variable(union_struct_member): var = parse_variable(documentation_class, clazz, union_struct_member) current_variables_list.append(var) elif is_variable(member): var = parse_variable(documentation_class, clazz, member) current_variables_list.append(var) elif is_method(member): method = parse_function(documentation_class, clazz, member, current_methods_list) if method is not None: current_methods_list.append(method) else: methods_for_fuzzy_search.append(member) for member in methods_for_fuzzy_search: method = parse_function(documentation_class, clazz, member, current_methods_list, True) if method is not None: current_methods_list.append(method) for method in documentation_class.function_list: if not method in current_methods_list: missing_methods.append(method) documentation_class.function_list = current_methods_list for var in documentation_class.var_list: if not var in current_variables_list: missing_vars.append(var) documentation_class.var_list = current_variables_list documentation_class.function_list.sort(key=lambda function: function.syntax) documentation_class.var_list.sort(key=lambda variable: variable.name) if documentation_class.new: new_classes.append(documentation_class) setclass(documentation_class,is_addon)
def ofReferenceConvert(): method = DocsMethod(0) #from ofReference var = DocsVar(0) clazzmethod = DocsMethod(0) #from markdown for root, dirs, files in os.walk(os.path.join(ofReference_path)): for name in files: file_split = os.path.splitext(name) if file_split[1]==".jpeg" or file_split[1]==".jpg" or file_split[1]==".gif" or file_split[1]==".png": try: os.mkdir(os.path.join(documentation_root,os.path.basename(root))) except: pass shutil.copyfile(os.path.join(root,name), os.path.join(documentation_root,os.path.basename(root),name)) if file_split[1]=='.markdown': print '###################get_class ' + file_split[0] clazz = getclass(file_split[0]) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = root print os.path.basename(root) f = open(os.path.join(root,name),'r') state = 'clazz' for line in f: if state == 'clazz' and line.find('## Functions')==0: state = 'functions' elif (state == 'clazz' or state=='method' or state=='var' or state=='functions') and line.find('###')==0: element = line.replace("const ### ","const ").split('###')[1].rstrip('#').strip(' ') if element.find('(')!=-1 and element.find(')')!=-1: method = parse_function(element) clazzmethod = clazztosave.function_by_signature(method.name,method.returns,method.parameters) state = 'method' else: state = 'var' elif (state == 'clazz' or state=='method' or state=='var' or state=='functions') and line.find('##')==0: #print 'class: ' + line.strip('\n') clazz_name = line.split('##')[1].rstrip('#').strip(' ').strip('\n') clazz = getclass(clazz_name) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = os.path.basename(root) print clazztosave.module state = 'clazz' print clazz_name + '\n\n' elif state == 'clazz': if line.find("//----------------------")==0: continue line = line.replace('```cpp','$$code(lang=c++)') line = line.replace('```','$$/code') print unicode(line,errors='ignore') clazztosave.reference = clazztosave.reference + unicode(line, errors='ignore') #.decode('cp1252')) elif state == 'method': if line.find("//----------------------")==0: continue line = line.replace('```cpp','$$code(lang=c++)') line = line.replace('```','$$/code') clazzmethod.description = clazzmethod.description + unicode(line, errors='ignore') elif state == 'function': pass elif state == 'functions' and line.find('###')==0: pass f.close() setclass(clazztosave)
def serialize_class(filename, is_addon=False): xml = objectify.parse(filename) doxygen = xml.getroot() clazz = doxygen_compound.parse(filename).compounddef #doxygen.compounddef documentation_class = getclass(clazz.compoundname) current_variables_list = [] current_methods_list = [] #f = open('documentation/' + classname + ".html.mako",'w') #index.write("[" + classname + "](" + classname + ".html)\n\n") #f.write( '<%inherit file="_templates/documentation.mako" />\n' ) #f.write( '___' + classname + "___\n" ) inheritsfrom = [] #if clazz.find('derivedcompoundref')!=None: inheritsfrom = clazz.derivedcompoundref documentation_class.detailed_inline_description = "" #clazz_for_description = doxygen_compound.parse(filename).compounddef for p in clazz.briefdescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph( p) documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + "\n" for p in clazz.detaileddescription.get_para(): documentation_class.detailed_inline_description = documentation_class.detailed_inline_description + serialize_doxygen_paragraph( p) #if clazz.find('sectiondef')!=None: for section in clazz.sectiondef: for member in section.memberdef: #if section.get("kind") == public TODO: access, virtual, pure virtual if member.kind == 'enum': pass else: #f.write( "$$code(lang=c++)\n" ) if member.kind == 'variable': var = documentation_class.var_by_name(member.name) if not var: var = DocsVar(0) var.name = member.name var.access = member.prot var.version_started = currentversion var.version_deprecated = "" var.constant = member.mutable == "no" var.static = member.static != "no" var.clazz = documentation_class.name #member.type.ref.text if hasattr(member.type,'ref') else member.type.text var.type = "" try: for e in member.type_.content_: if type(e.value ) == doxygen_compound.refTextType: var.type = var.type + e.value.valueOf_ else: var.type = var.type + e.value + " " except: pass current_variables_list.append(var) #f.write( str(member.type.text) + " " + str(member.name.text) + "\n" ) if member.kind == 'function' and member.name.find( "OF_DEPRECATED_MSG") == -1: #print member.name argstring = str(member.argsstring) params = argstring[argstring.find('(') + 1:argstring.rfind(')')] returns = "" try: for e in member.type_.content_: if type(e.value) == doxygen_compound.refTextType: returns = returns + e.value.valueOf_ else: returns = returns + e.value except: pass returns = ("" if returns is None else returns) method = documentation_class.function_by_signature( member.name, returns, params) method.static = member.static != "no" method.clazz = documentation_class.name method.access = member.prot method.returns = returns #method.description = method.description.replace("~~~~{.brush: cpp}","~~~~{.cpp}").replace('</pre>',"~~~~") method.description = method.description.replace( '<p>', '').replace('</p>', '').replace('<code>', '').replace( '</code>', '').replace('<pre>', '') if method.new: print "new method " + method.name + " in " + method.clazz method.version_started = currentversion method.inlined_description = "" for p in member.briefdescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph( p) method.inlined_description = method.inlined_description + "\n" for p in member.detaileddescription.get_para(): method.inlined_description = method.inlined_description + serialize_doxygen_paragraph( p) current_methods_list.append(method) #f.write( str(member.type.text) + " " + str(member.name.text) + str(member.argsstring.text) + "\n" ) """if member.name.text.find("OF_DEPRECATED_MSG")!=-1: print "found deprecated function " + member.name.text print "argstring = " + str(member.argsstring.text) print "params = " + member.argsstring.text[member.argsstring.text.find('(')+1:member.argsstring.text.rfind(')')] returns = member.type.ref.text if hasattr(member.type,'ref') else member.type.text print "returns = " + ("" if returns is None else returns)""" #f.write( "$$/code\n\n\n\n" ) #f.close() deprecated_methods = [] for method in documentation_class.function_list: if method.name.find("OF_DEPRECATED_MSG") != -1: deprecated_methods.append(method) for method in deprecated_methods: documentation_class.function_list.remove(method) class_name_printed = False for method in documentation_class.function_list: if not method in current_methods_list: if method.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "\n\n\n\n" print "removing method " + method.returns + " " + method.name + "(" + method.parameters + ")" print "with description:" print method.description documentation_class.function_list = current_methods_list for var in documentation_class.var_list: if not var in current_variables_list: if var.description.strip("\n ") != "": if not class_name_printed: print "\n\n\n\n" print "========================================" print "class " + documentation_class.name class_name_printed = True print "removing " + var.name print "with description:" print var.description documentation_class.var_list = current_variables_list documentation_class.function_list.sort(key=lambda function: function.name) documentation_class.var_list.sort(key=lambda variable: variable.name) setclass(documentation_class, is_addon)
def ofReferenceConvert(): method = DocsMethod(0) #from ofReference var = DocsVar(0) clazzmethod = DocsMethod(0) #from markdown for root, dirs, files in os.walk(os.path.join(ofReference_path)): for name in files: file_split = os.path.splitext(name) if file_split[1] == ".jpeg" or file_split[ 1] == ".jpg" or file_split[1] == ".gif" or file_split[ 1] == ".png": try: os.mkdir( os.path.join(documentation_root, os.path.basename(root))) except: pass shutil.copyfile( os.path.join(root, name), os.path.join(documentation_root, os.path.basename(root), name)) if file_split[1] == '.markdown': print '###################get_class ' + file_split[0] clazz = getclass(file_split[0]) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = root print os.path.basename(root) f = open(os.path.join(root, name), 'r') state = 'clazz' for line in f: if state == 'clazz' and line.find('## Functions') == 0: state = 'functions' elif (state == 'clazz' or state == 'method' or state == 'var' or state == 'functions') and line.find('###') == 0: element = line.replace( "const ### ", "const ").split('###')[1].rstrip('#').strip(' ') if element.find('(') != -1 and element.find(')') != -1: method = parse_function(element) clazzmethod = clazztosave.function_by_signature( method.name, method.returns, method.parameters) state = 'method' else: state = 'var' elif (state == 'clazz' or state == 'method' or state == 'var' or state == 'functions') and line.find('##') == 0: #print 'class: ' + line.strip('\n') clazz_name = line.split('##')[1].rstrip('#').strip( ' ').strip('\n') clazz = getclass(clazz_name) clazztosave = getclass(file_split[0]) if clazztosave.new: clazztosave.module = os.path.basename(root) print clazztosave.module state = 'clazz' print clazz_name + '\n\n' elif state == 'clazz': if line.find("//----------------------") == 0: continue line = line.replace('```cpp', '$$code(lang=c++)') line = line.replace('```', '$$/code') print unicode(line, errors='ignore') clazztosave.reference = clazztosave.reference + unicode( line, errors='ignore') #.decode('cp1252')) elif state == 'method': if line.find("//----------------------") == 0: continue line = line.replace('```cpp', '$$code(lang=c++)') line = line.replace('```', '$$/code') clazzmethod.description = clazzmethod.description + unicode( line, errors='ignore') elif state == 'function': pass elif state == 'functions' and line.find('###') == 0: pass f.close() setclass(clazztosave)
import markdown_file addons = markdown_file.list_all_addons() classes = markdown_file.getclass_list() for clazz_name in classes: clazz = markdown_file.getclass(clazz_name,True) markdown_file.setclass(clazz,clazz.module in addons) function_files = markdown_file.getfunctionsfiles_list() for function_file_name in function_files: functions_file = markdown_file.getfunctionsfile(function_file_name) markdown_file.setfunctionsfile(functions_file, functions_file.module in addons)