Beispiel #1
0
 def print_full_documentation(self):
     """output a full documentation in ReST format"""
     by_checker = {}
     for checker in self.get_checkers():
         if checker.name == 'master':
             prefix = 'Main '
             print("Options")
             print('-------\n')
             if checker.options:
                 for section, options in checker.options_by_section():
                     if section is None:
                         title = 'General options'
                     else:
                         title = '%s options' % section.capitalize()
                     print(title)
                     print('~' * len(title))
                     rest_format_section(sys.stdout, None, options)
                     print()
         else:
             try:
                 by_checker[checker.name][0] += checker.options_and_values()
                 by_checker[checker.name][1].update(checker.msgs)
                 by_checker[checker.name][2] += checker.reports
             except KeyError:
                 by_checker[checker.name] = [
                     list(checker.options_and_values()),
                     dict(checker.msgs),
                     list(checker.reports)
                 ]
     for checker, (options, msgs, reports) in six.iteritems(by_checker):
         prefix = ''
         title = '%s checker' % checker
         print(title)
         print('-' * len(title))
         print()
         if options:
             title = 'Options'
             print(title)
             print('~' * len(title))
             rest_format_section(sys.stdout, None, options)
             print()
         if msgs:
             title = ('%smessages' % prefix).capitalize()
             print(title)
             print('~' * len(title))
             for msgid, msg in sorted(six.iteritems(msgs),
                                      key=lambda kv:
                                      (_MSG_ORDER.index(kv[0][0]), kv[1])):
                 msg = build_message_def(checker, msgid, msg)
                 print(msg.format_help(checkerref=False))
             print()
         if reports:
             title = ('%sreports' % prefix).capitalize()
             print(title)
             print('~' * len(title))
             for report in reports:
                 print(':%s: %s' % report[:2])
             print()
         print()
Beispiel #2
0
 def print_full_documentation(self):
     """output a full documentation in ReST format"""
     by_checker = {}
     for checker in self.get_checkers():
         if checker.name == "master":
             prefix = "Main "
             print "Options"
             print "-------\n"
             if checker.options:
                 for section, options in checker.options_by_section():
                     if section is None:
                         title = "General options"
                     else:
                         title = "%s options" % section.capitalize()
                     print title
                     print "~" * len(title)
                     rest_format_section(sys.stdout, None, options)
                     print
         else:
             try:
                 by_checker[checker.name][0] += checker.options_and_values()
                 by_checker[checker.name][1].update(checker.msgs)
                 by_checker[checker.name][2] += checker.reports
             except KeyError:
                 by_checker[checker.name] = [
                     list(checker.options_and_values()),
                     dict(checker.msgs),
                     list(checker.reports),
                 ]
     for checker, (options, msgs, reports) in by_checker.iteritems():
         prefix = ""
         title = "%s checker" % checker
         print title
         print "-" * len(title)
         print
         if options:
             title = "Options"
             print title
             print "~" * len(title)
             rest_format_section(sys.stdout, None, options)
             print
         if msgs:
             title = ("%smessages" % prefix).capitalize()
             print title
             print "~" * len(title)
             for msgid, msg in sorted(msgs.iteritems(), key=lambda (k, v): (_MSG_ORDER.index(k[0]), k)):
                 msg = build_message_def(checker, msgid, msg)
                 print msg.format_help(checkerref=False)
             print
         if reports:
             title = ("%sreports" % prefix).capitalize()
             print title
             print "~" * len(title)
             for report in reports:
                 print ":%s: %s" % report[:2]
             print
         print
Beispiel #3
0
 def print_full_documentation(self):
     """output a full documentation in ReST format"""
     by_checker = {}
     for checker in self.get_checkers():
         if checker.name == 'master':
             prefix = 'Main '
             print "Options"
             print '-------\n'
             if checker.options:
                 for section, options in checker.options_by_section():
                     if section is None:
                         title = 'General options'
                     else:
                         title = '%s options' % section.capitalize()
                     print title
                     print '~' * len(title)
                     rest_format_section(sys.stdout, None, options)
                     print
         else:
             try:
                 by_checker[checker.name][0] += checker.options_and_values()
                 by_checker[checker.name][1].update(checker.msgs)
                 by_checker[checker.name][2] += checker.reports
             except KeyError:
                 by_checker[checker.name] = [
                     list(checker.options_and_values()),
                     dict(checker.msgs),
                     list(checker.reports)
                 ]
     for checker, (options, msgs, reports) in by_checker.iteritems():
         prefix = ''
         title = '%s checker' % checker
         print title
         print '-' * len(title)
         print
         if options:
             title = 'Options'
             print title
             print '~' * len(title)
             rest_format_section(sys.stdout, None, options)
             print
         if msgs:
             title = ('%smessages' % prefix).capitalize()
             print title
             print '~' * len(title)
             for msgid in sort_msgs(msgs.iterkeys()):
                 print self.get_message_help(msgid, False)
             print
         if reports:
             title = ('%sreports' % prefix).capitalize()
             print title
             print '~' * len(title)
             for report in reports:
                 print ':%s: %s' % report[:2]
             print
         print
Beispiel #4
0
 def print_full_documentation(self):
     """output a full documentation in ReST format"""
     by_checker = {}
     for checker in self.get_checkers():
         if checker.name == 'master':
             prefix = 'Main '
             print "Options"
             print '-------\n'
             if checker.options:
                 for section, options in checker.options_by_section():
                     if section is None:
                         title = 'General options'
                     else:
                         title = '%s options' % section.capitalize()
                     print title
                     print '~' * len(title)
                     rest_format_section(sys.stdout, None, options)
                     print
         else:
             try:
                 by_checker[checker.name][0] += checker.options_and_values()
                 by_checker[checker.name][1].update(checker.msgs)
                 by_checker[checker.name][2] += checker.reports
             except KeyError:
                 by_checker[checker.name] = [list(checker.options_and_values()),
                                             dict(checker.msgs),
                                             list(checker.reports)]
     for checker, (options, msgs, reports) in by_checker.items():
         prefix = ''
         title = '%s checker' % checker
         print title
         print '-' * len(title)
         print
         if options:
             title = 'Options'
             print title
             print '~' * len(title)
             rest_format_section(sys.stdout, None, options)
             print
         if msgs:
             title = ('%smessages' % prefix).capitalize()
             print title
             print '~' * len(title)
             for msgid in sort_msgs(msgs.keys()):
                 print self.get_message_help(msgid, False)
             print
         if reports:
             title = ('%sreports' % prefix).capitalize()
             print title
             print '~' * len(title)
             for report in reports:
                 print ':%s: %s' % report[:2]
             print
         print
Beispiel #5
0
 def list_messages(self):
     """output a full documentation in ReST format"""
     for checker in sort_checkers(self._checkers.values()):
         if checker.name == 'master':
             prefix = 'Main '
             if checker.options:
                 for section, options in checker.options_by_section():
                     if section is None:
                         title = 'General options'
                     else:
                         title = '%s options' % section.capitalize()
                     print title
                     print '~' * len(title)
                     rest_format_section(sys.stdout, None, options)
                     print
         else:
             prefix = ''
             title = '%s checker' % checker.name.capitalize()
             print title
             print '-' * len(title)
             if checker.__doc__: # __doc__ is None with -OO
                 print linesep.join([l.strip()
                                     for l in checker.__doc__.splitlines()])
             if checker.options:
                 title = 'Options'
                 print title
                 print '~' * len(title)
                 for section, options in checker.options_by_section():
                     rest_format_section(sys.stdout, section, options)
                     print
         if checker.msgs:
             title = ('%smessages' % prefix).capitalize()
             print title
             print '~' * len(title)
             for msg_id in sort_msgs(checker.msgs.keys()):
                 print self.get_message_help(msg_id, False)
             print
         if getattr(checker, 'reports', None):
             title = ('%sreports' % prefix).capitalize()
             print title
             print '~' * len(title)
             for report in checker.reports:
                 print ':%s: %s' % report[:2]
             print
         print
Beispiel #6
0
 def print_full_documentation(self):
     """output a full documentation in ReST format"""
     for checker in sort_checkers(self._checkers.values()):
         if checker.name == 'master':
             prefix = 'Main '
             if checker.options:
                 for section, options in checker.options_by_section():
                     if section is None:
                         title = 'General options'
                     else:
                         title = '%s options' % section.capitalize()
                     print title
                     print '~' * len(title)
                     rest_format_section(sys.stdout, None, options)
                     print
         else:
             prefix = ''
             title = '%s checker' % checker.name.capitalize()
             print title
             print '-' * len(title)
             if checker.__doc__: # __doc__ is None with -OO
                 print linesep.join([l.strip()
                                     for l in checker.__doc__.splitlines()])
             if checker.options:
                 title = 'Options'
                 print title
                 print '~' * len(title)
                 for section, options in checker.options_by_section():
                     rest_format_section(sys.stdout, section, options)
                     print
         if checker.msgs:
             title = ('%smessages' % prefix).capitalize()
             print title
             print '~' * len(title)
             self.list_checkers_messages( checker)
             print
         if getattr(checker, 'reports', None):
             title = ('%sreports' % prefix).capitalize()
             print title
             print '~' * len(title)
             for report in checker.reports:
                 print ':%s: %s' % report[:2]
             print
         print
Beispiel #7
0
    def print_full_documentation(self):
        """output a full documentation in ReST format"""
        print("Pylint global options and switches")
        print("----------------------------------")
        print("")
        print("Pylint provides global options and switches.")
        print("")

        by_checker = {}
        for checker in self.get_checkers():
            if checker.name == 'master':
                if checker.options:
                    for section, options in checker.options_by_section():
                        if section is None:
                            title = 'General options'
                        else:
                            title = '%s options' % section.capitalize()
                        print(title)
                        print('~' * len(title))
                        rest_format_section(sys.stdout, None, options)
                        print("")
            else:
                try:
                    by_checker[checker.name][0] += checker.options_and_values()
                    by_checker[checker.name][1].update(checker.msgs)
                    by_checker[checker.name][2] += checker.reports
                except KeyError:
                    by_checker[checker.name] = [list(checker.options_and_values()),
                                                dict(checker.msgs),
                                                list(checker.reports)]

        print("Pylint checkers' options and switches")
        print("-------------------------------------")
        print("")
        print("Pylint checkers can provide three set of features:")
        print("")
        print("* options that control their execution,")
        print("* messages that they can raise,")
        print("* reports that they can generate.")
        print("")
        print("Below is a list of all checkers and their features.")
        print("")

        for checker, (options, msgs, reports) in six.iteritems(by_checker):
            title = '%s checker' % (checker.replace("_", " ").title())
            print(title)
            print('~' * len(title))
            print("")
            print("Verbatim name of the checker is ``%s``." % checker)
            print("")
            if options:
                title = 'Options'
                print(title)
                print('^' * len(title))
                rest_format_section(sys.stdout, None, options)
                print("")
            if msgs:
                title = 'Messages'
                print(title)
                print('~' * len(title))
                for msgid, msg in sorted(six.iteritems(msgs),
                                         key=lambda kv: (_MSG_ORDER.index(kv[0][0]), kv[1])):
                    msg = build_message_def(checker, msgid, msg)
                    print(msg.format_help(checkerref=False))
                print("")
            if reports:
                title = 'Reports'
                print(title)
                print('~' * len(title))
                for report in reports:
                    print(':%s: %s' % report[:2])
                print("")
            print("")