docs: update reference

This commit is contained in:
Sina Atalay
2024-07-07 15:44:27 +03:00
parent 3c69857b09
commit 14e5ca2b72
20 changed files with 147 additions and 61 deletions

View File

@@ -15,13 +15,15 @@ flowchart TD
A[YAML Input File] --parsing with ruamel.yaml package--> B(Python Dictionary)
B --validation with pydantic package--> C((Pydantic Object))
end
subgraph rendercv.themes
C --> AA[(Jinja2 Templates)]
end
AA --> D
AA --> E
subgraph rendercv.renderer
C --> AA
E[Markdown File] --markdown package--> K[HTML FIle]
D[LaTeX File] --TinyTeX--> L[PDF File]
L --PyMuPDF package--> Z[PNG Files]
AA[(Jinja2 Templates)] --> D
AA[(Jinja2 Templates)] --> E
end
```
@@ -40,12 +42,13 @@ flowchart TD
- [`rendercv_data_model.py`](data/models/rendercv_data_model.md) module contains the `RenderCVDataModel` data model, which is the main data model that defines the whole input file structure.
- [`generator.py`](data/generator.md) module contains all the functions for generating the JSON Schema of the input data format and a sample YAML input file.
- [`reader.py`](data/reader.md) module contains the functions that are used to read the input files.
- [`renderer`](renderer/index.md) package contains utilities for generating the output files.
- [`renderer`](renderer/index.md) package contains the necessary classes and functions for generating the output files from the `RenderCVDataModel` object.
- [`renderer.py`](renderer/renderer.md) module contains the necessary functions for rendering $\\LaTeX$, PDF, Markdown, HTML, and PNG files from the data model.
- [`templater.py`](renderer/templater.md) module contains all the necessary classes and functions for templating the $\\LaTeX$ and Markdown files from the data model.
object.
- [`themes`](themes/index.md) package contains all the built-in themes of RenderCV.
- [`classic`](themes/classic.md)
- [`engineeringresumes`](themes/engineeringresumes.md)
- [`sb2nov`](themes/sb2nov.md)
- [`moderncv`](themes/moderncv.md)
- [`common_models.py`](themes/common_models.md) module contains some standard data models for design options.
- [`classic`](themes/classic.md) package contains the `classic` theme templates and data models for its design options.
- [`engineeringresumes`](themes/engineeringresumes.md) package contains the `engineeringresumes` theme templates and data models for its design options.
- [`sb2nov`](themes/sb2nov.md) package contains the `sb2nov` theme templates and data models for its design options.
- [`moderncv`](themes/moderncv.md) package contains the `moderncv` theme templates and data models for its design options.

View File

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

View File

@@ -0,0 +1,3 @@
# `rendercv.themes.common_models`
::: rendercv.themes.common_models

View File

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

View File

@@ -1,3 +1,3 @@
# Themes
# `rendercv.themes`
::: rendercv.themes

View File

@@ -1,4 +1,8 @@
# Moderncv Theme
# `rendercv.themes.moderncv`
::: rendercv.themes.moderncv
## Jinja Templates
{% for template_name, template in theme_templates["moderncv"].items() %}
## {{ template_name }}

View File

@@ -1,4 +1,8 @@
# Sb2nov Theme
# `rendercv.themes.sb2nov`
::: rendercv.themes.sb2nov
## Jinja Templates
{% for template_name, template in theme_templates["sb2nov"].items() %}
## {{ template_name }}

View File

@@ -139,9 +139,32 @@ def define_env(env):
for theme in data.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()
theme_templates[theme][theme_file.stem] = theme_file.read_text()
# Update the ordering of the theme templates:
order = [
"Preamble.j2",
"Header.j2",
"SectionBeginning.j2",
"SectionEnding.j2",
"TextEntry.j2",
"BulletEntry.j2",
"OneLineEntry.j2",
"EducationEntry.j2",
"ExperienceEntry.j2",
"NormalEntry.j2",
"PublicationEntry.j2",
]
theme_templates[theme] = {key: theme_templates[theme][key] for key in order}
if theme != "markdown":
theme_templates[theme] = {
f"{key}.tex": value for key, value in theme_templates[theme].items()
}
else:
theme_templates[theme] = {
f"{key}.md": value for key, value in theme_templates[theme].items()
}
env.variables["theme_templates"] = theme_templates

View File

@@ -63,28 +63,29 @@ nav:
- Reference: reference/index.md
- cli:
- cli: reference/cli/index.md
- commands: reference/cli/commands.md
- printer: reference/cli/printer.md
- utilities: reference/cli/utilities.md
- commands.py: reference/cli/commands.md
- printer.py: reference/cli/printer.md
- utilities.py: reference/cli/utilities.md
- data:
- data: reference/data/index.md
- models:
- models: reference/data/models/index.md
- base: reference/data/models/base.md
- computers: reference/data/models/computers.md
- entry_types: reference/data/models/entry_types.md
- curriculum_vitae: reference/data/models/curriculum_vitae.md
- design: reference/data/models/design.md
- locale_catalog: reference/data/models/locale_catalog.md
- rendercv_data_model: reference/data/models/rendercv_data_model.md
- generator: reference/data/generator.md
- reader: reference/data/reader.md
- base.py: reference/data/models/base.md
- computers.py: reference/data/models/computers.md
- entry_types.py: reference/data/models/entry_types.md
- curriculum_vitae.py: reference/data/models/curriculum_vitae.md
- design.py: reference/data/models/design.md
- locale_catalog.py: reference/data/models/locale_catalog.md
- rendercv_data_model.py: reference/data/models/rendercv_data_model.md
- generator.py: reference/data/generator.md
- reader.py: reference/data/reader.md
- renderer:
- renderer: reference/renderer/index.md
- renderer: reference/renderer/renderer.md
- templater: reference/renderer/templater.md
- renderer.py: reference/renderer/renderer.md
- templater.py: reference/renderer/templater.md
- themes:
- themes: reference/themes/index.md
- common_models.py: reference/themes/common_models.md
- classic: reference/themes/classic.md
- engineeringresumes: reference/themes/engineeringresumes.md
- sb2nov: reference/themes/sb2nov.md
@@ -124,8 +125,6 @@ plugins:
members_order: source
show_bases: true
docstring_section_style: list
merge_init_into_class: true
show_docstring_attributes: true
docstring_style: google
extra_javascript:

View File

@@ -10,10 +10,12 @@ from typing import Annotated, Any, Type
import pydantic
from ...themes.classic import ClassicThemeOptions
from ...themes.engineeringresumes import EngineeringresumesThemeOptions
from ...themes.moderncv import ModerncvThemeOptions
from ...themes.sb2nov import Sb2novThemeOptions
from ...themes import (
ClassicThemeOptions,
EngineeringresumesThemeOptions,
ModerncvThemeOptions,
Sb2novThemeOptions,
)
from . import entry_types
from .base import RenderCVBaseModel

View File

@@ -216,6 +216,8 @@ class EntryWithDate(RenderCVBaseModel):
class PublicationEntryBase(RenderCVBaseModel):
"""This class is the parent class of the `PublicationEntry` class."""
title: str = pydantic.Field(
title="Publication Title",
description="The title of the publication.",
@@ -282,7 +284,10 @@ class PublicationEntryBase(RenderCVBaseModel):
# then the keys of the EntryWithDate class. The only way to achieve this in Pydantic is
# to do this. The same thing is done for the other classes as well.
class PublicationEntry(EntryWithDate, PublicationEntryBase):
"""This class is the data model of `PublicationEntry`."""
"""This class is the data model of `PublicationEntry`. `PublicationEntry` class is
created by combining the `EntryWithDate` and `PublicationEntryBase` classes to have
the fields in the correct order.
"""
pass
@@ -383,6 +388,8 @@ class EntryBase(EntryWithDate):
class NormalEntryBase(RenderCVBaseModel):
"""This class is the parent class of the `NormalEntry` class."""
name: str = pydantic.Field(
title="Name",
description="The name of the NormalEntry.",
@@ -390,12 +397,17 @@ class NormalEntryBase(RenderCVBaseModel):
class NormalEntry(EntryBase, NormalEntryBase):
"""This class is the data model of `NormalEntry`."""
"""This class is the data model of `NormalEntry`. `NormalEntry` class is created by
combining the `EntryBase` and `NormalEntryBase` classes to have the fields in the
correct order.
"""
pass
class ExperienceEntryBase(RenderCVBaseModel):
"""This class is the parent class of the `ExperienceEntry` class."""
company: str = pydantic.Field(
title="Company",
description="The company name.",
@@ -407,12 +419,17 @@ class ExperienceEntryBase(RenderCVBaseModel):
class ExperienceEntry(EntryBase, ExperienceEntryBase):
"""This class is the data model of `ExperienceEntry`."""
"""This class is the data model of `ExperienceEntry`. `ExperienceEntry` class is
created by combining the `EntryBase` and `ExperienceEntryBase` classes to have the
fields in the correct order.
"""
pass
class EducationEntryBase(RenderCVBaseModel):
"""This class is the parent class of the `EducationEntry` class."""
institution: str = pydantic.Field(
title="Institution",
description="The institution name.",
@@ -430,7 +447,10 @@ class EducationEntryBase(RenderCVBaseModel):
class EducationEntry(EntryBase, EducationEntryBase):
"""This class is the data model of `EducationEntry`."""
"""This class is the data model of `EducationEntry`. `EducationEntry` class is
created by combining the `EntryBase` and `EducationEntryBase` classes to have the
fields in the correct order.
"""
pass

View File

@@ -7,7 +7,7 @@ from typing import Optional
import pydantic
from ...themes.classic import ClassicThemeOptions
from ...themes import ClassicThemeOptions
from .base import RenderCVBaseModel
from .curriculum_vitae import CurriculumVitae
from .design import RenderCVDesign

View File

@@ -1,7 +1,7 @@
"""
The `rendercv.renderer` package contains the necessary classes and functions for
for generating $\\LaTeX$, PDF, Markdown, HTML, and PNG files from the
`RenderCVDataModel` object.
generating $\\LaTeX$, PDF, Markdown, HTML, and PNG files from the `RenderCVDataModel`
object.
The $\\LaTeX$ and Markdown files are generated with
[Jinja2](https://jinja.palletsprojects.com/en/3.1.x/) templates. Then, the $\\LaTeX$

View File

@@ -12,7 +12,6 @@ import sys
from typing import Optional
import fitz
import markdown
from .. import data

View File

@@ -2,3 +2,15 @@
The `rendercv.themes` package contains all the built-in templates and the design data
models for the themes.
"""
from .classic import ClassicThemeOptions
from .engineeringresumes import EngineeringresumesThemeOptions
from .moderncv import ModerncvThemeOptions
from .sb2nov import Sb2novThemeOptions
__all__ = [
"ClassicThemeOptions",
"EngineeringresumesThemeOptions",
"ModerncvThemeOptions",
"Sb2novThemeOptions",
]

View File

@@ -2,7 +2,7 @@ from typing import Literal
import pydantic
from rendercv.themes.base_models import (
from rendercv.themes.common_models import (
EntryAreaMargins,
LaTeXDimension,
Margins,

View File

@@ -1,6 +1,7 @@
"""
The `rendercv.themes.base_models` module contains the base data models for the themes.
To avoid code duplication, the themes are encouraged to inherit from these data models.
The `rendercv.themes.common_models` module contains the standard data models for the
design options. To avoid code duplication, the themes are encouraged to inherit from
these data models.
"""
from typing import Annotated, Literal
@@ -8,6 +9,8 @@ from typing import Annotated, Literal
import pydantic
import pydantic_extra_types.color as pydantic_color
from ..data.models.base import RenderCVBaseModel
# Create a custom type called LaTeXDimension that accepts only strings in a specified
# format.
# This type is used to validate the dimension fields in the design data.
@@ -21,8 +24,13 @@ LaTeXDimension = Annotated[
]
class PageMargins(pydantic.BaseModel):
"""This class is a data model for the page margins."""
class PageMargins(RenderCVBaseModel):
"""This class is a data model for the page margins.
Attributes:
top: The top margin of the page with units. The default value is 2 cm.
"""
top: LaTeXDimension = pydantic.Field(
default="2 cm",
@@ -52,7 +60,7 @@ class PageMargins(pydantic.BaseModel):
)
class SectionTitleMargins(pydantic.BaseModel):
class SectionTitleMargins(RenderCVBaseModel):
"""This class is a data model for the section title margins."""
top: LaTeXDimension = pydantic.Field(
@@ -67,7 +75,7 @@ class SectionTitleMargins(pydantic.BaseModel):
)
class EntryAreaMargins(pydantic.BaseModel):
class EntryAreaMargins(RenderCVBaseModel):
"""This class is a data model for the entry area margins."""
left_and_right: LaTeXDimension = pydantic.Field(
@@ -93,7 +101,7 @@ class EntryAreaMargins(pydantic.BaseModel):
)
class HighlightsAreaMargins(pydantic.BaseModel):
class HighlightsAreaMargins(RenderCVBaseModel):
"""This class is a data model for the highlights area margins."""
top: LaTeXDimension = pydantic.Field(
@@ -115,7 +123,7 @@ class HighlightsAreaMargins(pydantic.BaseModel):
)
class HeaderMargins(pydantic.BaseModel):
class HeaderMargins(RenderCVBaseModel):
"""This class is a data model for the header margins."""
vertical_between_name_and_connections: LaTeXDimension = pydantic.Field(
@@ -144,7 +152,7 @@ class HeaderMargins(pydantic.BaseModel):
)
class Margins(pydantic.BaseModel):
class Margins(RenderCVBaseModel):
"""This class is a data model for the margins."""
page: PageMargins = pydantic.Field(
@@ -174,7 +182,7 @@ class Margins(pydantic.BaseModel):
)
class ThemeOptions(pydantic.BaseModel):
class ThemeOptions(RenderCVBaseModel):
"""This class is a generic data model for the theme options. The themes are
encouraged to inherit from this data model and add their own options, to avoid code
duplication.

View File

@@ -3,7 +3,7 @@ from typing import Literal
import pydantic
import pydantic_extra_types.color as pydantic_color
from rendercv.themes.base_models import (
from rendercv.themes.common_models import (
EntryAreaMargins,
HeaderMargins,
HighlightsAreaMargins,

View File

@@ -2,10 +2,12 @@ from typing import Literal
import pydantic
from rendercv.themes.base_models import LaTeXDimension
from rendercv.themes.common_models import LaTeXDimension
from ...data.models.base import RenderCVBaseModel
class ModerncvThemeOptions(pydantic.BaseModel):
class ModerncvThemeOptions(RenderCVBaseModel):
"""This class is the data model of the theme options for the `moderncv` theme."""
model_config = pydantic.ConfigDict(extra="forbid")

View File

@@ -2,7 +2,7 @@ from typing import Literal
import pydantic
from rendercv.themes.base_models import LaTeXDimension, ThemeOptions
from rendercv.themes.common_models import LaTeXDimension, ThemeOptions
class Sb2novThemeOptions(ThemeOptions):