Ejemplo n.º 1
0
 def testGetFormatted(self):
     param = raw_doc.RawParam(self.txt_name, self.txt_text)
     self.assertEqual(param.getFormatted(self.formatter),
                      '@param name text\n')
     param = raw_doc.RawParam(self.txt_name, self.txt_text, self.tok_inout)
     self.assertEqual(param.getFormatted(self.formatter),
                      '@param[in,out] name text\n')
Ejemplo n.º 2
0
    def processParams(self, entry, node):
        for name, child in node.children.iteritems():
            ts = []
            if child.children.get('summary'):
                for summary in child.children['summary'].texts:
                    ts.append(lexer.Token('WORD', translate(summary), 0, 0, 0))
            if child.children.get('text'):
                for remark in child.children['text'].texts:
                    ts.append(lexer.Token('WORD', remark, 0, 0, 0))
            if child.children.get('tableheader'):
                for line in child.children['tableheader'].texts:
                    ts.append(lexer.Token('WORD', line, 0, 0, 0))
            if child.children.get('table'):
                for line in child.children['table'].texts:
                    ts.append(lexer.Token('WORD', line, 0, 0, 0))
            if child.children.get('remarks'):
                for remark in child.children['remarks'].texts:
                    ts.append(lexer.Token('WORD', remark, 0, 0, 0))
            if child.children.get('remark'):
                for remark in child.children['remark'].texts:
                    ts.append(lexer.Token('WORD', remark, 0, 0, 0))
            if child.children.get('node'):
                for node in child.children['node'].texts:
                    ts.append(lexer.Token('WORD', node, 0, 0, 0))
            if child.children.get('type'):
                if child.children['type'].texts:
                    ts.append(lexer.Token('WORD', ' Types: ', 0, 0, 0))
                    # TODO(holtgrew): Add @link?
                    ts.append(
                        lexer.Token(
                            'WORD',
                            translateTypename(child.children['type'].texts[0]),
                            0, 0, 0))
                for txt in child.children['type'].texts[1:]:
                    # TODO(holtgrew): Add @link?
                    ts.append(
                        lexer.Token('WORD', ', ' + translateTypename(txt), 0,
                                    0, 0))
            if child.children.get('concept'):
                if child.children['concept'].texts:
                    ts.append(lexer.Token('WORD', ' Concepts: ', 0, 0, 0))
                    ts.append(
                        lexer.Token('WORD', child.children['concept'].texts[0],
                                    0, 0, 0))
                for txt in child.children['concept'].texts[1:]:
                    ts.append(lexer.Token('WORD', ', ' + txt, 0, 0, 0))
            if child.children.get('class'):
                if child.children['class'].texts:
                    ts.append(lexer.Token('WORD', ' Classes: ', 0, 0, 0))
                    ts.append(
                        lexer.Token('WORD', child.children['class'].texts[0],
                                    0, 0, 0))
                for txt in child.children['class'].texts[1:]:
                    ts.append(lexer.Token('WORD', ', ' + txt, 0, 0, 0))
            if child.children.get('default'):
                if child.children['default'].texts:
                    ts.append(lexer.Token('WORD', ' Default: ', 0, 0, 0))
                    ts.append(
                        lexer.Token('WORD', child.children['default'].texts[0],
                                    0, 0, 0))
                for txt in child.children['default'].texts[1:]:
                    ts.append(lexer.Token('WORD', ', ' + txt, 0, 0, 0))
            if child.children.get('value'):
                if child.children['value'].texts:
                    ts.append(lexer.Token('WORD', ' Values: ', 0, 0, 0))
                    ts.append(
                        lexer.Token('WORD', child.children['value'].texts[0],
                                    0, 0, 0))
                for txt in child.children['value'].texts[1:]:
                    ts.append(lexer.Token('WORD', ', ' + txt, 0, 0, 0))
            if node.children.get('metafunction'):
                if node.children['metafunction'].texts:
                    ts.append(lexer.Token('WORD', ' Metafunctions: ', 0, 0, 0))
                    ts.append(
                        lexer.Token('WORD',
                                    node.children['metafunction'].texts[0], 0,
                                    0, 0))
                for txt in node.children['metafunction'].texts[1:]:
                    ts.append(lexer.Token('WORD', ', ' + txt, 0, 0, 0))
            if child.children.get('see'):
                if child.children['see'].texts:
                    ts.append(lexer.Token('WORD', ' Sees: ', 0, 0, 0))
                    ts.append(
                        lexer.Token('WORD', child.children['see'].texts[0], 0,
                                    0, 0))
                for txt in child.children['see'].texts[1:]:
                    ts.append(lexer.Token('WORD', ', ' + txt, 0, 0, 0))
            ts = translateTokens(ts)
            raw_text = raw_doc.RawText(ts)
            name_text = raw_doc.RawText([lexer.Token('WORD', name, 0, 0, 0)])
            if hasattr(entry, 'addParam'):
                raw_param = raw_doc.RawParam(name_text, raw_text)
                entry.addParam(raw_param)
            else:
                raw_param = raw_doc.RawTParam(name_text, raw_text)
                entry.addTParam(raw_param)

            # Check that we processed all attributes.
            unhandled = set(child.children.keys()) - set([
                'summary', 'remarks', 'type', 'default', 'text', 'concept',
                'metafunction', 'remark', 'note', 'see', 'class', 'value',
                'nowarn', 'tableheader', 'table'
            ])
            if unhandled:
                print 'Missed %s in %s' % (unhandled, node)
                sys.exit(1)
Ejemplo n.º 3
0
 def testGetType(self):
     param = raw_doc.RawParam(self.txt_name, self.txt_text)
     self.assertEqual(param.getType(), 'param')
Ejemplo n.º 4
0
 def testCreationInOut(self):
     param = raw_doc.RawParam(self.txt_name, self.txt_text, self.tok_inout)
     self.assertEqual(param.name, self.txt_name)
     self.assertEqual(param.text, self.txt_text)
     self.assertEqual(param.inout, self.tok_inout)