Example #1
0
    def load_details_from_element(self, rootelem, xmlpath):
        """Load details for the member from a given XML element.

        This method is called when encountering member definitions while
        processing a compound XML file to load the information for that member.
        It processes common properties for a member, and delegates other
        elements to _load_element().
        """
        if self._loaded:
            # TODO: It would be nice to verify that the same information
            # is present in all instances
            return
        self._xmlpath = xmlpath
        # TODO: Process the attributes
        reporter = self._get_reporter()
        briefelem = None
        detailselem = None
        inbodyelem = None
        for elem in rootelem:
            if elem.tag == 'name':
                if elem.text != self.get_name():
                    reporter.xml_assert(
                        xmlpath,
                        "member name mismatch: '{0}' (in index.xml) vs. '{1}'".
                        format(self.get_name(), elem.text))
            elif elem.tag == 'briefdescription':
                briefelem = elem
            elif elem.tag == 'detaileddescription':
                detailselem = elem
            elif elem.tag == 'inbodydescription':
                # TODO: in-body description is probably only possible for
                # functions; move it there.
                inbodyelem = elem
            elif elem.tag == 'location':
                self._location = LocationWithBody(elem)
            else:
                if not self._load_element(elem):
                    # TODO Process the rest of the elements so that we can check this
                    #reporter.xml_assert(xmlpath,
                    #        "unknown member child element '{0}'".format(elem.tag))
                    pass
        self._process_descriptions(briefelem, detailselem, inbodyelem)
        self._loaded = True
Example #2
0
    def load_details_from_element(self, rootelem, xmlpath):
        """Load details for the member from a given XML element.

        This method is called when encountering member definitions while
        processing a compound XML file to load the information for that member.
        It processes common properties for a member, and delegates other
        elements to _load_element().
        """
        if self._loaded:
            # TODO: It would be nice to verify that the same information
            # is present in all instances
            return
        self._xmlpath = xmlpath
        # TODO: Process the attributes
        reporter = self._get_reporter()
        briefelem = None
        detailselem = None
        inbodyelem = None
        for elem in rootelem:
            if elem.tag == 'name':
                if elem.text != self.get_name():
                    reporter.xml_assert(xmlpath,
                            "member name mismatch: '{0}' (in index.xml) vs. '{1}'".format(
                                self.get_name(), elem.text))
            elif elem.tag == 'briefdescription':
                briefelem = elem
            elif elem.tag == 'detaileddescription':
                detailselem = elem
            elif elem.tag == 'inbodydescription':
                # TODO: in-body description is probably only possible for
                # functions; move it there.
                inbodyelem = elem
            elif elem.tag == 'location':
                self._location = LocationWithBody(elem)
            else:
                if not self._load_element(elem):
                    # TODO Process the rest of the elements so that we can check this
                    #reporter.xml_assert(xmlpath,
                    #        "unknown member child element '{0}'".format(elem.tag))
                    pass
        self._process_descriptions(briefelem, detailselem, inbodyelem)
        self._loaded = True
Example #3
0
 def __init__(self, xmlroot, reporter):
     """Initialize the documentation set and read index data."""
     self._xmlroot = xmlroot
     self._reporter = reporter
     xmlpath = os.path.join(xmlroot, 'index.xml')
     indextree = ET.parse(xmlpath)
     self._compounds = dict()
     self._members = dict()
     self._files = dict()
     for compoundelem in indextree.getroot():
         name = compoundelem.find('name').text
         refid = compoundelem.attrib['refid']
         kind = compoundelem.attrib['kind']
         if kind in ('page', 'example'):
             # TODO: Model these types as well
             continue
         compoundtype = _get_compound_type_from_kind(kind)
         if compoundtype is None:
             reporter.xml_assert(xmlpath,
                                 "unknown compound kind '{0}'".format(kind))
             continue
         compound = compoundtype(name, refid)
         compound.set_documentation_set(self)
         self._compounds[refid] = compound
         for memberelem in compoundelem.iter('member'):
             name = memberelem.find('name').text
             refid = memberelem.attrib['refid']
             kind = memberelem.attrib['kind']
             if refid in self._members:
                 member = self._members[refid]
                 membertype = _get_member_type_from_kind(kind)
                 if not isinstance(member, membertype):
                     reporter.xml_assert(
                         xmlpath,
                         "id '{0}' used for multiple kinds of members".
                         format(refid))
                     continue
             else:
                 membertype = _get_member_type_from_kind(kind)
                 if membertype is None:
                     reporter.xml_assert(
                         xmlpath, "unknown member kind '{0}'".format(kind))
                     continue
                 member = membertype(name, refid)
                 member.set_documentation_set(self)
                 self._members[refid] = member
             member.add_parent_compound(compound)
             compound.add_member(member)
Example #4
0
 def __init__(self, xmlroot, reporter):
     """Initialize the documentation set and read index data."""
     self._xmlroot = xmlroot
     self._reporter = reporter
     xmlpath = os.path.join(xmlroot, 'index.xml')
     indextree = ET.parse(xmlpath)
     self._compounds = dict()
     self._members = dict()
     self._files = dict()
     for compoundelem in indextree.getroot():
         name = compoundelem.find('name').text
         refid = compoundelem.attrib['refid']
         kind = compoundelem.attrib['kind']
         if kind in ('page', 'example'):
             # TODO: Model these types as well
             continue
         compoundtype = _get_compound_type_from_kind(kind)
         if compoundtype is None:
             reporter.xml_assert(xmlpath,
                     "unknown compound kind '{0}'".format(kind))
             continue
         compound = compoundtype(name, refid)
         compound.set_documentation_set(self)
         self._compounds[refid] = compound
         for memberelem in compoundelem.iter('member'):
             name = memberelem.find('name').text
             refid = memberelem.attrib['refid']
             kind = memberelem.attrib['kind']
             if refid in self._members:
                 member = self._members[refid]
                 membertype = _get_member_type_from_kind(kind)
                 if not isinstance(member, membertype):
                     reporter.xml_assert(xmlpath,
                             "id '{0}' used for multiple kinds of members"
                             .format(refid))
                     continue
             else:
                 membertype = _get_member_type_from_kind(kind)
                 if membertype is None:
                     reporter.xml_assert(xmlpath,
                             "unknown member kind '{0}'".format(kind))
                     continue
                 member = membertype(name, refid)
                 member.set_documentation_set(self)
                 self._members[refid] = member
             member.add_parent_compound(compound)
             compound.add_member(member)
Example #5
0
 def _unexpected_inner_compound(self, typename, compound):
     """Report a parsing error for an unexpected inner compound reference."""
     reporter = self._get_reporter()
     xmlpath = self._get_xml_path()
     reporter.xml_assert(
         xmlpath, "unexpected inner {0}: {1}".format(typename, compound))
Example #6
0
    def load_details(self):
        """Load details for the compound from its details XML file.

        This method processes common properties for a compound.
        References to inner compounds are delegated to _load_inner_*() methods,
        and all members encountered in the XML file are loaded with
        Member.load_details_from_element().
        Other elements are delegated to _load_element().
        """
        if self._loaded:
            return
        reporter = self._get_reporter()
        xmlpath = self._get_xml_path()
        compoundtree = ET.parse(xmlpath)
        root = compoundtree.getroot()
        if len(root) > 1:
            reporter.xml_assert(xmlpath, "more than one compound in a file")
        if root[0].tag != 'compounddef':
            reporter.xml_assert(xmlpath,
                                "expected <compounddef> as the first tag")
            return
        briefelem = None
        detailselem = None
        missing_members = set(self._members.values())
        for elem in root[0]:
            if elem.tag == 'compoundname':
                if elem.text != self.get_name():
                    reporter.xml_assert(
                        xmlpath,
                        "compound name mismatch: '{0}' (in index.xml) vs. '{1}'"
                        .format(self.get_name(), elem.text))
            elif elem.tag == 'briefdescription':
                briefelem = elem
            elif elem.tag == 'detaileddescription':
                detailselem = elem
            elif elem.tag in ('includes', 'includedby', 'incdepgraph',
                              'invincdepgraph', 'inheritancegraph',
                              'collaborationgraph', 'programlisting',
                              'templateparamlist', 'listofallmembers'):
                pass
            elif elem.tag.startswith('inner'):
                refid = elem.attrib['refid']
                reftype = elem.tag[5:]
                # TODO: Handle 'prot' attribute?
                refcompound = self._docset.get_compound(refid)
                self._children.add(refcompound)
                if reftype == 'file':
                    self._load_inner_file(refcompound)
                elif reftype == 'dir':
                    self._load_inner_dir(refcompound)
                elif reftype == 'group':
                    self._load_inner_group(refcompound)
                elif reftype == 'namespace':
                    self._load_inner_namespace(refcompound)
                elif reftype == 'class':
                    self._load_inner_class(refcompound)
                else:
                    reporter.xml_assert(
                        xmlpath,
                        "unknown inner compound type '{0}'".format(reftype))
            elif elem.tag == 'sectiondef':
                # TODO: Handle header and description elements
                kind = elem.attrib['kind']
                section = MemberSection(kind)
                self._sections.append(section)
                for memberelem in elem.iter('memberdef'):
                    refid = memberelem.attrib['id']
                    member = self._members[refid]
                    member.load_details_from_element(memberelem, xmlpath)
                    section.add_member(member)
                    if member in missing_members:
                        missing_members.remove(member)
                    # Enum values need special handling, but are not worth
                    # extra generalization.
                    if isinstance(member, Enum):
                        missing_members.difference_update(member.get_values())
            else:
                if not self._load_element(elem):
                    reporter.xml_assert(
                        xmlpath, "unknown compound child element '{0}'".format(
                            elem.tag))
        if missing_members:
            reporter.xml_assert(xmlpath, 'members without section')
        self._process_descriptions(briefelem, detailselem, None)
        self._loaded = True
Example #7
0
 def _unexpected_inner_compound(self, typename, compound):
     """Report a parsing error for an unexpected inner compound reference."""
     reporter = self._get_reporter()
     xmlpath = self._get_xml_path()
     reporter.xml_assert(xmlpath,
             "unexpected inner {0}: {1}".format(typename, compound))
Example #8
0
    def load_details(self):
        """Load details for the compound from its details XML file.

        This method processes common properties for a compound.
        References to inner compounds are delegated to _load_inner_*() methods,
        and all members encountered in the XML file are loaded with
        Member.load_details_from_element().
        Other elements are delegated to _load_element().
        """
        if self._loaded:
            return
        reporter = self._get_reporter()
        xmlpath = self._get_xml_path()
        compoundtree = ET.parse(xmlpath)
        root = compoundtree.getroot()
        if len(root) > 1:
            reporter.xml_assert(xmlpath, "more than one compound in a file")
        if root[0].tag != 'compounddef':
            reporter.xml_assert(xmlpath, "expected <compounddef> as the first tag")
            return
        briefelem = None
        detailselem = None
        missing_members = set(self._members.values())
        for elem in root[0]:
            if elem.tag == 'compoundname':
                if elem.text != self.get_name():
                    reporter.xml_assert(xmlpath,
                            "compound name mismatch: '{0}' (in index.xml) vs. '{1}'"
                            .format(self.get_name(), elem.text))
            elif elem.tag == 'briefdescription':
                briefelem = elem
            elif elem.tag == 'detaileddescription':
                detailselem = elem
            elif elem.tag in ('includes', 'includedby', 'incdepgraph',
                    'invincdepgraph', 'inheritancegraph', 'collaborationgraph',
                    'programlisting', 'templateparamlist', 'listofallmembers'):
                pass
            elif elem.tag.startswith('inner'):
                refid = elem.attrib['refid']
                reftype = elem.tag[5:]
                # TODO: Handle 'prot' attribute?
                refcompound = self._docset.get_compound(refid)
                self._children.add(refcompound)
                if reftype == 'file':
                    self._load_inner_file(refcompound)
                elif reftype == 'dir':
                    self._load_inner_dir(refcompound)
                elif reftype == 'group':
                    self._load_inner_group(refcompound)
                elif reftype == 'namespace':
                    self._load_inner_namespace(refcompound)
                elif reftype == 'class':
                    self._load_inner_class(refcompound)
                else:
                    reporter.xml_assert(xmlpath,
                            "unknown inner compound type '{0}'".format(reftype))
            elif elem.tag == 'sectiondef':
                # TODO: Handle header and description elements
                kind = elem.attrib['kind']
                section = MemberSection(kind)
                self._sections.append(section)
                for memberelem in elem.iter('memberdef'):
                    refid = memberelem.attrib['id']
                    member = self._members[refid]
                    member.load_details_from_element(memberelem, xmlpath)
                    section.add_member(member)
                    if member in missing_members:
                        missing_members.remove(member)
                    # Enum values need special handling, but are not worth
                    # extra generalization.
                    if isinstance(member, Enum):
                        missing_members.difference_update(member.get_values())
            else:
                if not self._load_element(elem):
                    reporter.xml_assert(xmlpath,
                            "unknown compound child element '{0}'".format(elem.tag))
        if missing_members:
            reporter.xml_assert(xmlpath, 'members without section')
        self._process_descriptions(briefelem, detailselem, None)
        self._loaded = True