- with open(file_name, "w") as file_handler:
- file_handler.write(rst_header)
- for suite_longname, suite in suites.iteritems():
- suite_name = suite["name"]
- file_handler.write("\n{0}\n{1}\n".format(
- suite_name, get_rst_title_char(
- suite["level"] - file_spec["data-start-level"] - 1) *
- len(suite_name)))
- file_handler.write("\n{0}\n".format(
- suite["doc"].replace('|br|', '\n\n -')))
- if _tests_in_suite(suite_name, input_data.tests(job, build)):
- for tbl_file in table_lst:
- if suite_name in tbl_file:
+ if _tests_in_suite(suite[u"name"], tests):
+ groups = re.search(REGEX_NIC_SHORT, suite[u"name"])
+ nic = groups.group(2) if groups else None
+ if nic is None:
+ continue
+ if chapters[chapter_l1][chapter_l2].get(nic, None) is None:
+ chapters[chapter_l1][chapter_l2][nic] = dict(
+ rst_file=f"{join(table_set, chapter_l1)}_{nic}.rst".
+ replace(u"2n1l-", u""),
+ tables=list()
+ )
+ for idx, tbl_file in enumerate(table_lst):
+ if suite[u"name"] in tbl_file:
+ chapters[chapter_l1][chapter_l2][nic][u"tables"].append(
+ (
+ table_lst.pop(idx),
+ suite[u"doc"].replace(u'|br|', u'\n\n -')
+ )
+ )
+ break
+ titles = {
+ # VPP Perf, MRR
+ u"container_memif": u"LXC/DRC Container Memif",
+ u"crypto": u"IPsec IPv4 Routing",
+ u"hoststack": u"Hoststack Testing",
+ u"ip4": u"IPv4 Routing",
+ u"ip4_tunnels": u"IPv4 Tunnels",
+ u"ip6": u"IPv6 Routing",
+ u"ip6_tunnels": u"IPv6 Tunnels",
+ u"l2": u"L2 Ethernet Switching",
+ u"lb": u"LoadBalancer",
+ u"nfv_density": u"NFV Service Density",
+ u"srv6": u"SRv6 Routing",
+ u"vm_vhost": u"KVM VMs vhost-user",
+ u"vts": u"Virtual Topology System",
+ # VPP Device
+ u"interfaces": u"Interfaces",
+ u"l2bd": u"L2 Bridge-domain",
+ u"l2patch": u"L2 Patch",
+ u"l2xc": u"L2 Cross-connect",
+ }
+
+ order_chapters = file_spec.get(u"order-chapters", None)
+
+ if order_chapters:
+ order_1 = order_chapters.get(u"level-1", None)
+ order_2 = order_chapters.get(u"level-2", None)
+ order_3 = order_chapters.get(u"level-3", None)
+ if not order_1:
+ order_1 = chapters.keys()
+ else:
+ order_1 = None
+ order_2 = None
+ order_3 = None
+
+ for chapter_l1 in order_1:
+ content_l1 = chapters.get(chapter_l1, None)
+ if not content_l1:
+ continue
+ with open(f"{fileset_file_name}/index.rst", u"a") as file_handler:
+ file_handler.write(f" {chapter_l1}\n")
+ l1_file_name = f"{join(fileset_file_name, chapter_l1)}.rst"
+ title = titles.get(chapter_l1, chapter_l1)
+ logging.info(f" Generating {title} ...")
+ with open(l1_file_name, u"w") as file_handler:
+ file_handler.write(
+ f"{title}\n"
+ f"{get_rst_title_char(1) * len(title)}\n\n"
+ f".. toctree::\n\n"
+ )
+
+ if not order_2:
+ order_2 = chapters[chapter_l1].keys()
+ for chapter_l2 in order_2:
+ content_l2 = content_l1.get(chapter_l2, None)
+ if not content_l2:
+ continue
+ if not order_3:
+ order_3 = chapters[chapter_l1][chapter_l2].keys()
+ for chapter_l3 in order_3:
+ content_l3 = content_l2.get(chapter_l3, None)
+ if not content_l3:
+ continue
+ with open(l1_file_name, u"a") as file_handler:
+ item = u"/".join(content_l3[u'rst_file'].split(u'/')[-2:])
+ file_handler.write(f" ../{item}\n")
+ logging.info(f" Writing the file {content_l3[u'rst_file']}")
+ with open(content_l3[u'rst_file'], u"w+") as file_handler:
+ title = f"{chapter_l2}-{chapter_l3}"
+ file_handler.write(
+ f"{rst_header}\n"
+ f"{title}\n"
+ f"{get_rst_title_char(2) * len(title)}\n"
+ )
+ for table in content_l3[u'tables']:
+ title = table[0].split(u"/")[-1].split(u".")[0]