section
¶
available_entry_models = get_args(EntryModel.__value__)
module-attribute
¶
available_entry_type_names = tuple([(entry_type.__name__) for entry_type in available_entry_models] + ['TextEntry'])
module-attribute
¶
characteristic_entry_fields = get_characteristic_entry_fields(available_entry_models)
module-attribute
¶
section_models = {entry_type: (create_section_models(entry_type)) for entry_type in available_entry_models}
module-attribute
¶
Entry = EntryModel | str
¶
EntryModel = OneLineEntry | NormalEntry | ExperienceEntry | EducationEntry | PublicationEntry | BulletEntry | NumberedEntry | ReversedNumberedEntry
¶
ListOfEntries = list[str] | reduce(or_, [(list[entry_type]) for entry_type in available_entry_models])
¶
Section = Annotated[pydantic.json_schema.SkipJsonSchema[Any] | ListOfEntries, pydantic.BeforeValidator(lambda entries: validate_section(entries))]
¶
BaseRenderCVSection
¶
create_section_models(entry_type)
¶
Generate Pydantic model for section containing specific entry type.
Why
Each section validates that all entries match a single type. Dynamic model generation creates type-safe section models with proper validation constraints for each entry type.
Parameters:
-
entry_type(type[EntryModel] | type[str]) –Entry class or str for TextEntry.
Returns:
-
type[BaseRenderCVSection]–Pydantic section model class.
Source code in src/rendercv/schema/models/cv/section.py
dictionary_key_to_proper_section_title(key)
¶
Convert snake_case section key to title case with proper capitalization.
Why
Users write education_and_training in YAML for readability. Rendering
requires "Education and Training" with proper title case rules (lowercase
articles/prepositions).
Example
Parameters:
-
key(str) –Section key from YAML.
Returns:
-
str–Properly capitalized section title.
Source code in src/rendercv/schema/models/cv/section.py
get_characteristic_entry_fields(entry_types)
¶
Calculate unique fields per entry type for automatic type detection.
Why
Users provide entries without explicit type declarations. Detecting
entry type by unique fields (e.g., degree for EducationEntry)
enables automatic routing to correct validators.
Parameters:
-
entry_types(tuple[type[EntryModel], ...]) –Entry type classes to analyze.
Returns:
-
dict[type[EntryModel], set[str]]–Map of entry types to their unique field names.
Source code in src/rendercv/schema/models/cv/section.py
get_entry_type_name_and_section_model(entry)
¶
Infer entry type from entry data and return corresponding section model.
Why
Sections contain mixed raw entry data (dicts/strings) before validation. Type inference via characteristic fields enables routing each entry to its correct validator model.
Parameters:
-
entry(dict[str, str | list[str]] | str | EntryModel | None) –Raw or validated entry data.
Returns:
-
tuple[str, type[BaseRenderCVSection]]–Tuple of entry type name and section model class.
Source code in src/rendercv/schema/models/cv/section.py
get_rendercv_sections(sections)
¶
Transform user's section dictionary into list of typed section objects.
Why
YAML sections are dicts for user convenience (e.g., {education: [...]}).
Template rendering requires list of section objects with title and
entry_type fields. This conversion happens after validation.
Parameters:
-
sections(dict[str, list[Any]] | None) –User's section dictionary with titles as keys.
Returns:
-
list[BaseRenderCVSection]–List of section objects ready for template rendering.
Source code in src/rendercv/schema/models/cv/section.py
validate_section(sections_input)
¶
Validate section entries with automatic type detection and error reporting.
Why
Section validation must infer entry type from first valid entry, then validate all entries against that type. Custom error messages identify detected type and aggregate nested validation errors.
Parameters:
-
sections_input(Any) –Raw section data (list of entries).
Returns:
-
Any–Validated list of entry instances.