Пример #1
0
    def append_to_items(self, art, depth):

        if is_req(art):
            self.current_req = art
            kind_text = writer.strong("(%s)" % class_to_string(art))
            id_text = writer.strong("%s" % art.full_name.replace("/TOR", ""))

        elif is_tc(art):
            kind_text = "(%s)" % class_to_string(art)

            common_prefix_parent_req = os.path.commonprefix(
                (art.full_name, self.current_req.full_name))

            id_text = \
                "[...]" + art.full_name.replace(common_prefix_parent_req, "")

        self.items.append([
            kind_text, id_text,
            write_artifact_ref(art.full_name, get_short_description(art))
        ])
Пример #2
0
    def qmlink_to_rest(self, parent, artifacts):

        items = []
        html_top_index = ""

        for a in artifacts:

            items.append([writer.strong(a.name), writer.qmref(a.full_name)])

            if a.name == "Ada":

                def key(a):
                    d = {'stmt': 1, 'decision': 2, 'mcdc': 3}
                    for k in d:
                        if k in a.name:
                            return d[k]

                selected = [k for k in a.relatives if not is_source(k)]
                selected.sort(key=key)

            else:
                selected = a.relatives

            for suba in selected:
                items.append(
                    ["`..` %s" % suba.name,
                     writer.qmref(suba.full_name)])

        html_top_index += writer.csv_table(items,
                                           headers=["Chapter", "Description"],
                                           widths=[30, 70])

        output = writer.only(html_top_index, "html")

        links = [(a, qm.rest.DefaultImporter()) for a in artifacts
                 if "Index/.+" not in a.full_name]

        output += writer.toctree([
            '/%s/content' % artifact_hash(*l)
            for l in links if not is_tc_or_set(l[0])
        ],
                                 hidden=True)

        return output, links
Пример #3
0
    def qmlink_to_rest(self, parent, artifacts):

        html_items = []
        pdf_items = []
        output = ""

        for a in artifacts:
            # Don't put sources in the tables
            if is_source(a):
                continue

            if is_tc_or_set(a):
                reference = write_artifact_ref(a.full_name,
                                               get_short_description(a))

            html_items.append([writer.strong(class_to_string(a)),
                               writer.strong(a.name),
                               reference])
            pdf_items.append([class_to_string(a),
                              a.name,
                              reference])
            for suba in self.get_recursive_relatives(a, 1):
                # We do include in the table children artifacts only
                # in html format.

                if is_tc(suba):
                    subref = write_artifact_ref(suba.full_name,
                                                get_short_description(suba))

                if is_tcset(suba):
                    subref = writer.qmref(suba.full_name)

                html_items.append([class_to_string(suba),
                                   "`..` %s" % suba.name,
                                   subref])

        html_table = writer.csv_table(
            html_items,
            headers=["", "TestCases", "Description"],
            widths=[3, 25, 65])

        pdf_table = writer.csv_table(
            pdf_items,
            headers=["", "TestCases", "Description"],
            widths=[3, 25, 65]).strip()

        output += writer.only(html_table, "html")
        output += writer.only(pdf_table, "latex").strip()
        output += "\n\n"

        links = []
        for a in artifacts:
            if is_tc(a):
                links.append((a, TestCaseImporter()))
            elif is_source(a):
                pass
            else:
                links.append((a, default_importer(a)))

        output += writer.toctree(
            ['/%s/content' % artifact_hash(*l)
             for l in links
             if not is_tc_or_set(l[0]) or is_tc_or_set(parent)],
            hidden=True)

        return output, links