本文整理汇总了Python中pylint.lint.PyLinter.print_full_documentation方法的典型用法代码示例。如果您正苦于以下问题:Python PyLinter.print_full_documentation方法的具体用法?Python PyLinter.print_full_documentation怎么用?Python PyLinter.print_full_documentation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pylint.lint.PyLinter
的用法示例。
在下文中一共展示了PyLinter.print_full_documentation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: builder_inited
# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import print_full_documentation [as 别名]
def builder_inited(app):
# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
base_path = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
linter = PyLinter()
linter.load_default_plugins()
features = os.path.join(base_path, 'doc', 'technical_reference', 'features.rst')
with open(features, 'w') as stream:
stream.write("Pylint features\n")
stream.write("===============\n\n")
stream.write(".. generated by pylint --full-documentation\n\n")
linter.print_full_documentation(stream)
示例2: PyLinterTC
# 需要导入模块: from pylint.lint import PyLinter [as 别名]
# 或者: from pylint.lint.PyLinter import print_full_documentation [as 别名]
#.........这里部分代码省略.........
pass
this_module.TestReporter = TestReporter
class_name = ".".join((this_module.__name__, 'TestReporter'))
self.linter.set_option('output-format', class_name)
self.assertEqual(self.linter.reporter.__class__.__name__, 'TestReporter')
def test_set_option_1(self):
linter = self.linter
linter.set_option('disable', 'C0111,W0234')
self.assertFalse(linter.is_message_enabled('C0111'))
self.assertFalse(linter.is_message_enabled('W0234'))
self.assertTrue(linter.is_message_enabled('W0113'))
self.assertFalse(linter.is_message_enabled('missing-docstring'))
self.assertFalse(linter.is_message_enabled('non-iterator-returned'))
def test_set_option_2(self):
linter = self.linter
linter.set_option('disable', ('C0111', 'W0234') )
self.assertFalse(linter.is_message_enabled('C0111'))
self.assertFalse(linter.is_message_enabled('W0234'))
self.assertTrue(linter.is_message_enabled('W0113'))
self.assertFalse(linter.is_message_enabled('missing-docstring'))
self.assertFalse(linter.is_message_enabled('non-iterator-returned'))
def test_enable_checkers(self):
self.linter.disable('design')
self.assertFalse('design' in [c.name for c in self.linter.prepare_checkers()])
self.linter.enable('design')
self.assertTrue('design' in [c.name for c in self.linter.prepare_checkers()])
def test_errors_only(self):
linter = self.linter
self.linter.error_mode()
checkers = self.linter.prepare_checkers()
checker_names = set(c.name for c in checkers)
should_not = set(('design', 'format', 'metrics',
'miscellaneous', 'similarities'))
self.assertSetEqual(set(), should_not & checker_names)
def test_disable_similar(self):
self.linter.set_option('disable', 'RP0801')
self.linter.set_option('disable', 'R0801')
self.assertFalse('similarities' in [c.name for c in self.linter.prepare_checkers()])
def test_disable_alot(self):
"""check that we disabled a lot of checkers"""
self.linter.set_option('reports', False)
self.linter.set_option('disable', 'R,C,W')
checker_names = [c.name for c in self.linter.prepare_checkers()]
for cname in ('design', 'metrics', 'similarities'):
self.assertFalse(cname in checker_names, cname)
def test_addmessage(self):
self.linter.set_reporter(TestReporter())
self.linter.open()
self.linter.set_current_module('0123')
self.linter.add_message('C0301', line=1, args=(1, 2))
self.linter.add_message('line-too-long', line=2, args=(3, 4))
self.assertEqual(
['C: 1: Line too long (1/2)', 'C: 2: Line too long (3/4)'],
self.linter.reporter.messages)
def test_init_hooks_called_before_load_plugins(self):
self.assertRaises(RuntimeError,
Run, ['--load-plugins', 'unexistant', '--init-hook', 'raise RuntimeError'])
self.assertRaises(RuntimeError,
Run, ['--init-hook', 'raise RuntimeError', '--load-plugins', 'unexistant'])
def test_analyze_explicit_script(self):
self.linter.set_reporter(TestReporter())
self.linter.check(os.path.join(os.path.dirname(__file__), 'data', 'ascript'))
self.assertEqual(
['C: 2: Line too long (175/100)'],
self.linter.reporter.messages)
def test_python3_checker_disabled(self):
checker_names = [c.name for c in self.linter.prepare_checkers()]
self.assertNotIn('python3', checker_names)
self.linter.set_option('enable', 'python3')
checker_names = [c.name for c in self.linter.prepare_checkers()]
self.assertIn('python3', checker_names)
def test_full_documentation(self):
out = six.StringIO()
self.linter.print_full_documentation(out)
output = out.getvalue()
# A few spot checks only
for re_str in [
# autogenerated text
"^Pylint global options and switches$",
"Verbatim name of the checker is ``python3``",
# messages
"^:old-octal-literal \(E1608\):",
# options
"^:dummy-variables-rgx:",
]:
regexp = re.compile(re_str, re.MULTILINE)
self.assertRegexpMatches(output, regexp)