当前位置: 首页>>代码示例>>Python>>正文


Python DocBaseClass.extract方法代码示例

本文整理汇总了Python中coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass.extract方法的典型用法代码示例。如果您正苦于以下问题:Python DocBaseClass.extract方法的具体用法?Python DocBaseClass.extract怎么用?Python DocBaseClass.extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass的用法示例。


在下文中一共展示了DocBaseClass.extract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_python_doxygen

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_python_doxygen(self):
        data = load_testdata('doxygen.py')

        parsed_docs = [doc.parse() for doc in
                       DocBaseClass.extract(data, 'python', 'doxygen')]

        expected = [
            [self.Description(desc=' @package pyexample\n  Documentation for'
                                   ' this module.\n\n  More details.\n')],
            [self.Description(
                desc=' Documentation for a class.\n\n More details.\n')],
            [self.Description(desc=' The constructor.\n')],
            [self.Description(desc=' Documentation for a method.\n'),
             self.Parameter(name='self', desc='The object pointer.\n')],
            [self.Description(desc=' A class variable.\n')],
            [self.Description(desc=' @var _memVar\n  a member variable\n')],
            [self.Description(desc=' This is the best docstring ever!\n\n'),
             self.Parameter(name='param1', desc='Parameter 1\n'),
             self.Parameter(name='param2', desc='Parameter 2\n'),
             self.ReturnValue(desc='Nothing\n')],
            [self.Description(desc=' This is dummy docstring find '
                                   'function.\n\n'),
             self.Parameter(name='filename', desc='contains filename\n'),
             self.ExceptionValue(name='FileNotFoundError',
                                 desc='raises when filename is not found\n'),
             self.ReturnValue(desc='nothing\n')],
                   ]

        self.assertEqual(parsed_docs, expected)
开发者ID:Anmolbansal1,项目名称:coala,代码行数:31,代码来源:DocumentationCommentTest.py

示例2: test_c_assembly

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_c_assembly(self):
        data = load_testdata('default.c')
        docs = ''.join(data)

        for doc in DocBaseClass.extract(data, 'c', 'doxygen'):
            doc.top_padding = 1
            doc.assemble.cache_clear()
            self.assertIn(doc.assemble(), docs)
开发者ID:Anmolbansal1,项目名称:coala,代码行数:10,代码来源:DocumentationCommentTest.py

示例3: test_python_default_padding_amend_assembly_2

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_python_default_padding_amend_assembly_2(self):
        data = ['""" documentation in single line """\n']

        for doc in DocBaseClass.extract(data, 'python', 'default'):
            doc.top_padding = 2
            doc.bottom_padding = 3
            doc.assemble.cache_clear()
            self.assertEqual(doc.assemble(),
                             '\n\n""" documentation in single line """\n\n\n')
开发者ID:Anmolbansal1,项目名称:coala,代码行数:11,代码来源:DocumentationCommentTest.py

示例4: test_DocBaseClass_extraction_C

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_extraction_C(self):
        data = load_testdata('data.c')

        # No built-in documentation for C.
        with self.assertRaises(KeyError):
            tuple(DocBaseClass.extract(data, 'C', 'default'))

        docstyle_C_doxygen = DocstyleDefinition.load('C', 'doxygen')

        expected_results = (DocumentationComment(
                                ('\n'
                                 ' This is the main function.\n'
                                 '\n'
                                 ' @returns Your favorite number.\n'),
                                docstyle_C_doxygen, '',
                                docstyle_C_doxygen.markers[0],
                                TextPosition(3, 1)),
                            DocumentationComment(
                                ('\n'
                                 ' Preserves alignment\n'
                                 ' - Main item\n'
                                 '   - sub item\n'
                                 '     - sub sub item\n'),
                                docstyle_C_doxygen, '',
                                docstyle_C_doxygen.markers[2],
                                TextPosition(15, 1)),
                            DocumentationComment(
                                (' ABC\n'
                                 '    Another type of comment\n'
                                 '\n'
                                 '    ...'),
                                docstyle_C_doxygen, '',
                                docstyle_C_doxygen.markers[1],
                                TextPosition(23, 1)),
                            DocumentationComment(
                                (' foobar = barfoo.\n'
                                 ' @param x whatever...\n'),
                                docstyle_C_doxygen, '',
                                docstyle_C_doxygen.markers[0],
                                TextPosition(28, 1)))

        self.assertEqual(tuple(
            DocBaseClass.extract(data, 'C', 'doxygen')),
            expected_results)
开发者ID:CruiseDevice,项目名称:coala,代码行数:46,代码来源:DocBaseClassTest.py

示例5: test_DocBaseClass_extraction_CPP

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_extraction_CPP(self):
        data = load_testdata('data.cpp')

        # No built-in documentation for C++.
        with self.assertRaises(KeyError):
            tuple(DocBaseClass.extract(data, 'CPP', 'default'))

        docstyle_CPP_doxygen = DocstyleDefinition.load('CPP', 'doxygen')

        self.assertEqual(tuple(DocBaseClass.extract(data, 'CPP', 'doxygen')),
                         (DocumentationComment(
                              ('\n'
                               ' This is the main function.\n'
                               ' @returns Exit code.\n'
                               '          Or any other number.\n'),
                              docstyle_CPP_doxygen, '',
                              docstyle_CPP_doxygen.markers[0],
                              TextPosition(4, 1)),
                          DocumentationComment(
                              (' foobar\n'
                               ' @param xyz\n'),
                              docstyle_CPP_doxygen, '',
                              docstyle_CPP_doxygen.markers[0],
                              TextPosition(15, 1)),
                          DocumentationComment(
                              ' Some alternate style of documentation\n',
                              docstyle_CPP_doxygen, '',
                              docstyle_CPP_doxygen.markers[4],
                              TextPosition(22, 1)),
                          DocumentationComment(
                              ' ends instantly',
                              docstyle_CPP_doxygen, '\t',
                              docstyle_CPP_doxygen.markers[0],
                              TextPosition(26, 2)),
                          DocumentationComment(
                              (' Should work\n'
                               '\n'
                               ' even without a function standing below.\n'
                               '\n'
                               ' @param foo WHAT PARAM PLEASE!?\n'),
                              docstyle_CPP_doxygen, '',
                              docstyle_CPP_doxygen.markers[4],
                              TextPosition(32, 1))))
开发者ID:CruiseDevice,项目名称:coala,代码行数:45,代码来源:DocBaseClassTest.py

示例6: test_python_doxygen_padding_amend_assembly

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_python_doxygen_padding_amend_assembly(self):
        data = ['## documentation in single line without return at end.']

        for doc in DocBaseClass.extract(data, 'python', 'doxygen'):
            doc.top_padding = 0
            doc.bottom_padding = 2
            doc.assemble.cache_clear()
            self.assertEqual(doc.assemble(),
                             '## documentation in single line '
                             'without return at end.\n\n')
开发者ID:Anmolbansal1,项目名称:coala,代码行数:12,代码来源:DocumentationCommentTest.py

示例7: test_DocBaseClass_instantiate_docstring_type_PYTHON3_11

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_instantiate_docstring_type_PYTHON3_11(self):
        data = ['def xyz:\n',
                '   """\n',
                '   This docstring is of docstring_type function\n',
                '   """\n']

        docstyle_PYTHON3_default = DocstyleDefinition.load('PYTHON3',
                                                           'default')

        for doc in DocBaseClass.extract(data, 'PYTHON3', 'default'):
            self.assertEqual(doc.docstring_type, 'function')
开发者ID:CruiseDevice,项目名称:coala,代码行数:13,代码来源:DocBaseClassTest.py

示例8: test_DocBaseClass_extraction_C_2

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_extraction_C_2(self):
        data = ['/** my main description\n', ' * continues here */']

        docstyle_C_doxygen = DocstyleDefinition.load('C', 'doxygen')

        self.assertEqual(
            list(DocBaseClass.extract(data, 'C', 'doxygen')),
            [DocumentationComment(' my main description\n continues here',
                                  docstyle_C_doxygen, '',
                                  docstyle_C_doxygen.markers[0],
                                  TextPosition(1, 1))])
开发者ID:CruiseDevice,项目名称:coala,代码行数:13,代码来源:DocBaseClassTest.py

示例9: test_DocBaseClass_extraction_PYTHON3_2

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_extraction_PYTHON3_2(self):
        data = ['\n', '""" documentation in single line  """\n', 'print(1)\n']

        docstyle_PYTHON3_default = DocstyleDefinition.load('PYTHON3',
                                                           'default')

        self.assertEqual(
            list(DocBaseClass.extract(data, 'PYTHON3', 'default')),
            [DocumentationComment(' documentation in single line  ',
                                  docstyle_PYTHON3_default, '',
                                  docstyle_PYTHON3_default.markers[0],
                                  TextPosition(2, 1))])
开发者ID:CruiseDevice,项目名称:coala,代码行数:14,代码来源:DocBaseClassTest.py

示例10: test_DocBaseClass_extraction_PYTHON3_4

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_extraction_PYTHON3_4(self):
        data = ['\n', 'triple_quote_string_test = """\n',
                'This is not a docstring\n', '"""\n']

        docstyle_PYTHON3_default = DocstyleDefinition.load('PYTHON3',
                                                           'default')

        # Nothing is yielded as triple quote string literals are being
        # ignored.
        self.assertEqual(
            list(DocBaseClass.extract(data, 'PYTHON3', 'default')),
            [])
开发者ID:CruiseDevice,项目名称:coala,代码行数:14,代码来源:DocBaseClassTest.py

示例11: test_DocBaseClass_CPP_2

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_CPP_2(self):
        data = load_testdata('data2.cpp')

        docstyle_CPP_doxygen = DocstyleDefinition.load('CPP', 'doxygen')

        self.assertEqual(tuple(DocBaseClass.extract(data, 'CPP', 'doxygen')),
                         (DocumentationComment(
                          ('module comment\n'
                           ' hello world\n'),
                          docstyle_CPP_doxygen, '',
                          docstyle_CPP_doxygen.markers[0],
                          TextPosition(1, 1)),))
开发者ID:CruiseDevice,项目名称:coala,代码行数:14,代码来源:DocBaseClassTest.py

示例12: test_DocBaseClass_instantiate_docstring_type_PYTHON3_14

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_instantiate_docstring_type_PYTHON3_14(self):
        data = ['## Documentation for a class.\n',
                '#\n',
                '#  More details.\n',
                'class PyClass:\n',
                '\n']

        docstyle_PYTHON3_doxygen = DocstyleDefinition.load('PYTHON3',
                                                           'doxygen')

        for doc in DocBaseClass.extract(data, 'PYTHON3', 'doxygen'):
            self.assertEqual(doc.docstring_type, 'class')
开发者ID:CruiseDevice,项目名称:coala,代码行数:14,代码来源:DocBaseClassTest.py

示例13: test_DocBaseClass_extraction_PYTHON3_5

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_DocBaseClass_extraction_PYTHON3_5(self):
        data = ['r"""\n', 'This is a raw docstring\n', '"""\n']

        docstyle_PYTHON3_default = DocstyleDefinition.load('PYTHON3',
                                                           'default')

        self.assertEqual(
            list(DocBaseClass.extract(data, 'PYTHON3', 'default')),
            [DocumentationComment('\nThis is a raw docstring\n',
                                  docstyle_PYTHON3_default, 'r',
                                  docstyle_PYTHON3_default.markers[0],
                                  TextPosition(1, 2))])
开发者ID:CruiseDevice,项目名称:coala,代码行数:14,代码来源:DocBaseClassTest.py

示例14: test_c_default_padding_amend_assembly

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_c_default_padding_amend_assembly(self):
        data = ['/**\n',
                ' * This is the main function.\n',
                ' */\n']

        for doc in DocBaseClass.extract(data, 'c', 'doxygen'):
            doc.top_padding = 1
            doc.bottom_padding = 2
            doc.assemble.cache_clear()
            self.assertEqual(doc.assemble(),
                             '\n/**\n'
                             ' * This is the main function.\n'
                             ' */\n\n')
开发者ID:Anmolbansal1,项目名称:coala,代码行数:15,代码来源:DocumentationCommentTest.py

示例15: test_MalformedComment2_CPP

# 需要导入模块: from coalib.bearlib.languages.documentation.DocBaseClass import DocBaseClass [as 别名]
# 或者: from coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass import extract [as 别名]
    def test_MalformedComment2_CPP(self):
        data = ['\n',
                '/** Aborts...\n']

        expected = [dedent("""\
            Please check the docstring for faulty markers. A starting
            marker has been found, but no instance of DocComment is
            returned."""), 1]

        for doc_comment in DocBaseClass.extract(data, 'CPP', 'doxygen'):
            self.assertEqual(
                [doc_comment.message, doc_comment.line],
                expected)
开发者ID:CruiseDevice,项目名称:coala,代码行数:15,代码来源:DocBaseClassTest.py


注:本文中的coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass.extract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。