Render the llms.txt entry point with the curated category catalog.
(
template_text: str,
*,
readme_text: str,
stars_data: dict[str, dict],
categories: Sequence[ParsedSection],
total_entries: int,
)
| 368 | |
| 369 | |
| 370 | def build_llms_txt( |
| 371 | template_text: str, |
| 372 | *, |
| 373 | readme_text: str, |
| 374 | stars_data: dict[str, dict], |
| 375 | categories: Sequence[ParsedSection], |
| 376 | total_entries: int, |
| 377 | ) -> str: |
| 378 | """Render the llms.txt entry point with the curated category catalog.""" |
| 379 | categories_md = annotate_entries_with_stars( |
| 380 | link_llms_category_index_to_canonical_pages( |
| 381 | extract_categories_body(readme_text).rstrip(), |
| 382 | categories, |
| 383 | ), |
| 384 | stars_data, |
| 385 | format_stars=lambda n: f"GitHub stars: {n}", |
| 386 | ) |
| 387 | text_env = Environment(autoescape=False, trim_blocks=True, lstrip_blocks=True) |
| 388 | rendered = text_env.from_string(template_text).render( |
| 389 | site_url=SITE_URL, |
| 390 | github_repo_url="https://github.com/vinta/awesome-python", |
| 391 | contributing_url="https://github.com/vinta/awesome-python/blob/master/CONTRIBUTING.md", |
| 392 | sponsorship_url=SPONSORSHIP_PUBLIC_URL, |
| 393 | sitemap_url=SITEMAP_URL, |
| 394 | categories_md=categories_md, |
| 395 | total_entries=total_entries, |
| 396 | total_categories=len(categories), |
| 397 | ) |
| 398 | return rendered.rstrip() + "\n" |
| 399 | |
| 400 | |
| 401 | def annotate_entries_with_stars( |
no test coverage detected