Principle:AGI Edgerunners LLM Agents Papers Template Driven Document Generation
| Knowledge Sources | |
|---|---|
| Domains | Document_Generation, Data_Processing |
| Last Updated | 2026-10-10 14:30 GMT |
Overview
A document generation pattern that assembles a structured output document by concatenating independently rendered sections, each driven by a configuration template and grouped data.
Description
Template Driven Document Generation is the practice of building a complete document (like a README.md) by composing it from independently rendered sections. Each section is produced by a dedicated function that takes a config/data input and returns a formatted string. The sections are concatenated in a fixed order to produce the final document.
In this repository, the README.md is generated by assembling five sections:
- Title — the repository name from config
- Description — description text, date, and a category table-of-contents
- Recommendation — recommended resources with links
- Papers — all papers grouped by category and sub-category, sorted by date descending
- Star History — GitHub star history embed
Each section function (parse_description_section, parse_recommendation_section, parse_paper_section) is independently testable and reusable. The orchestrator (init) simply calls them in order and joins the results.
Usage
Use this principle when:
- Generating a structured document (README, report, catalog) from data and configuration
- Different sections of the document have different rendering logic
- The document structure (section order) should be configurable independently of section content
- You want to test or modify individual sections in isolation
Theoretical Basis
The core mechanism is a section composition pipeline:
# Abstract pattern (NOT real implementation)
def generate_document(config, data):
sections = [
render_title(config["Name"]),
render_description(config["Description"]),
render_recommendation(config["Recommendation"]),
render_papers(config["Category_Sort"], data),
render_star_history(config["Star_History"]),
]
return "\n".join(sections)
Key properties:
- Separation of concerns: Each section function handles only its rendering logic
- Composability: Sections are independent and can be reordered or omitted
3. Data-driven: Section content comes from config and parsed data, not hardcoded 4. String concatenation: The simplest possible composition mechanism (\n.join) 5. Recursive nesting: Paper sections nest as category → sub-category → paper items
The tradeoff is simplicity vs. flexibility: simple string concatenation cannot handle complex layouts (like multi-column or conditional sections), but it is easy to understand and maintain for straightforward documents.
Practical Guide
To apply this pattern:
- Identify the document's sections (title, description, body, footer, etc.)
- Write a dedicated render function for each section, taking config/data and returning a string
- Create an orchestrator that calls each section function in order and joins results
- Write the final string to the output file
- For nested sections (like category → sub-category → items), use recursive rendering