Exemple #1
0
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        if is_exception(obj.node):
            label = r'\fb\f09%s\fn' % obj.title
        else:
            label = r'\fb%s\fn' % obj.title
        if obj.shape == 'interface':
            shape = 'ellipse'
        else:
            shape = 'box'
        if not self.config.only_classnames:
            attrs = obj.attrs
            methods = [func.name for func in obj.methods]
            # box width for UML like diagram
            maxlen = max(len(name) for name in [obj.title] + methods + attrs)
            line = '_' * (maxlen + 2)
            label = r'%s\n\f%s' % (label, line)
            for attr in attrs:
                label = r'%s\n\f08%s' % (label, attr)
            if attrs:
                label = r'%s\n\f%s' % (label, line)
            for func in methods:
                label = r'%s\n\f10%s()' % (label, func)
        return dict(label=label, shape=shape)
Exemple #2
0
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        if is_exception(obj.node):
            label = r'\fb\f09%s\fn' % obj.title
        else:
            label = r'\fb%s\fn' % obj.title
        if obj.shape == 'interface':
            shape = 'ellipse'
        else:
            shape = 'box'
        if not self.config.only_classnames:
            attrs = obj.attrs
            methods = [func.name for func in obj.methods]
            # box width for UML like diagram
            maxlen = max(len(name) for name in [obj.title] + methods + attrs)
            line = '_' * (maxlen + 2)
            label = r'%s\n\f%s' % (label, line)
            for attr in attrs:
                label = r'%s\n\f08%s' % (label, attr)
            if attrs:
                label = r'%s\n\f%s' % (label, line)
            for func in methods:
                label = r'%s\n\f10%s()' % (label, func)
        return dict(label=label, shape=shape)
Exemple #3
0
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        if is_exception(obj.node):
            label = r"\fb\f09%s\fn" % obj.title
        else:
            label = r"\fb%s\fn" % obj.title
        if obj.shape == "interface":
            shape = "ellipse"
        else:
            shape = "box"
        if not self.config.only_classnames:
            attrs = obj.attrs
            methods = [func.name for func in obj.methods]
            # box width for UML like diagram
            maxlen = max(len(name) for name in [obj.title] + methods + attrs)
            line = "_" * (maxlen + 2)
            label = fr"{label}\n\f{line}"
            for attr in attrs:
                label = fr"{label}\n\f08{attr}"
            if attrs:
                label = fr"{label}\n\f{line}"
            for func in methods:
                label = fr"{label}\n\f10{func}()"
        return dict(label=label, shape=shape)
Exemple #4
0
 def get_class_properties(self, obj: ClassEntity) -> NodeProperties:
     """Get label and shape for classes."""
     properties = NodeProperties(
         label=obj.title,
         attrs=obj.attrs if not self.config.only_classnames else None,
         methods=obj.methods if not self.config.only_classnames else None,
         fontcolor="red" if is_exception(obj.node) else "black",
         color=self.get_shape_color(obj)
         if self.config.colorized else "black",
     )
     return properties
Exemple #5
0
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        label = obj.title
        if obj.shape == 'interface':
            label = u'«interface»\\n%s' % label
        if not self.config.only_classnames:
            label = r'%s|%s\l|' % (label, r'\l'.join(obj.attrs))
            for func in obj.methods:
                label = r'%s%s()\l' % (label, func.name)
            label = '{%s}' % label
        if is_exception(obj.node):
            return dict(fontcolor='red', label=label, shape='record')
        return dict(label=label, shape='record')
Exemple #6
0
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        label = obj.title
        if obj.shape == 'interface':
            label = u'«interface»\\n%s' % label
        if not self.config.only_classnames:
            label = r'%s|%s\l|' % (label, r'\l'.join(obj.attrs))
            for func in obj.methods:
                label = r'%s%s()\l' % (label, func.name)
            label = '{%s}' % label
        if is_exception(obj.node):
            return dict(fontcolor='red', label=label, shape='record')
        return dict(label=label, shape='record')
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        label = obj.title
        if obj.shape == "interface":
            label = "«interface»\\n%s" % label
        if not self.config.only_classnames:
            label = r"%s|%s\l|" % (label, r"\l".join(obj.attrs))
            for func in obj.methods:
                label = r"%s%s()\l" % (label, func.name)
            label = "{%s}" % label
        if is_exception(obj.node):
            return dict(fontcolor="red", label=label, shape="record")
        return dict(label=label, shape="record")
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        label = obj.title
        if obj.shape == "interface":
            label = "«interface»\\n%s" % label
        if not self.config.only_classnames:
            label = r"%s|%s\l|" % (label, r"\l".join(obj.attrs))
            for func in obj.methods:
                label = r"%s%s()\l" % (label, func.name)
            label = "{%s}" % label
        if is_exception(obj.node):
            return dict(fontcolor="red", label=label, shape="record")
        return dict(label=label, shape="record")
Exemple #9
0
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        label = obj.title
        if obj.shape == "interface":
            label = "«interface»\\n%s" % label
        if not self.config.only_classnames:
            label = r"{}|{}\l|".format(label, r"\l".join(obj.attrs))
            for func in obj.methods:
                if func.args.args:
                    args = [arg.name for arg in func.args.args if arg.name != "self"]
                else:
                    args = []
                label = r"{}{}({})\l".format(label, func.name, ", ".join(args))
            label = "{%s}" % label
        if is_exception(obj.node):
            return dict(fontcolor="red", label=label, shape="record")
        return dict(label=label, shape="record")
    def get_values(self, obj):
        """get label and shape for classes.

        The label contains all attributes and methods
        """
        label = obj.title
        if obj.shape == "interface":
            label = "«interface»\\n%s" % label
        if not self.config.only_classnames:
            label = r"{}|{}\l|".format(label, r"\l".join(obj.attrs))
            for func in obj.methods:
                return_type = (
                    f": {get_annotation_label(func.returns)}" if func.returns else ""
                )

                if func.args.args:
                    args = [arg for arg in func.args.args if arg.name != "self"]
                else:
                    args = []

                annotations = dict(zip(args, func.args.annotations[1:]))
                for arg in args:
                    annotation_label = ""
                    ann = annotations.get(arg)
                    if ann:
                        annotation_label = get_annotation_label(ann)
                    annotations[arg] = annotation_label

                args = ", ".join(
                    f"{arg.name}: {ann}" if ann else f"{arg.name}"
                    for arg, ann in annotations.items()
                )

                label = fr"{label}{func.name}({args}){return_type}\l"
            label = "{%s}" % label
        if is_exception(obj.node):
            return dict(fontcolor="red", label=label, shape="record")
        return dict(label=label, shape="record")