Exemplo n.º 1
0
    def _check_docstrings(self, msg_buffer):
        for plg_cls in plugin.Plugin.get_all():
            if not plg_cls.__module__.startswith("rally."):
                continue
            name = "%s (%s.%s)" % (plg_cls.get_name(),
                                   plg_cls.__module__,
                                   plg_cls.__name__)
            doc_info = plg_cls.get_info()
            if not doc_info["title"]:
                msg_buffer.append("Plugin '%s' should have a docstring."
                                  % name)
            if doc_info["title"].startswith("Test"):
                msg_buffer.append("One-line description for %s"
                                  " should be declarative and not"
                                  " start with 'Test(s) ...'"
                                  % name)

            # NOTE(andreykurilin): I never saw any real usage of
            #   reStructuredText definitions in our docstrings. In most cases,
            #   "definitions" means that there is an issue with intends or
            #   missed empty line before the list title and list items.
            if doc_info["description"]:
                parsed_docstring = utils.parse_rst(doc_info["description"])
                self._iterate_parsed_rst(plg_cls.get_name(),
                                         parsed_docstring,
                                         msg_buffer)
Exemplo n.º 2
0
    def test_plugin_bases_have_docstrigs(self):
        plugin_bases = set()
        msg_buffer = []
        for plg_cls in plugin.Plugin.get_all(allow_hidden=True):
            plugin_bases.add(plg_cls._get_base())
        for base in plugin_bases:
            name = "%s.%s" % (base.__module__, base.__name__)
            try:
                docstring = base._get_doc()
            except Exception:
                docstring = base.__doc__

            print(name)
            parsed_docstring = utils.parse_rst(docstring)
            self._iterate_parsed_rst(name, parsed_docstring, msg_buffer)

        if msg_buffer:
            self.fail("\n%s" % "\n===============\n".join(msg_buffer))
Exemplo n.º 3
0
    def get_rally_releases(self):
        full_path = os.path.join(ROOT_DIR, "CHANGELOG.rst")
        with open(full_path) as f:
            changelog = f.read()
        changelog = utils.parse_rst(changelog)
        if len(changelog) != 1:
            self.fail("'%s' file should contain one global section "
                      "with subsections for each release." % full_path)

        releases = []
        for node in changelog[0].children:
            if not isinstance(node, nodes.section):
                continue
            title = node.astext().split("\n", 1)[0]
            result = self.RE_RELEASE.match(title)
            if result:
                releases.append(result.groupdict()["version"])
        if not releases:
            self.fail("'%s' doesn't mention any releases..." % full_path)
        return releases
Exemplo n.º 4
0
    def get_rally_releases(self):
        full_path = os.path.join(ROOT_DIR, "CHANGELOG.rst")
        with open(full_path) as f:
            changelog = f.read()
        changelog = utils.parse_rst(changelog)
        if len(changelog) != 1:
            self.fail("'%s' file should contain one global section "
                      "with subsections for each release." % full_path)

        releases = []
        for node in changelog[0].children:
            if not isinstance(node, nodes.section):
                continue
            title = node.astext().split("\n", 1)[0]
            result = self.RE_RELEASE.match(title)
            if result:
                releases.append(result.groupdict()["version"])
        if not releases:
            self.fail("'%s' doesn't mention any releases..." % full_path)
        return releases
Exemplo n.º 5
0
    def test_plugin_bases_have_docstrigs(self):
        plugin_bases = set()
        msg_buffer = []
        for plg_cls in plugin.Plugin.get_all(allow_hidden=True):
            plugin_bases.add(plg_cls._get_base())
        for base in plugin_bases:
            name = "%s.%s" % (base.__module__, base.__name__)
            try:
                docstring = base._get_doc()
            except Exception:
                docstring = base.__doc__

            print(name)
            parsed_docstring = utils.parse_rst(docstring)
            self._iterate_parsed_rst(name,
                                     parsed_docstring,
                                     msg_buffer)

        if msg_buffer:
            self.fail("\n%s" % "\n===============\n".join(msg_buffer))
Exemplo n.º 6
0
    def _check_docstrings(self, msg_buffer):
        for plg_cls in plugin.Plugin.get_all():
            if not plg_cls.__module__.startswith("rally."):
                continue
            name = "%s (%s.%s)" % (plg_cls.get_name(), plg_cls.__module__,
                                   plg_cls.__name__)
            doc_info = plg_cls.get_info()
            if not doc_info["title"]:
                msg_buffer.append("Plugin '%s' should have a docstring." %
                                  name)
            if doc_info["title"].startswith("Test"):
                msg_buffer.append("One-line description for %s"
                                  " should be declarative and not"
                                  " start with 'Test(s) ...'" % name)

            # NOTE(andreykurilin): I never saw any real usage of
            #   reStructuredText definitions in our docstrings. In most cases,
            #   "definitions" means that there is an issue with intends or
            #   missed empty line before the list title and list items.
            if doc_info["description"]:
                parsed_docstring = utils.parse_rst(doc_info["description"])
                self._iterate_parsed_rst(plg_cls.get_name(), parsed_docstring,
                                         msg_buffer)