diff --git a/papyri/render.py b/papyri/render.py index 20f42cda..5b0825db 100644 --- a/papyri/render.py +++ b/papyri/render.py @@ -195,6 +195,10 @@ def GET(ref_map, key, cpath): return siblings +def _uuid(): + return uuid.uuid4().hex + + class HtmlRenderer: def __init__(self, store: GraphStore, *, sidebar, prefix, trailing_html): assert prefix.startswith("/") @@ -218,7 +222,7 @@ def __init__(self, store: GraphStore, *, sidebar, prefix, trailing_html): self.env.globals["unreachable"] = unreachable self.env.globals["sidebar"] = sidebar self.env.globals["dothtml"] = extension - self.env.globals["uuid"] = lambda: uuid.uuid4().hex + self.env.globals["uuid"] = _uuid def compute_graph( self, backrefs: Set[Key], refs: Set[Key], key: Key @@ -380,7 +384,7 @@ class S: backrefs=[[], []], module="*", doc=doc, - parts={"*": []}, + parts=list({"*": []}.items()), version="*", ext="", current_type="", @@ -475,7 +479,8 @@ class D: meta=meta, figmap=figmap, module=package, - parts=parts, + parts_mods=parts.get(package, []), + parts=list(parts.items()), version=version, parts_links=defaultdict(lambda: ""), doc=doc, @@ -501,7 +506,8 @@ class D: logo=logo, meta=meta, module=package, - parts={}, + parts=list({}.items()), + parts_mods=[], version=version, parts_links=defaultdict(lambda: ""), doc=doc, @@ -569,15 +575,17 @@ def render_one( doc.content[k] = self.LR.visit(v) doc.arbitrary = [self.LR.visit(x) for x in doc.arbitrary] + module = qa.split(".")[0] return template.render( current_type=current_type, doc=doc, logo=meta.get("logo", None), version=meta["version"], - module=qa.split(".")[0], + module=module, name=qa.split(":")[-1].split(".")[-1], backrefs=backrefs, - parts=parts, + parts_mods=parts.get(module, []), + parts=list(parts.items()), parts_links=parts_links, graph=graph, meta=meta, @@ -725,6 +733,7 @@ async def _write_api_file( template = self.env.get_template("html.tpl.j2") gfiles = list(self.store.glob((None, None, "module", None))) random.shuffle(gfiles) + for _, key in progress(gfiles, description="Rendering API..."): module, version = key.module, key.version if config.ascii: @@ -869,7 +878,7 @@ class Doc: meta=meta, logo=meta["logo"], module=package, - parts=parts, + parts=list(parts.items()), version=version, parts_links=defaultdict(lambda: ""), doc=doc, @@ -897,7 +906,8 @@ class Doc: meta=meta, logo=logo, module=module, - parts=parts, + parts_mods=parts.get(module, []), + parts=list(parts.items()), version=version, parts_links=defaultdict(lambda: ""), doc=doc, @@ -1188,7 +1198,7 @@ def old_render_one( version=meta["version"], module=qa.split(".")[0], backrefs=backrefs, - parts=parts, + parts=list(parts.items()), parts_links=parts_links, graph=graph, meta=meta, diff --git a/papyri/skeleton.tpl.j2 b/papyri/skeleton.tpl.j2 index fdb647db..2016dff6 100644 --- a/papyri/skeleton.tpl.j2 +++ b/papyri/skeleton.tpl.j2 @@ -6,7 +6,7 @@ - {% for p,links in parts.items() %} + {% for p,links in parts %} {% if links %}