예제 #1
0
    def tc_pdf_for_subdir(self, toplevel, subdir, links):
        """
        Helper for tc_pdf_for, doing the work for a single subdir.
        """

        subdir_links = [
            sdl for sdl in links
            if sdl[0].full_name.startswith('/TOR/%s/%s' % (toplevel, subdir))
        ]

        if not subdir_links:
            return ''

        links_dict = OrderedDict()
        for sdl in subdir_links:
            main_desc, desc = self.short_descs_of_main_ancestors(
                sdl[0], subdir)
            if desc not in links_dict:
                links_dict[desc] = []
            links_dict[desc].append(sdl)

        pdf_output = ''
        pdf_output += writer.subsection('%s' % main_desc) + '\n'

        for desc in links_dict.keys():
            pdf_output += writer.subsubsection(desc) + '\n'
            pdf_output += writer.toctree(
                ['/%s/content' % artifact_hash(*l) for l in links_dict[desc]],
                hidden=True)

        return pdf_output
예제 #2
0
    def qmlink_to_rest(self, parent, artifacts):

        links = [(a, default_importer(a)) for a in artifacts]

        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):

        # cleanup missingTRfile
        with open(MISSING_TR_LOG, 'w') as fd:
            fd.write("")

        # Precompute sets of (artifact, importer) pairs of relevance
        # to our outputs.

        tc_or_set_links = []
        src_links = []
        for a in artifacts:
            for suba in self.get_testcases(a) + self.get_sources(a):
                if is_tc(suba):
                    tc_or_set_links.append((suba, TestCaseImporter()))
                elif is_tcset(suba):
                    tc_or_set_links.append((suba, TCSetImporter()))
                elif is_source(suba):
                    src_links.append((suba, SourceCodeImporter()))

        mixed_links = src_links + tc_or_set_links

        # Build the html output

        html_output = writer.toctree(
            ['/%s/content' % artifact_hash(*l) for l in mixed_links],
            hidden=True)

        # Then the PDF variant. A bit more work as we need to output
        # intermediate section titles ourselves and we don't want to
        # include the sources there.

        pdf_output = ''
        pdf_output += self.tc_pdf_for(toplevel='Ada',
                                      subdirs=['stmt', 'decision', 'mcdc'],
                                      links=tc_or_set_links)
        pdf_output += self.tc_pdf_for(
            toplevel='Common',
            subdirs=['Report', 'UnitsOfInterest', 'GprFacilities'],
            links=tc_or_set_links)

        output = writer.only(html_output, "html")
        output += writer.only(pdf_output, "latex")

        return output, mixed_links
예제 #4
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
예제 #5
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
예제 #6
0
    def qmlink_to_rest(self, parent, artifacts):

        items = []
        for a in artifacts:
            items += self.get_testcases(a)
            items += self.get_sources(a)

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

        html_output = writer.toctree(['/%s/content' % artifact_hash(*l)
                                      for l in links], hidden=True)

        # We don't include the tests sources in the pdf version
        pdf_output = writer.section('Ada Testcases') + '\n'

        # cleanup missingTRfile
        with open(MISSING_TR_LOG, 'w') as fd:
            fd.write("")

        # stmt
        links_stmt = [l for l in links
                      if not is_source(l[0]) and "stmt" in l[0].full_name]

        if links_stmt:

            links_dict = OrderedDict()

            for l in links_stmt:
                main_desc, desc = self.short_descs_of_main_ancestors(l[0],
                                                                     "stmt")

                if desc not in links_dict:
                    links_dict[desc] = []

                links_dict[desc].append(l)

            pdf_output += writer.subsection('%s' % main_desc) + '\n'

            for desc in links_dict.keys():

                pdf_output += writer.subsubsection(desc) + '\n'

                pdf_output += writer.toctree(['/%s/content' % artifact_hash(*l)
                                             for l in links_dict[desc]],
                                             hidden=True)

        # decision
        links_dec = [l for l in links
                     if not is_source(l[0]) and "decision" in l[0].full_name]

        if links_dec:

            links_dict = OrderedDict()

            for l in links_dec:
                main_desc, desc = self.short_descs_of_main_ancestors(l[0],
                                                                     "decision"
                                                                     )

                if desc not in links_dict:
                    links_dict[desc] = []

                links_dict[desc].append(l)

            pdf_output += writer.role('raw-latex', r'\newpage') + '\n\n'
            pdf_output += writer.subsection('%s' % main_desc) + '\n\n'

            for desc in links_dict.keys():

                pdf_output += writer.subsubsection(desc) + '\n\n'

                pdf_output += writer.toctree(['/%s/content' % artifact_hash(*l)
                                             for l in links_dict[desc]],
                                             hidden=True)

        links_mcdc = [l for l in links
                      if not is_source(l[0]) and "mcdc" in l[0].full_name]

        if links_mcdc:

            links_dict = OrderedDict()

            for l in links_mcdc:
                main_desc, desc = self.short_descs_of_main_ancestors(l[0],
                                                                     "mcdc")

                if desc not in links_dict:
                    links_dict[desc] = []

                links_dict[desc].append(l)

            pdf_output += writer.role('raw-latex', r'\newpage') + '\n\n'
            pdf_output += writer.subsection('%s' % main_desc) + '\n\n'

            for desc in links_dict.keys():

                pdf_output += writer.subsubsection(desc) + '\n\n'

                pdf_output += writer.toctree(['/%s/content' % artifact_hash(*l)
                                             for l in links_dict[desc]],
                                             hidden=True)

        links_rep = [l for l in links
                     if not is_source(l[0]) and "Report" in l[0].full_name]

        if links_rep:

            for l in links_rep:
                main_desc, desc = self.short_descs_of_main_ancestors(l[0],
                                                                     "Report")
                break

            section = "Language-independent Testcases"

            pdf_output += writer.section('%s' % section) + '\n\n'
            pdf_output += writer.subsection('%s' % main_desc) + '\n\n'

            pdf_output += writer.toctree(['/%s/content' % artifact_hash(*l)
                                         for l in links_rep],
                                         hidden=True)

        output = writer.only(html_output, "html")
        output += writer.only(pdf_output, "latex")

        return output, links