def list_all_classes(db, groupid): cursor = db.cursor() sql = "SELECT c.id,c.name,c.description,c.advanced,c.visible FROM documentation_class c JOIN documentation_files f WHERE c.fileid=f.id and f.groupid=%s ORDER BY f.sortid, c.sortid" cursor.execute(sql, (groupid)) classes = cursor.fetchall() class_list = [] for dbclass in classes: clazz = DocsClass(dbclass[0]) clazz.name = dbclass[1] clazz.reference = dbclass[2] clazz.advanced = dbclass[3] clazz.visible = dbclass[4] # clazz.function_list = documentation_function.list_all(db,dbclass[0]) class_list.append(clazz) return class_list
def list_all_classes(db, groupid): cursor = db.cursor() sql = 'SELECT c.id,c.name,c.description,c.advanced,c.visible FROM documentation_class c JOIN documentation_files f WHERE c.fileid=f.id and f.groupid=%s ORDER BY f.sortid, c.sortid' cursor.execute(sql, (groupid)) classes = cursor.fetchall() class_list = [] for dbclass in classes: clazz = DocsClass(dbclass[0]) clazz.name = dbclass[1] clazz.reference = dbclass[2] clazz.advanced = dbclass[3] clazz.visible = dbclass[4] #clazz.function_list = documentation_function.list_all(db,dbclass[0]) class_list.append(clazz) return class_list
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, 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