Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
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