def generate_hardware_blocks(): for hardware in config["hardware_definitions"]: hardware_file = open(str(SRCTREE_TOP.joinpath(hardware))) regs = hjson.load(hardware_file, use_decimal=True, object_pairs_hook=validate.checking_dict) if validate.validate(regs) == 0: logging.info("Parsed %s" % (hardware)) else: logging.fatal("Failed to parse %s" % (hardware)) base_path = config["outdir-generated"].joinpath(hardware) base_path.parent.mkdir(parents=True, exist_ok=True) regs_html = open(str( base_path.parent.joinpath(base_path.name + '.registers')), mode='w') gen_html.gen_html(regs, regs_html) regs_html.close() hwcfg_html = open(str( base_path.parent.joinpath(base_path.name + '.hwcfg')), mode='w') gen_cfg_html.gen_cfg_html(regs, hwcfg_html) hwcfg_html.close()
def generate_hardware_blocks(): for hardware in config["hardware_definitions"]: regs = IpBlock.from_path(str(SRCTREE_TOP.joinpath(hardware)), []) hw_path = config["outdir-generated"].joinpath(hardware) dst_path = hw_path.parent dst_path.mkdir(parents=True, exist_ok=True) regs_path = dst_path.joinpath(hw_path.name + '.registers') with open(regs_path, 'w') as regs_file: gen_html.gen_html(regs, regs_file) hwcfg_path = dst_path.joinpath(hw_path.name + '.hwcfg') with open(hwcfg_path, 'w') as hwcfg_file: gen_cfg_html.gen_cfg_html(regs, hwcfg_file)
def render_lowrisc_escape(self, token): # plan eventually to allow lowrisc-doc-hdr=doctype if token.type[:15] == "lowrisc-doc-hdr": return html_data.lowrisc_title_head + token.text + \ html_data.lowrisc_title_tail if token.type == "toc": return html_data.toc_mark_head + token.text + \ html_data.toc_mark_tail if token.type == "regfile": regfile = open(path.join(self.basedir, token.text), 'r', encoding='UTF-8') with regfile: try: obj = hjson.load(regfile, use_decimal=True, object_pairs_hook=validate.checking_dict) except ValueError: raise SystemExit(sys.exc_info()[1]) if validate.validate(obj) == 0: log.info("Generated register object\n") self.regs = obj else: log.warn("Register import failed\n") self.regs = None return "" if token.type == "registers": if self.regs == None: return "<B>Errors parsing registers prevents insertion.</B>" outbuf = io.StringIO() # note for CSS need to escape the mdown class on the div outbuf.write("</div>" + html_data.register_header) gen_html.gen_html(self.regs, outbuf, toclist=self.toc, toclevel=3) outbuf.write(html_data.register_trailer + '<div class="mdown">') generated = outbuf.getvalue() outbuf.close() return generated if token.type == "cfgfile": log.error("Deprecated lowRISC token cfgfile ignored. Config is now"\ " in a single file with the registers!") return "" if token.type == "hwcfg": if self.regs == None: return "<B>Errors parsing configuration prevents insertion.</B>" outbuf = io.StringIO() # note for CSS need to escape the mdown class on the div outbuf.write("</div>" + html_data.hwcfg_header) gen_cfg_html.gen_cfg_html(self.regs, outbuf) outbuf.write(html_data.hwcfg_trailer + '<div class="mdown">') generated = outbuf.getvalue() outbuf.close() return generated if token.type == "section1": # TODO should token.text get parsed to allow markdown in it? id = self.id_from_inner(token.text) self.toc.append((2, token.text, id)) return html_data.section_template.format(cls="section_heading", id=id, inner=token.text) if token.type == "section2": # TODO should token.text get parsed to allow markdown in it? id = self.id_from_inner(token.text) self.toc.append((3, token.text, id)) return html_data.section_template.format(cls="subsection_heading", id=id, inner=token.text) if token.type == "doctree": md_paths = [] return_string = '' subdirs = [path.join(self.basedir, s) for s in token.text.split()] for subdir in sorted(subdirs): md_paths.extend(sorted(Path(subdir).rglob('*.md'))) for md_path in md_paths: rel_md_path = md_path.relative_to(self.basedir) return_string += html_data.doctree_template.format( link=rel_md_path.with_suffix('.html'), text=rel_md_path.with_suffix('')) return html_data.doctree_head + return_string + html_data.doctree_tail bad_tag = '{{% ' + token.type + ' ' + token.text + ' }}' log.warn("Unknown lowRISC tag " + bad_tag) return bad_tag