Ejemplo n.º 1
0
    def function_by_signature(self, name, returns, parameters):
        method = DocsMethod(0)
        method.name = name
        method.parameters = parameters
        method.syntax = name + "("
        for p in self.get_parameter_names(parameters):
            method.syntax = method.syntax + p + ", "
        method.syntax = method.syntax.rstrip(', ')
        method.syntax = method.syntax + ")"
        method.returns = returns
        method.new = True
        for function in self.function_list:
            if function.name == name:
                dst_parameters_types = self.get_parameter_types(function.parameters.replace('const ',''))
                src_parameters_types = self.get_parameter_types(parameters.replace('const ',''))

                if(len(src_parameters_types)==len(dst_parameters_types)):
                    a = -1
                    for i in range(len(src_parameters_types)):
                        if src_parameters_types[i] != dst_parameters_types[i]:
                            break
                        else:
                            a = i
                    if a == len(src_parameters_types)-1:
                        function.new = False
                        function.parameters = parameters
                        return function
                        
        self.function_list.append(method)   
        return method
Ejemplo n.º 2
0
    def function_by_signature(self, name, returns, parameters):
        method = DocsMethod(0)
        method.name = name
        method.parameters = parameters
        method.syntax = name + "("
        for p in self.get_parameter_names(parameters):
            method.syntax = method.syntax + p + ", "
        method.syntax = method.syntax.rstrip(', ')
        method.syntax = method.syntax + ")"
        method.returns = returns
        method.new = True
        found = False
        for function in self.function_list:
            if function.name == name:
                dst_parameters_types = self.get_parameter_types(function.parameters)
                src_parameters_types = self.get_parameter_types(parameters)

                if(len(src_parameters_types)==len(dst_parameters_types)):
                    a = -1
                    for i in range(len(src_parameters_types)):
                        if src_parameters_types[i] != dst_parameters_types[i]:
                            break
                        else:
                            a = i
                    if a == len(src_parameters_types)-1:
                        function.new = False
                        return function
                        found = True
                        #print 'found ' + function.name
                        break
        if not found:
            #print 'not found ' + method.name
            #clazzmethod = method
            self.function_list.append(method)   
        return method
Ejemplo n.º 3
0
def parse_function(element):
    if re.match('.*operator\s*\[\s*\]',element) is None: 
        clean_element = remove_links(element)
    else:
        clean_element = element
    clean_element = html_encode_templates(clean_element)
    #print re.match('operator\b*\[\b*\]\b*\(.*\)',element) is None
    #print clean_element
    m = DocsMethod(0)
    function_name = "" 
    function_return = ""
    function = clean_element.split('(')[0].lstrip(' ').rstrip(' ').split(' ')
    print str(function) + ": " + str(len(function)) + ": " + function[len(function)-1]
    
    #print function
    if len(function)>1:
        if element.find("operator")!=-1 and len(function)>2:
            function_name = function[len(function)-2] + function[len(function)-1]
        else:
            function_name = function[len(function)-1]
            print function_name
        for r in function[:len(function)-1]:
            if r == 'static':
                m.static = True
                continue
            if r == 'operator':
                continue
            if r == 'virtual':
                continue

            function_return = function_return + " " + r
    else:
        function_name = function[0]
    #print clean_element
    
    if clean_element.rfind('const') > clean_element.rfind(')'):
        clean_element = clean_element[:clean_element.rfind('const')]
        m.constant = True
        
    function_parameters = clean_element.split('(')[1].strip('\n').strip(' ').strip(')').strip(' ')
        
    m.name = function_name
    m.returns = function_return
    m.parameters = function_parameters
    m.syntax = function_name + "("
    for p in get_parameter_names(function_parameters):
        m.syntax = m.syntax + p + ", "
    m.syntax = m.syntax.rstrip(', ')
    m.syntax = m.syntax + ")"
    return m
Ejemplo n.º 4
0
 def function_by_signature(self, name, returns, parameters, alternatives,
                           already_found, fuzzy):
     method = DocsMethod(0)
     method.name = name
     method.parameters = parameters
     method.syntax = name + "("
     for p in self.get_parameter_names(parameters):
         method.syntax = method.syntax + p + ", "
     method.syntax = method.syntax.rstrip(', ')
     method.syntax = method.syntax + ")"
     method.returns = returns
     method.new = True
     for function in self.function_list:
         if function.name == name:
             dst_parameters_types = self.get_parameter_types(
                 function.parameters)
             src_parameters_types = self.get_parameter_types(parameters)
             if (len(src_parameters_types) == len(dst_parameters_types)):
                 a = -1
                 for i in range(len(src_parameters_types)):
                     if src_parameters_types[i] != dst_parameters_types[i]:
                         break
                     else:
                         a = i
                 if a == len(src_parameters_types
                             ) - 1 and function.returns == returns:
                     function.new = False
                     function.parameters = parameters
                     function.syntax = method.syntax
                     function.returns = method.returns
                     return function
     if fuzzy and len(alternatives) > 0:
         alternative_func = self.fuzzy_function_search(
             name, returns, parameters, alternatives, already_found)
         if alternative_func != None:
             alternative_func.parameters = method.parameters
             alternative_func.syntax = method.syntax
             alternative_func.returns = method.returns
             return alternative_func
         else:
             self.function_list.append(method)
             return method
     else:
         return None
Ejemplo n.º 5
0
 def function_by_signature(self, name, returns, parameters, alternatives, already_found, fuzzy):
     method = DocsMethod(0)
     method.name = name
     method.parameters = parameters
     method.syntax = name + "("
     for p in self.get_parameter_names(parameters):
         method.syntax = method.syntax + p + ", "
     method.syntax = method.syntax.rstrip(', ')
     method.syntax = method.syntax + ")"
     method.returns = returns
     method.new = True
     for function in self.function_list:
         if function.name == name:
             dst_parameters_types = self.get_parameter_types(function.parameters)
             src_parameters_types = self.get_parameter_types(parameters)
             if(len(src_parameters_types)==len(dst_parameters_types)):
                 a = -1
                 for i in range(len(src_parameters_types)):
                     if src_parameters_types[i] != dst_parameters_types[i]:
                         break
                     else:
                         a = i
                 if a == len(src_parameters_types)-1 and function.returns == returns:
                     function.new = False
                     function.parameters = parameters
                     function.syntax = method.syntax
                     function.returns = method.returns
                     return function
     if fuzzy and len(alternatives)>0:
         alternative_func = self.fuzzy_function_search(name, returns, parameters, alternatives, already_found)
         if alternative_func != None:        
             alternative_func.parameters = method.parameters
             alternative_func.syntax = method.syntax
             alternative_func.returns = method.returns
             return alternative_func
         else:
             self.function_list.append(method)
             return method
     else:
         return None
Ejemplo n.º 6
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.º 7
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.º 8
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.º 9
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.º 10
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
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
def parse_function(element):
    if re.match('.*operator\s*\[\s*\]', element) is None:
        clean_element = remove_links(element)
    else:
        clean_element = element
    clean_element = html_encode_templates(clean_element)
    #print re.match('operator\b*\[\b*\]\b*\(.*\)',element) is None
    #print clean_element
    m = DocsMethod(0)
    function_name = ""
    function_return = ""
    function = clean_element.split('(')[0].lstrip(' ').rstrip(' ').split(' ')
    print str(function) + ": " + str(
        len(function)) + ": " + function[len(function) - 1]

    #print function
    if len(function) > 1:
        if element.find("operator") != -1 and len(function) > 2:
            function_name = function[len(function) -
                                     2] + function[len(function) - 1]
        else:
            function_name = function[len(function) - 1]
            print function_name
        for r in function[:len(function) - 1]:
            if r == 'static':
                m.static = True
                continue
            if r == 'operator':
                continue
            if r == 'virtual':
                continue

            function_return = function_return + " " + r
    else:
        function_name = function[0]
    #print clean_element

    if clean_element.rfind('const') > clean_element.rfind(')'):
        clean_element = clean_element[:clean_element.rfind('const')]
        m.constant = True

    function_parameters = clean_element.split('(')[1].strip('\n').strip(
        ' ').strip(')').strip(' ')

    m.name = function_name
    m.returns = function_return
    m.parameters = function_parameters
    m.syntax = function_name + "("
    for p in get_parameter_names(function_parameters):
        m.syntax = m.syntax + p + ", "
    m.syntax = m.syntax.rstrip(', ')
    m.syntax = m.syntax + ")"
    return m
Ejemplo n.º 13
0
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)