Example #1
0
def parse_groups(path: str, root: Node):
    remov_from_root = []
    for child in root.members:
        if child.kind == Kind.GROUP:
            remov_from_root.extend(check_innergroups(path, root, child))

    root.members[:] = filterfalse(lambda x: x in remov_from_root, root.members)
Example #2
0
def generate_breadcrubs(node: Node):
    ret = []

    breadcrubs = []
    parent = node.parent
    while parent != None:
        #ret.append(MdLink([Text(parent.name)], parent.generate_url()))
        #ret.append(Text(' > '))
        breadcrubs.append(parent)
        parent = parent.parent

    is_first = True
    for parent in reversed(breadcrubs):
        if parent.kind == Kind.ROOT:
            ret.append(MdLink([MdBold([Text('Class List')])], 'annotated.md'))
        else:
            ret.append(MdLink([MdBold([Text(parent.name)])], parent.generate_url()))
        ret.append(Text(' '))
        if is_first:
            is_first = False
            ret.append(MdBold([Text('>')]))
        else:
            ret.append(MdBold([Text('::')]))
        ret.append(Text(' '))

    ret.append(MdLink([MdBold([Text(node.name)])], node.generate_url()))
    ret.append(Br())
    return MdParagraph(ret)
Example #3
0
def parseRoot(root: xml.etree.ElementTree):
    parent = Node('root', 'root', Kind.ROOT)
    for compound in root.iter('compound'):
        child = Node(
            compound.find('name').text, compound.get('refid'),
            Kind(compound.get('kind')))
        parent.addMember(child)
        for member in compound.findall('member'):
            subchild = Node(
                member.find('name').text, member.get('refid'),
                Kind(member.get('kind')))
            child.addMember(subchild)
    return parent
Example #4
0
def reparseRoot(rootNode: Node, newRoot: Node):
    while len(rootNode.members) > 0:
        child = rootNode.members[0]
        if isKindLanguage(child.kind):
            newChild = reparseChildren(child, rootNode, newRoot)
            lastEnum = None
            for subchild in child.members:
                if subchild.kind == Kind.ENUMVALUE:
                    lastEnum.addMember(subchild)
                    continue
                else:
                    newChild.addMember(subchild)

                if subchild.kind == Kind.ENUM:
                    lastEnum = subchild
        else:
            newRoot.addMember(child)
        rootNode.members.pop(0)
Example #5
0
def reparse_root(root_node: Node, new_root: Node):
    while len(root_node.members) > 0:
        child = root_node.members[0]
        if child.kind.is_language():
            new_child = reparse_children(child, root_node, new_root)
            last_enum = None
            for subchild in child.members:
                if subchild.kind == Kind.ENUMVALUE:
                    last_enum.add_member(subchild)
                    continue
                else:
                    new_child.add_member(subchild)

                if subchild.kind == Kind.ENUM:
                    last_enum = subchild
        else:
            new_root.add_member(child)
        root_node.members.pop(0)
Example #6
0
def loadRoot(cache: Cache, dirPath: str, debug: bool) -> Node:
    print("XML index from: " + dirPath)
    e = xml.etree.ElementTree.parse(os.path.join(dirPath,
                                                 'index.xml')).getroot()

    outNode = Node('root', 'root', Kind.ROOT)

    rootNode = parseRoot(e)
    reparseRoot(rootNode, outNode)
    finalize(cache, outNode)

    if debug:
        debugNode(outNode)
    return outNode
Example #7
0
def load_root(cache: Cache, path: str) -> Node:
    print("XML index from: " + path)
    e = xml.etree.ElementTree.parse(os.path.join(path, 'index.xml')).getroot()

    out_node = Node('Global', 'root', Kind.ROOT)

    root_node = parse_root(e)
    reparse_root(root_node, out_node)
    parse_groups(path, out_node)
    check_for_overloads(out_node)
    finalize(cache, out_node)

    if config.debug:
        debug_node(out_node)
    return out_node
Example #8
0
def reparseChildren(child: Node, root: Node, output: Node):
    tokens = tokenize(child.name, '::')
    if len(tokens) < 1:
        return

    i = 0
    while i < len(tokens):
        outFound = output.findMember(tokens[i])
        if outFound == None:
            addedNode = Node(tokens[i], None, Kind('variable'))
            output.addMember(addedNode)
            output = addedNode
        else:
            output = outFound

        i += 1

    output.kind = child.kind
    output.refid = child.refid
    return output
Example #9
0
def finalize(cache: Cache, node: Node):
    node.finalize()
    cache.add(node.refid, node)
    node.members = sorted(node.members, key=lambda k: k.name)
    for child in node.members:
        finalize(cache, child)
Example #10
0
    def __init__(self,
                 index_path: str,
                 parser: XmlParser,
                 cache: Cache,
                 options: dict = {}):
        path = os.path.join(index_path, 'index.xml')
        print('Loading XML from: ' + path)
        xml = ElementTree.parse(path).getroot()

        self.parser = parser
        self.cache = cache
        self._options = options
        self.root = Node('root',
                         None,
                         self.cache,
                         self.parser,
                         None,
                         options=self._options)
        self.groups = Node('root',
                           None,
                           self.cache,
                           self.parser,
                           None,
                           options=self._options)
        self.files = Node('root',
                          None,
                          self.cache,
                          self.parser,
                          None,
                          options=self._options)
        self.pages = Node('root',
                          None,
                          self.cache,
                          self.parser,
                          None,
                          options=self._options)

        for compound in xml.findall('compound'):
            kind = Kind.from_str(compound.get('kind'))
            refid = compound.get('refid')
            if kind.is_language():
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.root.add_child(node)
            if kind == Kind.GROUP:
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.groups.add_child(node)
            if kind == Kind.FILE or kind == Kind.DIR:
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.files.add_child(node)
            if kind == Kind.PAGE:
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.pages.add_child(node)

        print('Deduplicating data... (may take a minute!)')
        for i, child in enumerate(self.root.children.copy()):
            self._fix_duplicates(child, self.root, [])

        for i, child in enumerate(self.groups.children.copy()):
            self._fix_duplicates(child, self.groups, [Kind.GROUP])

        for i, child in enumerate(self.files.children.copy()):
            self._fix_duplicates(child, self.files, [Kind.FILE, Kind.DIR])

        self._fix_parents(self.files)

        print('Sorting...')
        self._recursive_sort(self.root)
        self._recursive_sort(self.groups)
        self._recursive_sort(self.files)
        self._recursive_sort(self.pages)
Example #11
0
class Doxygen:
    def __init__(self,
                 index_path: str,
                 parser: XmlParser,
                 cache: Cache,
                 options: dict = {}):
        path = os.path.join(index_path, 'index.xml')
        print('Loading XML from: ' + path)
        xml = ElementTree.parse(path).getroot()

        self.parser = parser
        self.cache = cache
        self._options = options
        self.root = Node('root',
                         None,
                         self.cache,
                         self.parser,
                         None,
                         options=self._options)
        self.groups = Node('root',
                           None,
                           self.cache,
                           self.parser,
                           None,
                           options=self._options)
        self.files = Node('root',
                          None,
                          self.cache,
                          self.parser,
                          None,
                          options=self._options)
        self.pages = Node('root',
                          None,
                          self.cache,
                          self.parser,
                          None,
                          options=self._options)

        for compound in xml.findall('compound'):
            kind = Kind.from_str(compound.get('kind'))
            refid = compound.get('refid')
            if kind.is_language():
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.root.add_child(node)
            if kind == Kind.GROUP:
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.groups.add_child(node)
            if kind == Kind.FILE or kind == Kind.DIR:
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.files.add_child(node)
            if kind == Kind.PAGE:
                node = Node(os.path.join(index_path, refid + '.xml'),
                            None,
                            self.cache,
                            self.parser,
                            self.root,
                            options=self._options)
                node._visibility = Visibility.PUBLIC
                self.pages.add_child(node)

        print('Deduplicating data... (may take a minute!)')
        for i, child in enumerate(self.root.children.copy()):
            self._fix_duplicates(child, self.root, [])

        for i, child in enumerate(self.groups.children.copy()):
            self._fix_duplicates(child, self.groups, [Kind.GROUP])

        for i, child in enumerate(self.files.children.copy()):
            self._fix_duplicates(child, self.files, [Kind.FILE, Kind.DIR])

        self._fix_parents(self.files)

        print('Sorting...')
        self._recursive_sort(self.root)
        self._recursive_sort(self.groups)
        self._recursive_sort(self.files)
        self._recursive_sort(self.pages)

    def _fix_parents(self, node: Node):
        if node.is_dir or node.is_root:
            for child in node.children:
                if child.is_file:
                    child._parent = node
                if child.is_dir:
                    self._fix_parents(child)

    def _recursive_sort(self, node: Node):
        node.sort_children()
        for child in node.children:
            self._recursive_sort(child)

    def _is_in_root(self, node: Node, root: Node):
        for child in root.children:
            if node.refid == child.refid:
                return True
        return False

    def _remove_from_root(self, refid: str, root: Node):
        for i, child in enumerate(root.children):
            if child.refid == refid:
                root.children.pop(i)
                return

    def _fix_duplicates(self, node: Node, root: Node, filter: [Kind]):
        for child in node.children:
            if len(filter) > 0 and child.kind not in filter:
                continue
            if self._is_in_root(child, root):
                self._remove_from_root(child.refid, root)
            self._fix_duplicates(child, root, filter)

    def print(self):
        for node in self.root.children:
            self.print_node(node, '')
        for node in self.groups.children:
            self.print_node(node, '')
        for node in self.files.children:
            self.print_node(node, '')

    def print_node(self, node: Node, indent: str):
        print(indent, node.kind, node.name)
        for child in node.children:
            self.print_node(child, indent + '  ')
Example #12
0
 def _recursive_sort(self, node: Node):
     node.sort_children()
     for child in node.children:
         self._recursive_sort(child)