本文整理汇总了Python中coalib.bearlib.languages.documentation.DocBaseClass.DocBaseClass类的典型用法代码示例。如果您正苦于以下问题:Python DocBaseClass类的具体用法?Python DocBaseClass怎么用?Python DocBaseClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DocBaseClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_python_doxygen
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)
示例2: test_c_assembly
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)
示例3: test_python_default_padding_amend_assembly_2
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')
示例4: test_DocBaseClass_extraction_C
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)
示例5: test_DocBaseClass_extraction_CPP
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))))
示例6: test_python_doxygen_padding_amend_assembly
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')
示例7: test_DocBaseClass_instantiate_docstring_type_PYTHON3_11
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')
示例8: test_DocBaseClass_extraction_C_2
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))])
示例9: test_DocBaseClass_extraction_PYTHON3_2
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))])
示例10: test_DocBaseClass_extraction_PYTHON3_4
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')),
[])
示例11: test_DocBaseClass_CPP_2
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)),))
示例12: test_DocBaseClass_instantiate_docstring_type_PYTHON3_14
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')
示例13: test_DocBaseClass_extraction_PYTHON3_5
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))])
示例14: test_c_default_padding_amend_assembly
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')
示例15: test_MalformedComment2_CPP
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)