コード例 #1
0
ファイル: generic_parser.py プロジェクト: bartdag/recodoc2
    def _add_code_ref(self, index, code_ref_element, page, load,
            s_code_references):
        text = self.xcoderef.get_text(code_ref_element)
        text = clean_breaks(text).strip()

        # Not significant
        if len(text) < 2 or text.isdigit():
            return

        text_context = get_text_context(code_ref_element)
        sentence = get_sentence(code_ref_element, text, text_context)

        (text, kind_hint) = self._get_code_ref_kind(code_ref_element, text)

        xpath = load.tree.getpath(code_ref_element)
        for code in parse_single_code_references(text, kind_hint,
                self.kind_strategies, self.kinds):
            code.xpath = xpath
            code.file_path = page.file_path
            code.source = DOCUMENT_SOURCE
            code.index = index
            code.sentence = sentence
            code.paragraph = text_context
            code.project = self.document.project_release.project
            code.project_release = self.document.project_release
            code.save()
            s_code_references.append(code)
コード例 #2
0
    def _add_code_ref(self, index, code_ref_element, page, load,
                      s_code_references):
        text = self.xcoderef.get_text(code_ref_element)
        text = clean_breaks(text).strip()

        # Not significant
        if len(text) < 2 or text.isdigit():
            return

        text_context = get_text_context(code_ref_element)
        sentence = get_sentence(code_ref_element, text, text_context)

        (text, kind_hint) = self._get_code_ref_kind(code_ref_element, text)

        xpath = load.tree.getpath(code_ref_element)
        for code in parse_single_code_references(text, kind_hint,
                                                 self.kind_strategies,
                                                 self.kinds):
            code.xpath = xpath
            code.file_path = page.file_path
            code.source = DOCUMENT_SOURCE
            code.index = index
            code.sentence = sentence
            code.paragraph = text_context
            code.project = self.document.project_release.project
            code.project_release = self.document.project_release
            code.save()
            s_code_references.append(code)
コード例 #3
0
    def test_text(self):
        text = r'''
        The class FooBar and Boo is useful to call method m1("hello").
        You should know that FooBar.CONSTANT is fun, but @Bar and buz().baz(1)
        does not equal com.Baz.m2("", null).m3(CONST);
        '''
        text = su.clean_breaks(text).strip()
        refs = psc(text,
                   self.kinds['unknown'],
                   self.strategies,
                   self.kinds,
                   save_index=True)
        self.assertEqual(11, len(refs))

        self.assertEqual('FooBar', refs[0].content)
        self.assertEqual('class', refs[0].kind_hint.kind)
        self.assertEqual(0, refs[0].index)

        self.assertEqual('Boo', refs[1].content)
        self.assertEqual('class', refs[1].kind_hint.kind)
        self.assertEqual(1, refs[1].index)

        self.assertEqual('m1("hello")', refs[2].content)
        self.assertEqual('method', refs[2].kind_hint.kind)
        self.assertEqual(2, refs[2].index)

        self.assertEqual('FooBar.CONSTANT', refs[3].content)
        self.assertEqual('class', refs[3].kind_hint.kind)
        self.assertEqual(3, refs[3].index)

        self.assertEqual('FooBar.CONSTANT', refs[4].content)
        self.assertEqual('field', refs[4].kind_hint.kind)
        self.assertEqual(3, refs[4].index)

        self.assertEqual('@Bar', refs[5].content)
        self.assertEqual('annotation', refs[5].kind_hint.kind)
        self.assertEqual(4, refs[5].index)

        self.assertEqual('buz().baz(1)', refs[6].content)
        self.assertEqual('method', refs[6].kind_hint.kind)
        self.assertEqual(5, refs[6].index)

        self.assertEqual('baz(1)', refs[7].content)
        self.assertEqual('method', refs[7].kind_hint.kind)
        self.assertEqual(5, refs[7].index)

        self.assertEqual('com.Baz.m2("", null).m3(CONST);', refs[8].content)
        self.assertEqual('class', refs[8].kind_hint.kind)
        self.assertEqual(6, refs[8].index)

        self.assertEqual('com.Baz.m2("", null).m3(CONST);', refs[9].content)
        self.assertEqual('method', refs[9].kind_hint.kind)
        self.assertEqual(6, refs[9].index)

        self.assertEqual('m3(CONST);', refs[10].content)
        self.assertEqual('method', refs[10].kind_hint.kind)
        self.assertEqual(6, refs[10].index)
コード例 #4
0
    def test_text(self):
        text = r'''
        The class FooBar and Boo is useful to call method m1("hello").
        You should know that FooBar.CONSTANT is fun, but @Bar and buz().baz(1)
        does not equal com.Baz.m2("", null).m3(CONST);
        '''
        text = su.clean_breaks(text).strip()
        refs = psc(text, self.kinds['unknown'], self.strategies, self.kinds,
                save_index=True)
        self.assertEqual(11, len(refs))

        self.assertEqual('FooBar', refs[0].content)
        self.assertEqual('class', refs[0].kind_hint.kind)
        self.assertEqual(0, refs[0].index)

        self.assertEqual('Boo', refs[1].content)
        self.assertEqual('class', refs[1].kind_hint.kind)
        self.assertEqual(1, refs[1].index)

        self.assertEqual('m1("hello")', refs[2].content)
        self.assertEqual('method', refs[2].kind_hint.kind)
        self.assertEqual(2, refs[2].index)

        self.assertEqual('FooBar.CONSTANT', refs[3].content)
        self.assertEqual('class', refs[3].kind_hint.kind)
        self.assertEqual(3, refs[3].index)

        self.assertEqual('FooBar.CONSTANT', refs[4].content)
        self.assertEqual('field', refs[4].kind_hint.kind)
        self.assertEqual(3, refs[4].index)

        self.assertEqual('@Bar', refs[5].content)
        self.assertEqual('annotation', refs[5].kind_hint.kind)
        self.assertEqual(4, refs[5].index)

        self.assertEqual('buz().baz(1)', refs[6].content)
        self.assertEqual('method', refs[6].kind_hint.kind)
        self.assertEqual(5, refs[6].index)

        self.assertEqual('baz(1)', refs[7].content)
        self.assertEqual('method', refs[7].kind_hint.kind)
        self.assertEqual(5, refs[7].index)

        self.assertEqual('com.Baz.m2("", null).m3(CONST);', refs[8].content)
        self.assertEqual('class', refs[8].kind_hint.kind)
        self.assertEqual(6, refs[8].index)

        self.assertEqual('com.Baz.m2("", null).m3(CONST);', refs[9].content)
        self.assertEqual('method', refs[9].kind_hint.kind)
        self.assertEqual(6, refs[9].index)

        self.assertEqual('m3(CONST);', refs[10].content)
        self.assertEqual('method', refs[10].kind_hint.kind)
        self.assertEqual(6, refs[10].index)
コード例 #5
0
ファイル: generic_parser.py プロジェクト: bartdag/recodoc2
    def _get_lines(self, message, load, ucontent):
        lines = []

        if not message.title.lower().strip().startswith('re:'):
            lines.append(clean_breaks(message.title))
            lines.append('')

        new_content = ucontent.replace('\r', '').replace('\t', ' ')
        content_lines = new_content.split('\n')
        for content_line in content_lines:
            content_line = content_line.replace('&lt;', '<')\
                    .replace('&gt;', '>')
            if not self._uninteresting_line(content_line):
                lines.append(content_line)

        return lines
コード例 #6
0
ファイル: generic_parser.py プロジェクト: nengnengwu/recodoc2
    def _get_lines(self, message, load, ucontent):
        lines = []

        if not message.title.lower().strip().startswith('re:'):
            lines.append(clean_breaks(message.title))
            lines.append('')

        new_content = ucontent.replace('\r', '').replace('\t', ' ')
        content_lines = new_content.split('\n')
        for content_line in content_lines:
            content_line = content_line.replace('&lt;', '<')\
                    .replace('&gt;', '>')
            if not self._uninteresting_line(content_line):
                lines.append(content_line)

        return lines