mirror of https://github.com/eyhc1/rendercv.git
docs: update reference
This commit is contained in:
parent
d0b285e03a
commit
0f81f49a0c
|
@ -9,7 +9,7 @@ The data models are initialized with data validation to prevent unexpected bugs.
|
||||||
the initialization, we ensure that everything is in the correct place and that the user
|
the initialization, we ensure that everything is in the correct place and that the user
|
||||||
has provided a valid RenderCV input. This is achieved through the use of
|
has provided a valid RenderCV input. This is achieved through the use of
|
||||||
[Pydantic](https://pypi.org/project/pydantic/). Each class method decorated with
|
[Pydantic](https://pypi.org/project/pydantic/). Each class method decorated with
|
||||||
'pydantic.model_validator` or 'pydantic.field_validator` is executed automatically
|
`pydantic.model_validator` or `pydantic.field_validator` is executed automatically
|
||||||
during the data classes' initialization.
|
during the data classes' initialization.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ RenderCVDate = Annotated[
|
||||||
|
|
||||||
def get_date_object(date: str | int) -> Date:
|
def get_date_object(date: str | int) -> Date:
|
||||||
"""Parse a date string in YYYY-MM-DD, YYYY-MM, or YYYY format and return a
|
"""Parse a date string in YYYY-MM-DD, YYYY-MM, or YYYY format and return a
|
||||||
datetime.date object. This function is used throughout the validation process of the
|
`datetime.date` object. This function is used throughout the validation process of
|
||||||
data models.
|
the data models.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
date (str): The date string to parse.
|
date (str): The date string to parse.
|
||||||
|
@ -727,7 +727,7 @@ def get_entry_and_section_type(
|
||||||
def validate_section_input(
|
def validate_section_input(
|
||||||
sections_input: SectionBase | list[Any],
|
sections_input: SectionBase | list[Any],
|
||||||
) -> SectionBase | list[Any]:
|
) -> SectionBase | list[Any]:
|
||||||
"""Validate a SectionInput object and raise an error if it is not valid.
|
"""Validate a `SectionInput` object and raise an error if it is not valid.
|
||||||
|
|
||||||
Sections input is very complex. It is either a `Section` object or a list of
|
Sections input is very complex. It is either a `Section` object or a list of
|
||||||
entries. Since there are multiple entry types, it is not possible to validate it
|
entries. Since there are multiple entry types, it is not possible to validate it
|
||||||
|
@ -737,9 +737,9 @@ def validate_section_input(
|
||||||
validates it directly.
|
validates it directly.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
sections_input (Section | list[Any]): The sections input to validate.
|
sections_input (SectionBase | list[Any]): The sections input to validate.
|
||||||
Returns:
|
Returns:
|
||||||
Section | list[Any]: The validated sections input.
|
SectionBase | list[Any]: The validated sections input.
|
||||||
"""
|
"""
|
||||||
if isinstance(sections_input, list):
|
if isinstance(sections_input, list):
|
||||||
# find the entry type based on the first identifiable entry:
|
# find the entry type based on the first identifiable entry:
|
||||||
|
@ -1138,16 +1138,16 @@ class RenderCVDataModel(RenderCVBaseModel):
|
||||||
def read_input_file(
|
def read_input_file(
|
||||||
file_path: pathlib.Path,
|
file_path: pathlib.Path,
|
||||||
) -> RenderCVDataModel:
|
) -> RenderCVDataModel:
|
||||||
"""Read the input file and return two instances of RenderCVDataModel. The first
|
"""Read the input file and return two instances of
|
||||||
instance is the data model with $\\LaTeX$ strings and the second instance is the
|
[RenderCVDataModel](#rendercv.data_models.RenderCVDataModel). The first instance is
|
||||||
data model with markdown strings.
|
the data model with $\\LaTeX$ strings and the second instance is the data model with
|
||||||
|
markdown strings.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
file_path (str): The path to the input file.
|
file_path (str): The path to the input file.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple[RenderCVDataModel, RenderCVDataModel]: The data models with $\\LaTeX$ and
|
RenderCVDataModel: The data models with $\\LaTeX$ and markdown strings.
|
||||||
markdown strings.
|
|
||||||
"""
|
"""
|
||||||
# check if the file exists:
|
# check if the file exists:
|
||||||
if not file_path.exists():
|
if not file_path.exists():
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
"""
|
"""
|
||||||
This module contains functions and classes for generating a $\\LaTeX$ file from the data
|
This module contains functions and classes for generating CVs as $\\LaTeX$ files, PDF
|
||||||
model and rendering the $\\LaTeX$ file to produce a PDF.
|
files, Markdown files, HTML files, and PNG files from the data model.
|
||||||
|
|
||||||
The $\\LaTeX$ files are generated with
|
The $\\LaTeX$ and Markdown files are generated with
|
||||||
[Jinja2](https://jinja.palletsprojects.com/en/3.1.x/) templates. Then, the $\\LaTeX$
|
[Jinja2](https://jinja.palletsprojects.com/en/3.1.x/) templates. Then, the $\\LaTeX$
|
||||||
file is rendered into a PDF with [TinyTeX](https://yihui.org/tinytex/), a $\\LaTeX$
|
file is rendered into a PDF with [TinyTeX](https://yihui.org/tinytex/), a $\\LaTeX$
|
||||||
distribution.
|
distribution. The markdown file is rendered into an HTML file with markdown package. The
|
||||||
|
PDF files are rendered into PNG files with PyMuPDF/fitz package.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -27,9 +28,10 @@ from . import data_models as dm
|
||||||
|
|
||||||
|
|
||||||
class TemplatedFile:
|
class TemplatedFile:
|
||||||
"""This class is a base class for LaTeXFile and MarkdownFile classes. It contains
|
"""This class is a base class for `LaTeXFile` and `MarkdownFile` classes. It
|
||||||
the common methods and attributes for both classes. These classes are used to
|
contains the common methods and attributes for both classes. These classes are used
|
||||||
generate the $\\LaTeX$ and Markdown files with the data model and Jinja2 templates.
|
to generate the $\\LaTeX$ and Markdown files with the data model and Jinja2
|
||||||
|
templates.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
data_model (dm.RenderCVDataModel): The data model.
|
data_model (dm.RenderCVDataModel): The data model.
|
||||||
|
@ -106,7 +108,7 @@ class TemplatedFile:
|
||||||
|
|
||||||
class LaTeXFile(TemplatedFile):
|
class LaTeXFile(TemplatedFile):
|
||||||
"""This class represents a $\\LaTeX$ file. It generates the $\\LaTeX$ code with the
|
"""This class represents a $\\LaTeX$ file. It generates the $\\LaTeX$ code with the
|
||||||
data model and Jinja2 templates. It inherits from the TemplatedFile class.
|
data model and Jinja2 templates. It inherits from the `TemplatedFile` class.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
|
@ -219,8 +221,8 @@ class LaTeXFile(TemplatedFile):
|
||||||
|
|
||||||
class MarkdownFile(TemplatedFile):
|
class MarkdownFile(TemplatedFile):
|
||||||
"""This class represents a Markdown file. It generates the Markdown code with the
|
"""This class represents a Markdown file. It generates the Markdown code with the
|
||||||
data model and Jinja2 templates. It inherits from the TemplatedFile class. Markdown
|
data model and Jinja2 templates. It inherits from the `TemplatedFile` class.
|
||||||
files are generated to produce a PDF which can be copy-pasted to
|
Markdown files are generated to produce an HTML which can be copy-pasted to
|
||||||
[Grammarly](https://app.grammarly.com/) for proofreading.
|
[Grammarly](https://app.grammarly.com/) for proofreading.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -365,10 +367,10 @@ def escape_latex_characters(string: str, strict: bool = True) -> str:
|
||||||
|
|
||||||
|
|
||||||
def markdown_to_latex(markdown_string: str) -> str:
|
def markdown_to_latex(markdown_string: str) -> str:
|
||||||
"""Convert a markdown string to LaTeX.
|
"""Convert a markdown string to $\\LaTeX$.
|
||||||
|
|
||||||
This function is called during the reading of the input file. Before the validation
|
This function is called during the reading of the input file. Before the validation
|
||||||
process, each input field is converted from markdown to LaTeX.
|
process, each input field is converted from markdown to $\\LaTeX$.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
```python
|
```python
|
||||||
|
@ -830,7 +832,7 @@ def copy_theme_files_to_output_directory(
|
||||||
output_directory_path: pathlib.Path,
|
output_directory_path: pathlib.Path,
|
||||||
):
|
):
|
||||||
"""Copy the auxiliary files (all the files that don't end with `.j2.tex` and `.py`)
|
"""Copy the auxiliary files (all the files that don't end with `.j2.tex` and `.py`)
|
||||||
of the theme to the output directory. For example, the "classic" theme has custom
|
of the theme to the output directory. For example, a theme can have custom
|
||||||
fonts, and the $\\LaTeX$ needs it. If the theme is a custom theme, then it will be
|
fonts, and the $\\LaTeX$ needs it. If the theme is a custom theme, then it will be
|
||||||
copied from the current working directory.
|
copied from the current working directory.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue