docs: include themes' templates to reference documentation

This commit is contained in:
Sina Atalay 2024-04-30 01:12:59 +03:00
parent 0f81f49a0c
commit 15c4557285
6 changed files with 47 additions and 6 deletions

View File

@ -1,3 +1,10 @@
# Classic Theme
::: rendercv.themes.classic
{% for template_name, template in theme_templates["classic"].items() %}
## {{ template_name }}
```latex
{{ template }}
```
{% endfor %}

View File

@ -1,3 +1,10 @@
# Engineeringresumes Theme
::: rendercv.themes.engineeringresumes
{% for template_name, template in theme_templates["engineeringresumes"].items() %}
## {{ template_name }}
```latex
{{ template }}
```
{% endfor %}

View File

@ -1,3 +1,10 @@
# Moderncv Theme
::: rendercv.themes.moderncv
{% for template_name, template in theme_templates["moderncv"].items() %}
## {{ template_name }}
```latex
{{ template }}
```
{% endfor %}

View File

@ -1,3 +1,10 @@
# Sb2nov Theme
::: rendercv.themes.sb2nov
{% for template_name, template in theme_templates["sb2nov"].items() %}
## {{ template_name }}
```latex
{{ template }}
```
{% endfor %}

View File

@ -7,6 +7,7 @@ import io
import os
import sys
import shutil
from time import thread_time_ns
from typing import Any
import pdfCropMargins
@ -162,6 +163,18 @@ def define_env(env):
env.variables["showcase_entries"] = entries_showcase
# for theme templates reference docs:
themes_path = rendercv_path / "themes"
theme_templates = dict()
for theme in dm.available_themes:
theme_templates[theme] = dict()
for theme_file in themes_path.glob(f"{theme}/*.tex"):
theme_templates[theme][
theme_file.stem.replace(".j2", "")
] = theme_file.read_text()
env.variables["theme_templates"] = theme_templates
def generate_entry_figures():
"""Generate an image for each entry type and theme."""

View File

@ -125,8 +125,8 @@ def get_error_message_and_location_and_value_from_a_custom_error(
def handle_validation_error(exception: pydantic.ValidationError):
"""Take a Pydantic validation error and print the error messages in a nice table.
Pydantic's ValidationError object is a complex object that contains a lot of
information about the error. This function takes a ValidationError object and
Pydantic's `ValidationError` object is a complex object that contains a lot of
information about the error. This function takes a `ValidationError` object and
extracts the error messages, locations, and the input values. Then, it prints them
in a nice table with [Rich](https://rich.readthedocs.io/en/latest/).