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 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): 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 parse_variable(documentation_class, clazz, member): var = documentation_class.var_by_name(member.displayname) if not var: var = DocsVar(0) var.name = member.spelling var.access = member.access_specifier.name.lower() var.version_started = currentversion var.version_deprecated = "" var.constant = member.result_type.is_volatile_qualified() var.static = member.kind == CursorKind.VAR_DECL var.clazz = documentation_class.name #member.type.ref.text if hasattr(member.type,'ref') else member.type.text var.type = substitutetype(member.type.spelling) new_vars.append(var) try: var.inlined_description = parse_docs(member) except: pass return var
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 getclass(clazz, getTemplated=False): var = DocsVar(0) documentation_clazz = DocsClass(0) var.clazz = clazz documentation_clazz.name = clazz documentation_clazz.new = True method = DocsMethod(0) method.clazz = documentation_clazz.name prevBreakLine = False for root, dirs, files in os.walk(os.path.join(documentation_root)): for name in files: file_split = os.path.splitext(name) if file_split[1] == '.markdown' and file_split[0] == clazz: f = open(os.path.join(root, name), 'r') state = 'begin' linenum = 0 for line in f: line = line.decode("utf-8", "replace") if state == 'begin' and line.find( '#class') == 0 and line.find(clazz) != -1: state = 'class' documentation_clazz.module = os.path.basename(root) documentation_clazz.new = False elif state == 'class' and line.rstrip('\n').rstrip( ' ') == '##Methods': state = 'methods' elif state == 'methods' and line.find('###') == 0: #print "##########method: " + line state = 'method' elif state == 'method' and line.find( '_') == 0 and line.find('_description') == -1: #print "##########field: " + line addfield(method, line) elif state == 'method' and line.find('_description') == 0: state = 'description' prevBreakLine = False elif state == 'description' and line.find( '##' ) != 0 and line.find( '<!----------------------------------------------------------------------------->' ) == -1 and (line != '\n' or not prevBreakLine): method.description = method.description + line prevBreakLine = (line == '\n') elif state == 'description' and line.find('###') == 0: state = 'method' documentation_clazz.function_list.append(method) method = DocsMethod(0) method.clazz = documentation_clazz.name method.linenum = linenum method.file = os.path.join(root, name) elif state == 'description' and line.rstrip('\n').rstrip( ' ') == '##Variables': documentation_clazz.function_list.append(method) state = 'vars' elif state == 'vars' and line.find('###') == 0: #print line state = 'var' elif state == 'var' and line.find('_') == 0 and line.find( '_description') == -1: addfield(var, line) elif state == 'var' and line.find('_description') == 0: state = 'vardescription' prevBreakLine = False elif state == 'vardescription' and line.find( '##' ) != 0 and line.find( '<!----------------------------------------------------------------------------->' ) == -1 and (line != '\n' or not prevBreakLine): var.description = var.description + line prevBreakLine = (line == '\n') elif state == 'vardescription' and line.find('###') == 0: #print line state = 'var' documentation_clazz.var_list.append(var) var = DocsVar(0) var.clazz = documentation_clazz.name var.linenum = linenum var.file = os.path.join(root, name) elif state == 'class' and line.find( '##Description') == -1 and (line != '\n' or not prevBreakLine): documentation_clazz.reference = documentation_clazz.reference + line prevBreakLine = (line == '\n') linenum = linenum + 1 if state == 'vardescription': documentation_clazz.var_list.append(var) f.close() if getTemplated: templatedClazz = getclass(clazz + "_") if not templatedClazz.new: #print "found templated class " + clazz + "_" if documentation_clazz.new: documentation_clazz.id = templatedClazz.id documentation_clazz.module = templatedClazz.module documentation_clazz.new = False documentation_clazz.advanced = templatedClazz.advanced documentation_clazz.visible = templatedClazz.visible documentation_clazz.example = templatedClazz.example documentation_clazz.reference = templatedClazz.reference documentation_clazz.addons = templatedClazz.addons documentation_clazz.function_list = templatedClazz.function_list documentation_clazz.var_list = templatedClazz.var_list else: documentation_clazz.function_list.extend( templatedClazz.function_list) documentation_clazz.var_list.extend( templatedClazz.var_list) documentation_clazz.reference = documentation_clazz.reference + templatedClazz.reference documentation_clazz.example = documentation_clazz.example + templatedClazz.example documentation_clazz.function_list.sort( key=lambda function: function.name) documentation_clazz.var_list.sort( key=lambda variable: variable.name) #documentation_clazz.function_list.sort(key= sort_function) return documentation_clazz if getTemplated: templatedClazz = getclass(clazz + "_") if not templatedClazz.new: #print "found templated class " + clazz + "_" if documentation_clazz.new: documentation_clazz.id = templatedClazz.id documentation_clazz.module = templatedClazz.module documentation_clazz.new = False documentation_clazz.advanced = templatedClazz.advanced documentation_clazz.visible = templatedClazz.visible documentation_clazz.example = templatedClazz.example documentation_clazz.reference = templatedClazz.reference documentation_clazz.addons = templatedClazz.addons documentation_clazz.function_list = templatedClazz.function_list documentation_clazz.var_list = templatedClazz.var_list else: documentation_clazz.function_list.extend( templatedClazz.function_list) documentation_clazz.var_list.extend(templatedClazz.var_list) documentation_clazz.reference = documentation_clazz.reference + templatedClazz.reference documentation_clazz.example = documentation_clazz.example + templatedClazz.example #documentation_clazz.function_list.sort(key= sort_function) documentation_clazz.function_list.sort(key=lambda function: function.name) documentation_clazz.var_list.sort(key=lambda variable: variable.name) return documentation_clazz
def getclass(clazz): var = DocsVar(0) documentation_clazz = DocsClass(0) var.clazz = clazz documentation_clazz.name = clazz documentation_clazz.new = True method = DocsMethod(0) method.clazz = documentation_clazz.name prevBreakLine = False; for root, dirs, files in os.walk(os.path.join(documentation_root)): for name in files: file_split = os.path.splitext(name) if file_split[1]=='.markdown' and file_split[0] == clazz: f = open(os.path.join(root,name),'r') state = 'begin' linenum = 0 for line in f: line = line.decode("utf-8", "replace") if state == 'begin' and line.find('#class') == 0 and line.find(clazz)!=-1: state = 'class' documentation_clazz.module = os.path.basename(root) documentation_clazz.new = False elif state == 'class' and line.rstrip('\n').rstrip(' ') == '##Methods': state = 'methods' elif state == 'methods' and line.find('###') == 0: #print "##########method: " + line state = 'method' elif state == 'method' and line.find('_')==0 and line.find('_description')==-1: #print "##########field: " + line addfield(method,line) elif state == 'method' and line.find('_description')==0: state = 'description' prevBreakLine = False elif state == 'description' and line.find('##')!=0 and line.find('<!----------------------------------------------------------------------------->')==-1 and (line!='\n' or not prevBreakLine): method.description = method.description + line prevBreakLine = (line=='\n') elif state == 'description' and line.find('###') == 0: state = 'method' documentation_clazz.function_list.append(method) method = DocsMethod(0) method.clazz = documentation_clazz.name method.linenum = linenum method.file = os.path.join(root,name) elif state == 'description' and line.rstrip('\n').rstrip(' ') == '##Variables': documentation_clazz.function_list.append(method) state = 'vars' elif state == 'vars' and line.find('###') == 0: #print line state = 'var' elif state == 'var' and line.find('_')==0 and line.find('_description')==-1: addfield(var,line) elif state == 'var' and line.find('_description') == 0: state = 'vardescription' prevBreakLine = False elif state == 'vardescription' and line.find('##')!=0 and line.find('<!----------------------------------------------------------------------------->')==-1 and (line!='\n' or not prevBreakLine): var.description = var.description + line prevBreakLine = (line=='\n') elif state == 'vardescription' and line.find('###') == 0: #print line state = 'var' documentation_clazz.var_list.append(var) var = DocsVar(0) var.clazz = documentation_clazz.name var.linenum = linenum var.file = os.path.join(root,name) elif state == 'class' and line.find('##Description')==-1 and (line!='\n' or not prevBreakLine): documentation_clazz.reference = documentation_clazz.reference + line prevBreakLine = (line=='\n') linenum = linenum + 1 if state == 'vardescription': documentation_clazz.var_list.append(var) f.close() return documentation_clazz return documentation_clazz
def getclass(clazz): var = DocsVar(0) documentation_clazz = DocsClass(0) if clazz[-1]=="_": documentation_clazz.istemplated = True var.clazz = clazz documentation_clazz.name = clazz documentation_clazz.new = True method = DocsMethod(0) method.clazz = documentation_clazz.name prevBreakLine = False; for root, dirs, files in os.walk(os.path.join(documentation_root)): for name in files: file_split = os.path.splitext(name) if file_split[1]=='.markdown' and file_split[0] == clazz: documentation_clazz.new = False f = open(os.path.join(root,name),'rU') state = 'begin' linenum = 0 for line in f: #line = line.decode("utf-8", "replace") if state == 'begin' and line.find('#class') == 0 and line.find(clazz)!=-1: state = 'class' documentation_clazz.module = os.path.basename(root) documentation_clazz.new = False elif state == 'classdescription' and line.rstrip('\n').rstrip(' ') == '##Methods': state = 'methods' elif state == 'methods' and line.find('###') == 0: #print "##########method: " + line state = 'method' elif state == 'method' and line.find('_')==0 and line.find('_description')==-1 and line.find('_inlined_description')==-1: #print "##########field: " + line addfield(method,line) elif state == 'method' and line.find('_inlined_description')==0: state = 'inlined_description' prevBreakLine = False elif (state == 'inlined_description' or state=='method') and line.find('_description')==0: state = 'description' prevBreakLine = False elif state == 'inlined_description' and line.find('##')!=0 and line.find('_description')==-1 and (line!='\n' or not prevBreakLine): method.inlined_description = method.inlined_description + line prevBreakLine = (line=='\n') elif state == 'description' and line.find('##')!=0 and line.find('<!----------------------------------------------------------------------------->')==-1 and (line!='\n' or not prevBreakLine): method.description = method.description + line prevBreakLine = (line=='\n') elif state == 'description' and line.find('###') == 0: state = 'method' documentation_clazz.function_list.append(method) method = DocsMethod(0) method.clazz = documentation_clazz.name method.linenum = linenum method.file = os.path.join(root,name) elif (state == 'description' or state == 'methods') and line.rstrip('\n').rstrip(' ') == '##Variables': if state == 'description': documentation_clazz.function_list.append(method) state = 'vars' elif state == 'vars' and line.find('###') == 0: #print line state = 'var' elif state == 'var' and line.find('_')==0 and line.find('_description')==-1: addfield(var,line) elif state == 'var' and line.find('_description') == 0: state = 'vardescription' prevBreakLine = False elif state == 'vardescription' and line.find('##')!=0 and line.find('<!----------------------------------------------------------------------------->')==-1 and (line!='\n' or not prevBreakLine): var.description = var.description + line prevBreakLine = (line=='\n') elif state == 'vardescription' and line.find('###') == 0: #print line state = 'var' documentation_clazz.var_list.append(var) var = DocsVar(0) var.clazz = documentation_clazz.name var.linenum = linenum var.file = os.path.join(root,name) elif state == 'class' and line.find('_')==0: addfield(documentation_clazz,line) elif state == 'class' and line.find('##InlineDescription')==0: state = 'classinlinedescription' documentation_clazz.detailed_inline_description = "" elif state == 'classinlinedescription' and line.find('##Description')==-1 and line.find('##InlineDescription')==-1 and (line!='\n' or not prevBreakLine): documentation_clazz.detailed_inline_description = documentation_clazz.detailed_inline_description + line prevBreakLine = (line=='\n') elif (state == 'classinlinedescription' or state == 'class') and line.rstrip('\n').rstrip(' ') == '##Description': state = "classdescription" elif state == 'classdescription' and (line!='\n' or not prevBreakLine): documentation_clazz.reference = documentation_clazz.reference + line prevBreakLine = (line=='\n') linenum = linenum + 1 if state == 'vardescription': documentation_clazz.var_list.append(var) f.close() """if getTemplated: templatedClazz = getclass(clazz+"_") if not templatedClazz.new: #print "found templated class " + clazz + "_" if documentation_clazz.new: documentation_clazz.id = templatedClazz.id documentation_clazz.module = templatedClazz.module documentation_clazz.new = False documentation_clazz.advanced = templatedClazz.advanced documentation_clazz.visible = templatedClazz.visible documentation_clazz.example = templatedClazz.example documentation_clazz.reference = templatedClazz.reference documentation_clazz.addons = templatedClazz.addons documentation_clazz.function_list = templatedClazz.function_list documentation_clazz.var_list = templatedClazz.var_list documentation_clazz.istemplated = True else: documentation_clazz.function_list.extend(templatedClazz.function_list) documentation_clazz.var_list.extend(templatedClazz.var_list) documentation_clazz.reference = documentation_clazz.reference + templatedClazz.reference documentation_clazz.example = documentation_clazz.example + templatedClazz.example documentation_clazz.istemplated = True""" documentation_clazz.function_list.sort(key= sort_function) #documentation_clazz.function_list.sort(key=lambda function: function.name) documentation_clazz.var_list.sort(key=lambda variable: variable.name) #documentation_clazz.function_list.sort(key= sort_function) return documentation_clazz """if getTemplated: templatedClazz = getclass(clazz+"_") if not templatedClazz.new: #print "found templated class " + clazz + "_" if documentation_clazz.new: documentation_clazz.id = templatedClazz.id documentation_clazz.module = templatedClazz.module documentation_clazz.new = False documentation_clazz.advanced = templatedClazz.advanced documentation_clazz.visible = templatedClazz.visible documentation_clazz.example = templatedClazz.example documentation_clazz.reference = templatedClazz.reference documentation_clazz.addons = templatedClazz.addons documentation_clazz.function_list = templatedClazz.function_list documentation_clazz.var_list = templatedClazz.var_list documentation_clazz.istemplated = True else: documentation_clazz.function_list.extend(templatedClazz.function_list) documentation_clazz.var_list.extend(templatedClazz.var_list) documentation_clazz.reference = documentation_clazz.reference + templatedClazz.reference documentation_clazz.example = documentation_clazz.example + templatedClazz.example documentation_clazz.istemplated = True""" documentation_clazz.function_list.sort(key= sort_function) #documentation_clazz.function_list.sort(key=lambda function: function.name) documentation_clazz.var_list.sort(key=lambda variable: variable.name) return documentation_clazz
def getclass(clazz): var = DocsVar(0) documentation_clazz = DocsClass(0) if clazz[-1] == "_": documentation_clazz.istemplated = True var.clazz = clazz documentation_clazz.name = clazz documentation_clazz.new = True method = DocsMethod(0) method.clazz = documentation_clazz.name prevBreakLine = False for root, dirs, files in os.walk(os.path.join(documentation_root)): for name in files: file_split = os.path.splitext(name) if file_split[1] == ".markdown" and file_split[0] == clazz: f = open(os.path.join(root, name), "rU") state = "begin" linenum = 0 for line in f: line = line.decode("utf-8", "replace") if state == "begin" and line.find("#class") == 0 and line.find(clazz) != -1: state = "class" documentation_clazz.module = os.path.basename(root) documentation_clazz.new = False elif state == "classdescription" and line.rstrip("\n").rstrip(" ") == "##Methods": state = "methods" elif state == "methods" and line.find("###") == 0: # print "##########method: " + line state = "method" elif ( state == "method" and line.find("_") == 0 and line.find("_description") == -1 and line.find("_inlined_description") == -1 ): # print "##########field: " + line addfield(method, line) elif state == "method" and line.find("_inlined_description") == 0: state = "inlined_description" prevBreakLine = False elif (state == "inlined_description" or state == "method") and line.find("_description") == 0: state = "description" prevBreakLine = False elif ( state == "inlined_description" and line.find("##") != 0 and line.find("_description") == -1 and (line != "\n" or not prevBreakLine) ): method.inlined_description = method.inlined_description + line prevBreakLine = line == "\n" elif ( state == "description" and line.find("##") != 0 and line.find( "<!----------------------------------------------------------------------------->" ) == -1 and (line != "\n" or not prevBreakLine) ): method.description = method.description + line prevBreakLine = line == "\n" elif state == "description" and line.find("###") == 0: state = "method" documentation_clazz.function_list.append(method) method = DocsMethod(0) method.clazz = documentation_clazz.name method.linenum = linenum method.file = os.path.join(root, name) elif (state == "description" or state == "methods") and line.rstrip("\n").rstrip( " " ) == "##Variables": if state == "description": documentation_clazz.function_list.append(method) state = "vars" elif state == "vars" and line.find("###") == 0: # print line state = "var" elif state == "var" and line.find("_") == 0 and line.find("_description") == -1: addfield(var, line) elif state == "var" and line.find("_description") == 0: state = "vardescription" prevBreakLine = False elif ( state == "vardescription" and line.find("##") != 0 and line.find( "<!----------------------------------------------------------------------------->" ) == -1 and (line != "\n" or not prevBreakLine) ): var.description = var.description + line prevBreakLine = line == "\n" elif state == "vardescription" and line.find("###") == 0: # print line state = "var" documentation_clazz.var_list.append(var) var = DocsVar(0) var.clazz = documentation_clazz.name var.linenum = linenum var.file = os.path.join(root, name) elif state == "class" and line.find("_") == 0: addfield(documentation_clazz, line) elif state == "class" and line.find("##InlineDescription") == 0: state = "classinlinedescription" documentation_clazz.detailed_inline_description = "" elif ( state == "classinlinedescription" and line.find("##Description") == -1 and line.find("##InlineDescription") == -1 and (line != "\n" or not prevBreakLine) ): documentation_clazz.detailed_inline_description = ( documentation_clazz.detailed_inline_description + line ) prevBreakLine = line == "\n" elif (state == "classinlinedescription" or state == "class") and line.rstrip("\n").rstrip( " " ) == "##Description": state = "classdescription" elif state == "classdescription" and (line != "\n" or not prevBreakLine): documentation_clazz.reference = documentation_clazz.reference + line prevBreakLine = line == "\n" linenum = linenum + 1 if state == "vardescription": documentation_clazz.var_list.append(var) f.close() """if getTemplated: templatedClazz = getclass(clazz+"_") if not templatedClazz.new: #print "found templated class " + clazz + "_" if documentation_clazz.new: documentation_clazz.id = templatedClazz.id documentation_clazz.module = templatedClazz.module documentation_clazz.new = False documentation_clazz.advanced = templatedClazz.advanced documentation_clazz.visible = templatedClazz.visible documentation_clazz.example = templatedClazz.example documentation_clazz.reference = templatedClazz.reference documentation_clazz.addons = templatedClazz.addons documentation_clazz.function_list = templatedClazz.function_list documentation_clazz.var_list = templatedClazz.var_list documentation_clazz.istemplated = True else: documentation_clazz.function_list.extend(templatedClazz.function_list) documentation_clazz.var_list.extend(templatedClazz.var_list) documentation_clazz.reference = documentation_clazz.reference + templatedClazz.reference documentation_clazz.example = documentation_clazz.example + templatedClazz.example documentation_clazz.istemplated = True""" documentation_clazz.function_list.sort(key=lambda function: function.name) documentation_clazz.var_list.sort(key=lambda variable: variable.name) # documentation_clazz.function_list.sort(key= sort_function) return documentation_clazz """if getTemplated: templatedClazz = getclass(clazz+"_") if not templatedClazz.new: #print "found templated class " + clazz + "_" if documentation_clazz.new: documentation_clazz.id = templatedClazz.id documentation_clazz.module = templatedClazz.module documentation_clazz.new = False documentation_clazz.advanced = templatedClazz.advanced documentation_clazz.visible = templatedClazz.visible documentation_clazz.example = templatedClazz.example documentation_clazz.reference = templatedClazz.reference documentation_clazz.addons = templatedClazz.addons documentation_clazz.function_list = templatedClazz.function_list documentation_clazz.var_list = templatedClazz.var_list documentation_clazz.istemplated = True else: documentation_clazz.function_list.extend(templatedClazz.function_list) documentation_clazz.var_list.extend(templatedClazz.var_list) documentation_clazz.reference = documentation_clazz.reference + templatedClazz.reference documentation_clazz.example = documentation_clazz.example + templatedClazz.example documentation_clazz.istemplated = True""" # documentation_clazz.function_list.sort(key= sort_function) documentation_clazz.function_list.sort(key=lambda function: function.name) documentation_clazz.var_list.sort(key=lambda variable: variable.name) return documentation_clazz
def getclass(clazz): method = DocsMethod(0) var = DocsVar(0) documentation_clazz = DocsClass(0) var.clazz = clazz documentation_clazz.name = clazz documentation_clazz.new = True for root, dirs, files in os.walk(os.path.join(documentation_root)): for name in files: file_split = os.path.splitext(name) if file_split[1]=='.markdown' and file_split[0] == clazz: f = open(os.path.join(root,name),'r') state = 'begin' linenum = 0 for line in f: if state == 'begin' and line.find('#class') == 0 and line.find(clazz)!=-1: state = 'class' documentation_clazz.module = os.path.basename(root) documentation_clazz.new = False elif state == 'class' and line.rstrip('\n').rstrip(' ') == '##Methods': state = 'methods' elif state == 'methods' and line.find('###') == 0: #print "##########method: " + line state = 'method' elif state == 'method' and line.find('_')==0 and line.find('_description')==-1: #print "##########field: " + line addfield(method,line) elif state == 'method' and line.find('_description')==0: state = 'description' elif state == 'description' and line.find('##')!=0 and line.find('<!----------------------------------------------------------------------------->')==-1 and line!='\n': method.description = method.description + line elif state == 'description' and line.find('###') == 0: state = 'method' documentation_clazz.function_list.append(method) method = DocsMethod(0) method.clazz = documentation_clazz.name method.linenum = linenum method.file = os.path.join(root,name) elif state == 'description' and line.rstrip('\n').rstrip(' ') == '##Variables': documentation_clazz.function_list.append(method) state = 'vars' elif state == 'vars' and line.find('###') == 0: #print line state = 'var' elif state == 'var' and line.find('_')==0 and line.find('_description')==-1: addfield(var,line) elif state == 'var' and line.find('_description') == 0: state = 'vardescription' elif state == 'vardescription' and line.find('##')!=0 and line.find('<!----------------------------------------------------------------------------->')==-1 and line!='\n': var.description = var.description + line elif state == 'vardescription' and line.find('###') == 0: #print line state = 'var' documentation_clazz.var_list.append(var) var = DocsVar(0) var.clazz = documentation_clazz.name var.linenum = linenum var.file = os.path.join(root,name) elif state == 'class' and line.find('##Description')==-1 and line!='\n': documentation_clazz.reference = documentation_clazz.reference + line linenum = linenum + 1 if state == 'vardescription': documentation_clazz.var_list.append(var) f.close() return documentation_clazz return documentation_clazz
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)