def has_toc_yaml(self, subnode: nodes.Element, tocdict: Dict[str, nodes.Element], depth: int) -> None: """constructs toc nodes from globaltoc dict :param subnode: node to which toc constructed here is appended to :param tocdict: dictionary of toc entries :param depth: current toclevel depth """ depth += 1 for key, val in tocdict.items(): if key in ["file", "url"]: internal = False if "title" in tocdict: title = tocdict["title"] else: if val not in self.env.titles: continue title = clean_astext(self.env.titles[val]) if "url" in tocdict: if "http" in tocdict["url"]: internal = False else: continue else: val = "%" + val internal = True reference = nodes.reference( "", "", internal=internal, refuri=val, anchorname="", *[nodes.Text(title)], ) para = addnodes.compact_paragraph("", "", reference) item = nodes.list_item("", para) item["classes"].append("tableofcontents-l%d" % (depth)) subnode.append(item) if key in ["sections"]: sectionlist = nodes.bullet_list().deepcopy() sectionheader = None for item in val: if "part" in item: sectionheader = handle_toc_header(item["part"]) sectionlist.append(sectionheader) del item["part"] has_toc_yaml(self, sectionlist, item, depth) else: has_toc_yaml(self, sectionlist, item, depth) subnode.append(sectionlist)