mirror of https://github.com/eyhc1/rendercv.git
add more sections
This commit is contained in:
parent
d60a604741
commit
631e9d594c
|
@ -272,9 +272,15 @@ def generate_json_schema(output_directory: str) -> str:
|
||||||
# Don't allow additional properties
|
# Don't allow additional properties
|
||||||
value["additionalProperties"] = False
|
value["additionalProperties"] = False
|
||||||
|
|
||||||
|
# I don't want the docstrings in the schema, so remove them:
|
||||||
if "This class" in value["description"]:
|
if "This class" in value["description"]:
|
||||||
del value["description"]
|
del value["description"]
|
||||||
|
|
||||||
|
# If a type is optional, then Pydantic sets the type to a list of two
|
||||||
|
# types, one of which is null. The null type can be removed since we
|
||||||
|
# already have the required field. Moreover, we would like to warn
|
||||||
|
# users if they provide null values. They can remove the fields if they
|
||||||
|
# don't want to provide them.
|
||||||
null_type_dict = {}
|
null_type_dict = {}
|
||||||
null_type_dict["type"] = "null"
|
null_type_dict["type"] = "null"
|
||||||
for field in value["properties"].values():
|
for field in value["properties"].values():
|
||||||
|
@ -286,6 +292,18 @@ def generate_json_schema(output_directory: str) -> str:
|
||||||
field["allOf"] = [field["anyOf"][0]]
|
field["allOf"] = [field["anyOf"][0]]
|
||||||
del field["anyOf"]
|
del field["anyOf"]
|
||||||
|
|
||||||
|
# In date field, we both accept normal strings and Date objects. They
|
||||||
|
# are both strings, therefore, if user provides a Date object, then
|
||||||
|
# JSON schema will complain that it matches two different types.
|
||||||
|
# Remember that all of the anyOfs are changed to oneOfs. Only one of
|
||||||
|
# the types can be matched. Therefore, we remove the first type, which
|
||||||
|
# is the string with the YYYY-MM-DD format.
|
||||||
|
if (
|
||||||
|
"date" in value["properties"]
|
||||||
|
and "anyOf" in value["properties"]["date"]
|
||||||
|
):
|
||||||
|
del value["properties"]["date"]["anyOf"][0]
|
||||||
|
|
||||||
return json_schema
|
return json_schema
|
||||||
|
|
||||||
schema = RenderCVDataModel.model_json_schema(
|
schema = RenderCVDataModel.model_json_schema(
|
||||||
|
@ -365,16 +383,11 @@ class ClassicThemeEntryAreaMargins(BaseModel):
|
||||||
[ExperienceEntry](../user_guide.md#experienceentry).
|
[ExperienceEntry](../user_guide.md#experienceentry).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
left: LaTeXDimension = Field(
|
left_and_right: LaTeXDimension = Field(
|
||||||
default="0.2 cm",
|
default="0.2 cm",
|
||||||
title="Left Margin",
|
title="Left Margin",
|
||||||
description="The left margin of entry areas.",
|
description="The left margin of entry areas.",
|
||||||
)
|
)
|
||||||
right: LaTeXDimension = Field(
|
|
||||||
default="0.2 cm",
|
|
||||||
title="Right Margin",
|
|
||||||
description="The right margin of entry areas.",
|
|
||||||
)
|
|
||||||
|
|
||||||
vertical_between: LaTeXDimension = Field(
|
vertical_between: LaTeXDimension = Field(
|
||||||
default="0.12 cm",
|
default="0.12 cm",
|
||||||
|
@ -578,9 +591,7 @@ class Design(BaseModel):
|
||||||
|
|
||||||
LaTeXString = Annotated[str, AfterValidator(escape_latex_characters)]
|
LaTeXString = Annotated[str, AfterValidator(escape_latex_characters)]
|
||||||
PastDate = Annotated[
|
PastDate = Annotated[
|
||||||
str,
|
str, Field(pattern=r"\d{4}-?(\d{2})?-?(\d{2})?"), AfterValidator(parse_date_string)
|
||||||
Field(pattern=r"\d{4}-?(\d{2})?-?(\d{2})?"),
|
|
||||||
AfterValidator(parse_date_string),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1166,6 +1177,7 @@ class CurriculumVitae(BaseModel):
|
||||||
title="Summary",
|
title="Summary",
|
||||||
description="The summary of the person.",
|
description="The summary of the person.",
|
||||||
)
|
)
|
||||||
|
# Sections:
|
||||||
section_order: Optional[list[str]] = Field(
|
section_order: Optional[list[str]] = Field(
|
||||||
default=None,
|
default=None,
|
||||||
title="Section Order",
|
title="Section Order",
|
||||||
|
@ -1223,7 +1235,7 @@ class CurriculumVitae(BaseModel):
|
||||||
title="Test Scores",
|
title="Test Scores",
|
||||||
description="The test score entries of the person.",
|
description="The test score entries of the person.",
|
||||||
)
|
)
|
||||||
programming_skills: Optional[list[OneLineEntry]] = Field(
|
programming_skills: Optional[list[NormalEntry]] = Field(
|
||||||
default=None,
|
default=None,
|
||||||
title="Programming Skills",
|
title="Programming Skills",
|
||||||
description="The programming skill entries of the person.",
|
description="The programming skill entries of the person.",
|
||||||
|
@ -1233,6 +1245,11 @@ class CurriculumVitae(BaseModel):
|
||||||
title="Skills",
|
title="Skills",
|
||||||
description="The skill entries of the person.",
|
description="The skill entries of the person.",
|
||||||
)
|
)
|
||||||
|
other_skills: Optional[list[OneLineEntry]] = Field(
|
||||||
|
default=None,
|
||||||
|
title="Skills",
|
||||||
|
description="The skill entries of the person.",
|
||||||
|
)
|
||||||
awards: Optional[list[OneLineEntry]] = Field(
|
awards: Optional[list[OneLineEntry]] = Field(
|
||||||
default=None,
|
default=None,
|
||||||
title="Awards",
|
title="Awards",
|
||||||
|
@ -1317,6 +1334,7 @@ class CurriculumVitae(BaseModel):
|
||||||
"Education": self.education,
|
"Education": self.education,
|
||||||
"Experience": self.experience,
|
"Experience": self.experience,
|
||||||
"Work Experience": self.work_experience,
|
"Work Experience": self.work_experience,
|
||||||
|
"Publications": self.publications,
|
||||||
"Projects": self.projects,
|
"Projects": self.projects,
|
||||||
"Academic Projects": self.academic_projects,
|
"Academic Projects": self.academic_projects,
|
||||||
"Personal Projects": self.personal_projects,
|
"Personal Projects": self.personal_projects,
|
||||||
|
@ -1324,30 +1342,16 @@ class CurriculumVitae(BaseModel):
|
||||||
"Extracurricular Activities": self.extracurricular_activities,
|
"Extracurricular Activities": self.extracurricular_activities,
|
||||||
"Test Scores": self.test_scores,
|
"Test Scores": self.test_scores,
|
||||||
"Skills": self.skills,
|
"Skills": self.skills,
|
||||||
|
"Programming Skills": self.programming_skills,
|
||||||
|
"Other Skills": self.other_skills,
|
||||||
"Awards": self.awards,
|
"Awards": self.awards,
|
||||||
"Interests": self.interests,
|
"Interests": self.interests,
|
||||||
"Programming Skills": self.programming_skills,
|
"Programming Skills": self.programming_skills,
|
||||||
"Publications": self.publications,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.section_order is None:
|
if self.section_order is None:
|
||||||
# If the user didn't specify the section order, then use the default order:
|
# If the user didn't specify the section order, then use the default order:
|
||||||
self.section_order = [
|
self.section_order = list(pre_defined_sections.keys())
|
||||||
"Education",
|
|
||||||
"Experience",
|
|
||||||
"Work Experience",
|
|
||||||
"Projects",
|
|
||||||
"Academic Projects",
|
|
||||||
"Personal Projects",
|
|
||||||
"Skills",
|
|
||||||
"Awards",
|
|
||||||
"Interests",
|
|
||||||
"Programming Skills",
|
|
||||||
"Test Scores",
|
|
||||||
"Certificates",
|
|
||||||
"Extracurricular Activities",
|
|
||||||
"Publications",
|
|
||||||
]
|
|
||||||
if self.custom_sections is not None:
|
if self.custom_sections is not None:
|
||||||
# If the user specified custom sections, then add them to the end of the
|
# If the user specified custom sections, then add them to the end of the
|
||||||
# section order with the same order as they are in the input file:
|
# section order with the same order as they are in the input file:
|
||||||
|
|
50
schema.json
50
schema.json
|
@ -2,20 +2,13 @@
|
||||||
"$defs": {
|
"$defs": {
|
||||||
"ClassicThemeEntryAreaMargins": {
|
"ClassicThemeEntryAreaMargins": {
|
||||||
"properties": {
|
"properties": {
|
||||||
"left": {
|
"left_and_right": {
|
||||||
"default": "0.2 cm",
|
"default": "0.2 cm",
|
||||||
"description": "The left margin of entry areas.",
|
"description": "The left margin of entry areas.",
|
||||||
"pattern": "\\d+\\.?\\d* *(cm|in|pt|mm|ex|em)",
|
"pattern": "\\d+\\.?\\d* *(cm|in|pt|mm|ex|em)",
|
||||||
"title": "Left Margin",
|
"title": "Left Margin",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"right": {
|
|
||||||
"default": "0.2 cm",
|
|
||||||
"description": "The right margin of entry areas.",
|
|
||||||
"pattern": "\\d+\\.?\\d* *(cm|in|pt|mm|ex|em)",
|
|
||||||
"title": "Right Margin",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
"vertical_between": {
|
"vertical_between": {
|
||||||
"default": "0.12 cm",
|
"default": "0.12 cm",
|
||||||
"description": "The vertical margin between entry areas.",
|
"description": "The vertical margin between entry areas.",
|
||||||
|
@ -93,8 +86,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"default": {
|
"default": {
|
||||||
"left": "0.2 cm",
|
"left_and_right": "0.2 cm",
|
||||||
"right": "0.2 cm",
|
|
||||||
"vertical_between": "0.12 cm"
|
"vertical_between": "0.12 cm"
|
||||||
},
|
},
|
||||||
"description": "Entry area margins for the classic theme.",
|
"description": "Entry area margins for the classic theme.",
|
||||||
|
@ -164,8 +156,7 @@
|
||||||
],
|
],
|
||||||
"default": {
|
"default": {
|
||||||
"entry_area": {
|
"entry_area": {
|
||||||
"left": "0.2 cm",
|
"left_and_right": "0.2 cm",
|
||||||
"right": "0.2 cm",
|
|
||||||
"vertical_between": "0.12 cm"
|
"vertical_between": "0.12 cm"
|
||||||
},
|
},
|
||||||
"highlights_area": {
|
"highlights_area": {
|
||||||
|
@ -482,7 +473,7 @@
|
||||||
"allOf": [
|
"allOf": [
|
||||||
{
|
{
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/$defs/OneLineEntry"
|
"$ref": "#/$defs/NormalEntry"
|
||||||
},
|
},
|
||||||
"type": "array"
|
"type": "array"
|
||||||
}
|
}
|
||||||
|
@ -501,6 +492,19 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"other_skills": {
|
||||||
|
"default": null,
|
||||||
|
"description": "The skill entries of the person.",
|
||||||
|
"title": "Skills",
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/$defs/OneLineEntry"
|
||||||
|
},
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"awards": {
|
"awards": {
|
||||||
"default": null,
|
"default": null,
|
||||||
"description": "The award entries of the person.",
|
"description": "The award entries of the person.",
|
||||||
|
@ -668,10 +672,6 @@
|
||||||
},
|
},
|
||||||
"date": {
|
"date": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-?(\\d{2})?-?(\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -838,10 +838,6 @@
|
||||||
},
|
},
|
||||||
"date": {
|
"date": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-?(\\d{2})?-?(\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -957,10 +953,6 @@
|
||||||
},
|
},
|
||||||
"date": {
|
"date": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-?(\\d{2})?-?(\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -1070,10 +1062,6 @@
|
||||||
},
|
},
|
||||||
"date": {
|
"date": {
|
||||||
"oneOf": [
|
"oneOf": [
|
||||||
{
|
|
||||||
"pattern": "\\d{4}-?(\\d{2})?-?(\\d{2})?",
|
|
||||||
"type": "string"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
@ -1566,8 +1554,7 @@
|
||||||
"date_and_location_width": "3.6 cm",
|
"date_and_location_width": "3.6 cm",
|
||||||
"margins": {
|
"margins": {
|
||||||
"entry_area": {
|
"entry_area": {
|
||||||
"left": "0.2 cm",
|
"left_and_right": "0.2 cm",
|
||||||
"right": "0.2 cm",
|
|
||||||
"vertical_between": "0.12 cm"
|
"vertical_between": "0.12 cm"
|
||||||
},
|
},
|
||||||
"highlights_area": {
|
"highlights_area": {
|
||||||
|
@ -1616,6 +1603,7 @@
|
||||||
"label": null,
|
"label": null,
|
||||||
"location": null,
|
"location": null,
|
||||||
"name": "John Doe",
|
"name": "John Doe",
|
||||||
|
"other_skills": null,
|
||||||
"personal_projects": null,
|
"personal_projects": null,
|
||||||
"phone": null,
|
"phone": null,
|
||||||
"programming_skills": null,
|
"programming_skills": null,
|
||||||
|
|
Loading…
Reference in New Issue