renderer: refactor

This commit is contained in:
Sina Atalay 2024-03-10 19:07:00 +01:00
parent 5e69373419
commit b1907acaa4
1 changed files with 11 additions and 65 deletions

View File

@ -47,27 +47,9 @@ class TemplatedFile:
def template( def template(
self, self,
theme_name: str, theme_name: str,
template_name: Literal[ template_name: str,
"EducationEntry",
"ExperienceEntry",
"NormalEntry",
"PublicationEntry",
"OneLineEntry",
"TextEntry",
"Header",
"Preamble",
"SectionBeginning",
"SectionEnding",
],
extension: str, extension: str,
entry: Optional[ entry: Optional[dm.Entry] = None,
dm.EducationEntry
| dm.ExperienceEntry
| dm.NormalEntry
| dm.PublicationEntry
| dm.OneLineEntry
| str # TextEntry
] = None,
section_title: Optional[str] = None, section_title: Optional[str] = None,
is_first_entry: Optional[bool] = None, is_first_entry: Optional[bool] = None,
) -> str: ) -> str:
@ -75,8 +57,7 @@ class TemplatedFile:
Args: Args:
template_name (str): The name of the template file. template_name (str): The name of the template file.
entry (Optional[dm.EducationEntry, dm.ExperienceEntry, dm.NormalEntry,dm.PublicationEntry, dm.OneLineEntry, str]): The data model of the entry. entry (Optional[dm.Entry]): The title of the section.
section_title (Optional[str]): The title of the section.
is_first_entry (Optional[bool]): Whether the entry is the first one in the is_first_entry (Optional[bool]): Whether the entry is the first one in the
section. section.
@ -175,26 +156,8 @@ class LaTeXFile(TemplatedFile):
def template( def template(
self, self,
template_name: Literal[ template_name: str,
"EducationEntry", entry: Optional[dm.Entry] = None,
"ExperienceEntry",
"NormalEntry",
"PublicationEntry",
"OneLineEntry",
"TextEntry",
"Header",
"Preamble",
"SectionBeginning",
"SectionEnding",
],
entry: Optional[
dm.EducationEntry
| dm.ExperienceEntry
| dm.NormalEntry
| dm.PublicationEntry
| dm.OneLineEntry
| str # TextEntry
] = None,
section_title: Optional[str] = None, section_title: Optional[str] = None,
is_first_entry: Optional[bool] = None, is_first_entry: Optional[bool] = None,
) -> str: ) -> str:
@ -202,7 +165,7 @@ class LaTeXFile(TemplatedFile):
Args: Args:
template_name (str): The name of the template file. template_name (str): The name of the template file.
entry (Optional[dm.EducationEntry, dm.ExperienceEntry, dm.NormalEntry,dm.PublicationEntry, dm.OneLineEntry, str]): The data model of the entry. entry (Optional[dm.Entry]): The data model of the entry.
section_title (Optional[str]): The title of the section. section_title (Optional[str]): The title of the section.
is_first_entry (Optional[bool]): Whether the entry is the first one in the section. is_first_entry (Optional[bool]): Whether the entry is the first one in the section.
@ -280,26 +243,8 @@ class MarkdownFile(TemplatedFile):
def template( def template(
self, self,
template_name: Literal[ template_name: str,
"EducationEntry", entry: Optional[dm.Entry] = None,
"ExperienceEntry",
"NormalEntry",
"PublicationEntry",
"OneLineEntry",
"TextEntry",
"Header",
"Preamble",
"SectionBeginning",
"SectionEnding",
],
entry: Optional[
dm.EducationEntry
| dm.ExperienceEntry
| dm.NormalEntry
| dm.PublicationEntry
| dm.OneLineEntry
| str # TextEntry
] = None,
section_title: Optional[str] = None, section_title: Optional[str] = None,
is_first_entry: Optional[bool] = None, is_first_entry: Optional[bool] = None,
) -> str: ) -> str:
@ -307,9 +252,10 @@ class MarkdownFile(TemplatedFile):
Args: Args:
template_name (str): The name of the template file. template_name (str): The name of the template file.
entry (Optional[dm.EducationEntry, dm.ExperienceEntry, dm.NormalEntry,dm.PublicationEntry, dm.OneLineEntry, str]): The data model of the entry. entry (Optional[dm.Entry]): The data model of the entry.
section_title (Optional[str]): The title of the section. section_title (Optional[str]): The title of the section.
is_first_entry (Optional[bool]): Whether the entry is the first one in the section. is_first_entry (Optional[bool]): Whether the entry is the first one in the
section.
Returns: Returns:
str: The templated file. str: The templated file.