예제 #1
0
    def __get_doc_block_parts_source(self):
        """
        Extracts the DocBlock (in parts) from the source of the stored routine source.
        """
        line1, line2 = self.__get_doc_block_lines()

        if line1 is not None and line2 is not None and line1 <= line2:
            doc_block = self._routine_source_code_lines[line1:line2 - line1 +
                                                        1]
        else:
            doc_block = list()

        reflection = DocBlockReflection(doc_block)

        self._doc_block_parts_source[
            'description'] = reflection.get_description()

        self._doc_block_parts_source['parameters'] = list()
        for tag in reflection.get_tags('param'):
            parts = re.match(r'^(@param)\s+(\w+)\s*(.+)?', tag, re.DOTALL)
            if parts:
                self._doc_block_parts_source['parameters'].append({
                    'name':
                    parts.group(2),
                    'description':
                    parts.group(3)
                })
예제 #2
0
    def test04(self):
        """
        Test DocBlock with description only and not proper whitespace.
        """
        doc_block = ['  /**', ' * Hello World', '  */  ']
        reflection = DocBlockReflection(doc_block)

        description = reflection.get_description()
        self.assertEqual('Hello World', description)

        params = reflection.get_tags('param')
        self.assertEqual([], params)
예제 #3
0
    def test01(self):
        """
        Test empty DocBlock.
        """
        doc_block = []
        reflection = DocBlockReflection(doc_block)

        description = reflection.get_description()
        self.assertEqual('', description)

        params = reflection.get_tags('param')
        self.assertEqual([], params)
예제 #4
0
    def test11(self):
        """
        Test DocBlock with description and parameters and not proper whitespace.
        """
        doc_block = [
            ' /**', ' * Hello World', '', ' ', '   * @param p1  ',
            '* @param p2 This is param2. ', ' */ '
        ]
        reflection = DocBlockReflection(doc_block)

        description = reflection.get_description()
        self.assertEqual('Hello World', description)

        params = reflection.get_tags('param')
        self.assertEqual(['@param p1', '@param p2 This is param2.'], params)
예제 #5
0
    def test20(self):
        """
        Test DocBlock without description and parameters with proper whitespace.
        """
        doc_block = [
            '/**', ' * @param p1 This is param1.',
            ' * @param p2 This is param2.', ' */'
        ]
        reflection = DocBlockReflection(doc_block)

        description = reflection.get_description()
        self.assertEqual('', description)

        params = reflection.get_tags('param')
        self.assertEqual(
            ['@param p1 This is param1.', '@param p2 This is param2.'], params)
    def __get_doc_block_parts_source(self):
        """
        Extracts the DocBlock (in parts) from the source of the stored routine source.
        """
        line1, line2 = self.__get_doc_block_lines()

        if line1 is not None and line2 is not None and line1 <= line2:
            doc_block = self._routine_source_code_lines[line1:line2 - line1 + 1]
        else:
            doc_block = list()

        reflection = DocBlockReflection(doc_block)

        self._doc_block_parts_source['description'] = reflection.get_description()

        self._doc_block_parts_source['parameters'] = list()
        for tag in reflection.get_tags('param'):
            parts = re.match(r'^(@param)\s+(\w+)\s*(.+)?', tag, re.DOTALL)
            if parts:
                self._doc_block_parts_source['parameters'].append({'name':        parts.group(2),
                                                                   'description': parts.group(3)})