How to use the ford.sourceform.FortranType function in FORD

To help you get started, we’ve selected a few FORD examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
# Check the various possibilities for what is on this line
            if self.settings['lower'].lower() == 'true': line = line.lower()
            if line.lower() == "contains":
                if not incontains and type(self) in _can_have_contains:
                    incontains = True
                    if isinstance(self,FortranType): permission = "public"
                elif incontains:
                    raise Exception("Multiple CONTAINS statements present in scope")
                else:
                    raise Exception("CONTAINS statement in {}".format(type(self).__name__[7:].upper()))
            elif line.lower() == "public": permission = "public"
            elif line.lower() == "private": permission = "private"
            elif line.lower() == "protected": permission = "protected"
            elif line.lower() == "sequence":
                if type(self) == FortranType: self.sequence = True
            elif self.ATTRIB_RE.match(line) and blocklevel == 0:
                match = self.ATTRIB_RE.match(line)
                attr = match.group(1).lower().replace(" ", "")
                if len(attr) >= 4 and attr[0:4].lower() == 'bind':
                    attr = attr.replace(",",", ")
                if hasattr(self,'attr_dict'):
                    if attr == 'data':
                        pass
                    elif attr == 'dimension' or attr == 'allocatable' or attr == 'pointer':
                        names = ford.utils.paren_split(',',match.group(2))
                        for name in names:
                            name = name.strip().lower()
                            i = name.index('(')
                            n = name[:i]
                            sh = name[i:]
                            if n in self.attr_dict:
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
def get_url(self):
        outstr = "{0}/{1}/{2}.html"
        loc = self.get_dir()
        if loc:
            return outstr.format(self.base_url,loc,quote(self.ident))
        elif (
            isinstance(self,(FortranBoundProcedure,FortranCommon))
            or isinstance(self, FortranVariable) and isinstance(self.parent, FortranType)
        ):
            parent_url = self.parent.get_url()
            if parent_url:
                return parent_url + '#' + self.anchor
            else:
                return None
        else:
            return None
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
permission))
                    self.num_lines += self.subroutines[-1].num_lines - 1
                else:
                    raise Exception("Found SUBROUTINE in {}".format(type(self).__name__[7:].upper()))
            elif self.FUNCTION_RE.match(line):
                if isinstance(self,FortranCodeUnit) and not incontains: continue
                if hasattr(self,'functions'):
                    self.functions.append(FortranFunction(source,
                                          self.FUNCTION_RE.match(line),self,
                                          permission))
                    self.num_lines += self.functions[-1].num_lines - 1
                else:
                    raise Exception("Found FUNCTION in {}".format(type(self).__name__[7:].upper()))
            elif self.TYPE_RE.match(line) and blocklevel == 0:
                if hasattr(self,'types'):
                    self.types.append(FortranType(source,self.TYPE_RE.match(line),
                                      self,permission))
                    self.num_lines += self.types[-1].num_lines - 1
                else:
                    raise Exception("Found derived TYPE in {}".format(type(self).__name__[7:].upper()))
            elif self.INTERFACE_RE.match(line) and blocklevel == 0:
                if hasattr(self,'interfaces'):
                    intr = FortranInterface(source,self.INTERFACE_RE.match(line),
                                            self,permission)
                    self.num_lines += intr.num_lines - 1
                    if intr.abstract:
                        self.absinterfaces.extend(intr.contents)
                    elif intr.generic:
                        self.interfaces.append(intr)
                    else:
                        self.interfaces.extend(intr.contents)
                else:
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
def get_dir(self):
        if ( type(self) in [FortranSubroutine,FortranFunction] and
             type(self.parent) is FortranInterface and
             not self.parent.generic ):
            return 'interface'
        elif type(self) is FortranSubmodule:
            return 'module'
        elif ( type(self) in [FortranSourceFile,FortranProgram,FortranModule,
                              GenericSource,FortranBlockData]
               or ( type(self) in [FortranType,FortranInterface,FortranFunction,
                                   FortranSubroutine, FortranSubmoduleProcedure]
                    and type(self.parent) in [FortranSourceFile,FortranProgram,
                                              FortranModule, FortranSubmodule,
                                              FortranBlockData] ) ):
            return self.obj
        else:
            return None
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
class Proc(object):
    def __init__(self,name,proctype):
        self.name = name
        self.proctype = proctype
        self.ident = ''
    def get_url(self):
        return ''
    def get_dir(self):
        return ''
    
sub = Proc('Subroutine','Subroutine')
func = Proc('Function','Function')
intr = Proc('Interface','Interface')
gd.register('Module',FortranModule)
gd.register('Submodule',FortranSubmodule)
gd.register('Type',FortranType)
gd.register(sub,FortranSubroutine)
gd.register(func,FortranFunction)
gd.register(intr,FortranInterface)
gd.register('Unknown Procedure Type',FortranSubroutine)
gd.register('Program',FortranProgram)
gd.register('Source File',FortranSourceFile)

try:
    # Generate key for module graph
    dot = Digraph('Graph Key',graph_attr={'size':'8.90625,1000.0',
                                          'concentrate':'false'},
                              node_attr={'shape':'box',
                                         'height':'0.0',
                                         'margin':'0.08',
                                         'fontname':'Helvetica',
                                         'fontsize':'10.5'},
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
if not self.fromstr:
            if obj.extends:
                if obj.extends in hist:
                    self.ancestor = hist[obj.extends]
                else:
                    self.ancestor = gd.get_node(obj.extends,FortranType,newdict(hist,obj,self))
                self.ancestor.children.add(self)
                self.ancestor.visible = getattr(obj.extends,'visible',True)
            for var in obj.local_variables:
                if (var.vartype == 'type' or var.vartype == 'class') and var.proto[0] != '*':
                    if var.proto[0] == obj:
                        n = self
                    elif var.proto[0] in hist:
                        n = hist[var.proto[0]]
                    else:
                        n = gd.get_node(var.proto[0],FortranType,newdict(hist,obj,self))
                    n.visible = getattr(var.proto[0],'visible',True)
                    if self in n.comp_of:
                        n.comp_of[self] += ', ' + var.name
                    else:
                        n.comp_of[self] = var.name
                    if n in self.comp_types:
                        self.comp_types[n] += ', ' + var.name
                    else:
                        self.comp_types[n] = var.name
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
if line.strip() != '': self.num_lines += 1

            # Temporarily replace all strings to make the parsing simpler
            self.strings = []
            search_from = 0
            while QUOTES_RE.search(line[search_from:]):
                self.strings.append(QUOTES_RE.search(line[search_from:]).group())
                line = line[0:search_from] + QUOTES_RE.sub("\"{}\"".format(len(self.strings)-1),line[search_from:],count=1)
                search_from += QUOTES_RE.search(line[search_from:]).end(0)

            # Check the various possibilities for what is on this line
            if self.settings['lower'].lower() == 'true': line = line.lower()
            if line.lower() == "contains":
                if not incontains and type(self) in _can_have_contains:
                    incontains = True
                    if isinstance(self,FortranType): permission = "public"
                elif incontains:
                    raise Exception("Multiple CONTAINS statements present in scope")
                else:
                    raise Exception("CONTAINS statement in {}".format(type(self).__name__[7:].upper()))
            elif line.lower() == "public": permission = "public"
            elif line.lower() == "private": permission = "private"
            elif line.lower() == "protected": permission = "protected"
            elif line.lower() == "sequence":
                if type(self) == FortranType: self.sequence = True
            elif self.ATTRIB_RE.match(line) and blocklevel == 0:
                match = self.ATTRIB_RE.match(line)
                attr = match.group(1).lower().replace(" ", "")
                if len(attr) >= 4 and attr[0:4].lower() == 'bind':
                    attr = attr.replace(",",", ")
                if hasattr(self,'attr_dict'):
                    if attr == 'data':
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
def is_type(obj,cls):
    return isinstance(obj,FortranType) or issubclass(cls,FortranType)
github Fortran-FOSS-Programmers / ford / ford / graphs.py View on Github external
dot.node(getattr(n[0],'name',n[0]),**gd.get_node(n[0],cls=n[1]).attribs)
    dot.node('This Page\'s Entity')
    mod_svg = dot.pipe().decode('utf-8')

    # Generate key for type graph
    dot = Digraph('Graph Key',graph_attr={'size':'8.90625,1000.0',
                                          'concentrate':'false'},
                              node_attr={'shape':'box',
                                         'height':'0.0',
                                         'margin':'0.08',
                                         'fontname':'Helvetica',
                                         'fontsize':'10.5'},
                              edge_attr={'fontname':'Helvetica',
                                         'fontsize':'9.5'},
                              format='svg', engine='dot')
    dot.node('Type',**gd.get_node('Type',cls=FortranType).attribs)
    dot.node('This Page\'s Entity')
    type_svg = dot.pipe().decode('utf-8')

    # Generate key for call graph
    dot = Digraph('Graph Key',graph_attr={'size':'8.90625,1000.0',
                                          'concentrate':'false'},
                              node_attr={'shape':'box',
                                         'height':'0.0',
                                         'margin':'0.08',
                                         'fontname':'Helvetica',
                                         'fontsize':'10.5'},
                              edge_attr={'fontname':'Helvetica',
                                         'fontsize':'9.5'},
                              format='svg', engine='dot')
    for n in [(sub,FortranSubroutine),(func,FortranFunction),(intr, FortranInterface),('Unknown Procedure Type',FortranFunction),('Program', FortranProgram)]:
        dot.node(getattr(n[0],'name',n[0]),**gd.get_node(n[0],cls=n[1]).attribs)
github Fortran-FOSS-Programmers / ford / ford / sourceform.py View on Github external
permission))
                    self.num_lines += self.subroutines[-1].num_lines - 1
                else:
                    raise Exception("Found SUBROUTINE in {}".format(type(self).__name__[7:].upper()))
            elif self.FUNCTION_RE.match(line):
                if isinstance(self,FortranCodeUnit) and not incontains: continue
                if hasattr(self,'functions'):
                    self.functions.append(FortranFunction(source,
                                          self.FUNCTION_RE.match(line),self,
                                          permission))
                    self.num_lines += self.functions[-1].num_lines - 1
                else:
                    raise Exception("Found FUNCTION in {}".format(type(self).__name__[7:].upper()))
            elif self.TYPE_RE.match(line) and blocklevel == 0:
                if hasattr(self,'types'):
                    self.types.append(FortranType(source,self.TYPE_RE.match(line),
                                      self,permission))
                    self.num_lines += self.types[-1].num_lines - 1
                else:
                    raise Exception("Found derived TYPE in {}".format(type(self).__name__[7:].upper()))
            elif self.INTERFACE_RE.match(line) and blocklevel == 0:
                if hasattr(self,'interfaces'):
                    intr = FortranInterface(source,self.INTERFACE_RE.match(line),
                                            self,permission)
                    self.num_lines += intr.num_lines - 1
                    if intr.abstract:
                        self.absinterfaces.extend(intr.contents)
                    elif intr.generic:
                        self.interfaces.append(intr)
                    else:
                        self.interfaces.extend(intr.contents)
                else: