39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
from typing import Optional, List
|
|
from pydantic import BaseModel
|
|
|
|
class TaskCard(BaseModel):
|
|
"""Pydantic model representing a task card.
|
|
|
|
Attributes:
|
|
title: The main title of the task.
|
|
subject: Optional subject or domain of the task.
|
|
deadline: Optional due date in ISO format or human readable string.
|
|
deliverable: Optional description of what should be produced.
|
|
criteria: List of acceptance criteria strings.
|
|
"""
|
|
|
|
title: str
|
|
subject: Optional[str] = None
|
|
deadline: Optional[str] = None
|
|
deliverable: Optional[str] = None
|
|
criteria: List[str]
|
|
|
|
def to_markdown(self) -> str:
|
|
"""Return a Markdown representation of the task card.
|
|
|
|
The format follows a simple, readable structure that can be used in
|
|
documentation or issue trackers. Empty optional fields are omitted.
|
|
"""
|
|
lines = [f"# {self.title}"]
|
|
if self.subject:
|
|
lines.append(f"**Subject:** {self.subject}")
|
|
if self.deadline:
|
|
lines.append(f"**Deadline:** {self.deadline}")
|
|
if self.deliverable:
|
|
lines.append(f"**Deliverable:** {self.deliverable}")
|
|
if self.criteria:
|
|
lines.append("## Acceptance Criteria")
|
|
for idx, crit in enumerate(self.criteria, 1):
|
|
lines.append(f"{idx}. {crit}")
|
|
return "\n\n".join(lines)
|