MCPcopy
hub / github.com/vinta/awesome-python / render_category

Function render_category

website/build.py:607–646  ·  view source on GitHub ↗
(
        category: TemplateCategory,
        *,
        category_url: str,
        entries: Sequence[TemplateEntry],
        current_path: str,
        page_dir: Path,
        parent_category: ParsedSection | None = None,
        group_categories: Sequence[ParsedSection] | None = None,
    )

Source from the content-addressed store, hash-verified

605 categories_dir = site_dir / "categories"
606
607 def render_category(
608 category: TemplateCategory,
609 *,
610 category_url: str,
611 entries: Sequence[TemplateEntry],
612 current_path: str,
613 page_dir: Path,
614 parent_category: ParsedSection | None = None,
615 group_categories: Sequence[ParsedSection] | None = None,
616 ) -> None:
617 page_dir.mkdir(parents=True, exist_ok=True)
618 parent_name = parent_category["name"] if parent_category else None
619 category_title = category_meta_title(category["name"], parent_name)
620 category_description = category_meta_description(category["name"], len(entries), category["description"], parent_name)
621 breadcrumbs = [("Awesome Python", SITE_URL)]
622 if parent_category:
623 breadcrumbs.append((parent_category["name"], category_public_url(parent_category)))
624 breadcrumbs.append((category["name"], category_url))
625 category_json_ld = json.dumps(
626 build_category_json_ld(category_title.removesuffix(" - Awesome Python"), category_url, category_description, entries, breadcrumbs),
627 ensure_ascii=False,
628 ).replace("</", "<\\/")
629 (page_dir / "index.html").write_text(
630 tpl_category.render(
631 category=category,
632 category_title=category_title,
633 category_url=category_url,
634 category_description=category_description,
635 entries=entries,
636 total_categories=len(categories),
637 category_urls=category_urls,
638 current_path=current_path,
639 filter_urls=filter_urls,
640 filter_urls_json=filter_urls_json,
641 parent_category=parent_category,
642 group_categories=group_categories,
643 category_json_ld=category_json_ld,
644 ),
645 encoding="utf-8",
646 )
647
648 for category in categories:
649 render_category(

Callers 1

buildFunction · 0.85

Calls 4

category_meta_titleFunction · 0.85
category_public_urlFunction · 0.85
build_category_json_ldFunction · 0.85

Tested by

no test coverage detected