Example #1
0
 def get_full_documentation(self, msgs, options, reports, doc=None, module=None):
     result = ""
     checker_title = "%s checker" % (self.name.replace("_", " ").title())
     if module:
         # Provide anchor to link against
         result += ".. _%s:\n\n" % module
     result += "%s\n" % get_rst_title(checker_title, "~")
     if module:
         result += "This checker is provided by ``%s``.\n" % module
     result += "Verbatim name of the checker is ``%s``.\n\n" % self.name
     if doc:
         # Provide anchor to link against
         result += get_rst_title("{} Documentation".format(checker_title), "^")
         result += "%s\n\n" % cleandoc(doc)
     # options might be an empty generator and not be False when casted to boolean
     options = list(options)
     if options:
         result += get_rst_title("{} Options".format(checker_title), "^")
         result += "%s\n" % get_rst_section(None, options)
     if msgs:
         result += get_rst_title("{} Messages".format(checker_title), "^")
         for msgid, msg in sorted(
             msgs.items(), key=lambda kv: (_MSG_ORDER.index(kv[0][0]), kv[1])
         ):
             msg = self.create_message_definition_from_tuple(msgid, msg)
             result += "%s\n" % msg.format_help(checkerref=False)
         result += "\n"
     if reports:
         result += get_rst_title("{} Reports".format(checker_title), "^")
         for report in reports:
             result += ":%s: %s\n" % report[:2]
         result += "\n"
     result += "\n"
     return result
Example #2
0
    def get_checkers_documentation(self):
        result = get_rst_title("Pylint global options and switches", "-")
        result += """
Pylint provides global options and switches.

"""
        for checker in self.get_checkers():
            name = checker.name
            if name == MAIN_CHECKER_NAME:
                if checker.options:
                    for section, options in checker.options_by_section():
                        if section is None:
                            title = "General options"
                        else:
                            title = "%s options" % section.capitalize()
                        result += get_rst_title(title, "~")
                        result += "%s\n" % get_rst_section(None, options)
        result += get_rst_title("Pylint checkers' options and switches", "-")
        result += """\

Pylint checkers can provide three set of features:

* options that control their execution,
* messages that they can raise,
* reports that they can generate.

Below is a list of all checkers and their features.

"""
        by_checker = self._get_checkers_infos()
        for checker in sorted(by_checker):
            information = by_checker[checker]
            checker = information["checker"]
            del information["checker"]
            result += checker.get_full_documentation(**information)
        return result