def __init__(self, object_desc, spec_name, number, package, pkg_ref):
        # members from object
        self.name = object_desc['name']
        self.fullname = spec_name
        self.number = number
        self.package = package.lower()
        self.pkg_ref = pkg_ref

        # useful repeated text strings
        self.valid = '\\validRule{'
        self.start_b = '{'
        self.end_b = '}'

        self.formatted_name = '\{}'.format(object_desc['name'])
        self.indef = strFunctions.get_indefinite(object_desc['name'])
        self.indef_u = strFunctions.upper_first(self.indef)

        self.reqd_att = []
        self.opt_att = []
        self.reqd_elem = []
        self.opt_elem = []
        self.reqd_child_lo_elem = []
        self.opt_child_lo_elem = []

        self.parse_attributes(self, object_desc['attribs'])
        self.rules = []
    def write_body_for_extended_class(self, plugin):
        extended_object = plugin['sbase']
        ex_objects = []
        for i in range(0, len(plugin['extension'])):
            name = plugin['extension'][i]['name']
            indef = strFunctions.get_indefinite(name)
            ex_objects.append('{} \\{} object'.format(indef, name))
        for i in range(0, len(plugin['lo_extension'])):
            name = plugin['lo_extension'][i]['listOfClassName']
            ex_objects.append('a \\{} object'.format(name))
        if len(plugin['attribs']) > 0:
            ex_objects.append('the following attributes.')
        # section heading
        self.write_comment_line('---------------------------------------------'
                                '------------')
        self.write_line('\subsection{0}The extended \class{0}{1}{2} class{2}'
                        .format(self.start_b, plugin['sbase'], self.end_b))
        self.write_line('\\label{}{}{}'
                        .format(self.start_b,
                                strFunctions.make_class(plugin['sbase']),
                                self.end_b))
        self.skip_line()
        self.write_to_do('explain where {} comes from'.format(extended_object))

        self.write_line('The {} extends the \\class{}{}{} object '
                        'with the addition of '
                        .format(self.full_pkg_command, self.start_b,
                                extended_object, self.end_b))
        num_additions = len(ex_objects)
        if num_additions > 1:
            self.write_line('{}'.format(ex_objects[0]))
            for i in range(1, num_additions-1):
                self.write_line(', {}'.format(ex_objects[i]))
            self.write_line(' and {}.'.format(ex_objects[num_additions-1]))
        elif num_additions == 1:
            self.write_line('{}.'.format(ex_objects[0]))
        self.skip_line()

        for i in range(0, len(plugin['attribs'])):
            self.write_attibute_paragraph(plugin['attribs'][i],
                                          extended_object)

        # write body for child elements
        for i in range(0, len(plugin['extension'])):
            child = self.get_class(plugin['extension'][i]['name'])
            self.write_body_for_class(child)

        for i in range(0, len(plugin['lo_extension'])):
            child = self.get_class(plugin['lo_extension'][i]['name'])
            self.write_body_for_lo_class(child)
    def write_child_element(self, attrib, name):
        if attrib['type'] == 'element':
            if self.derives_from_other_ns(attrib['element']):
                child_name = '\\class{' + attrib['element'] + '}'
            else:
                child_name = '\\' + attrib['element']
        elif attrib['type'] == 'lo_element':
            child_name = '\\' + strFunctions.cap_list_of_name(attrib['name'])
        elif attrib['type'] == 'inline_lo_element':
            child_name = '\\' + strFunctions.cap_list_of_name(attrib['name'])
        else:
            return

        # hack for render
        if child_name == '\\RelAbsVector':
            return

        self.write_line('{} \{} contains {} {} element.'
                        .format(strFunctions.get_indefinite(name).
                                capitalize(), name,
                                'at most one' if attrib['reqd'] is True
                                else 'exactly one', child_name))
 def write_attibute_paragraph(self, attrib, name):
     att_name = attrib['texname']
     if attrib['type'] == 'lo_element' \
             or attrib['type'] == 'inline_lo_element':
         return
     elif attrib['type'] == 'element' \
             and attrib['element'] != 'RelAbsVector':
         return
     else:
         self.write_line('\paragraph{0}The \\fixttspace\\token{0}{1}{2} '
                         'attribute{2}'.format(self.start_b, att_name,
                                               self.end_b))
         self.skip_line()
         self.write_line('{} \{} has {} attribute {} {}.'
                         .format(strFunctions.get_indefinite(name).
                                 capitalize(),
                                 name,
                                 'a required' if attrib['reqd'] is True
                                 else 'an optional',
                                 strFunctions.wrap_token(att_name),
                                 strFunctions.wrap_type(attrib['type'],
                                                        attrib['element'],
                                                        True)))
     self.skip_line()