docs: add a developer guide

This commit is contained in:
Sina Atalay 2024-05-19 00:45:39 +03:00
parent f48882aa33
commit 589bfc7f04
3 changed files with 96 additions and 6 deletions

83
docs/developer_guide.md Normal file
View File

@ -0,0 +1,83 @@
# Developer Guide
This document provides everything you need to know about the development of RenderCV.
## Getting Started
1. Ensure that you have Python version 3.10 or higher.
2. Then, clone the repository recursively (because TinyTeX is being used as a submodule) with the following command.
```bash
git clone --recursive https://github.com/sinaatalay/rendercv.git
```
3. Go to the `rendercv` directory.
```bash
cd rendercv
```
4. Create a virtual environment.
```bash
python -m venv .venv
```
5. Activate the virtual environment.
=== "Windows (PowerShell)"
```powershell
.venv\Scripts\Activate.ps1
```
=== "MacOS/Linux"
```bash
source .venv/bin/activate
```
6. Install the dependencies.
```bash
pip install .[docs,tests,dev]
```
## How RenderCV works?
The flowchart below illustrates the general operations of RenderCV. A detailed documentation of the source code is available in the [reference](reference/index.md).
```mermaid
flowchart TD
A[YAML Input File] --parsing with ruamel.yaml package--> B(Python Dictionary)
B --validation with pydantic package--> C((Pydantic Object))
C --> D[LaTeX File]
C --> E[Markdown File]
E --markdown package--> K[HTML FIle]
D --TinyTeX--> L[PDF File]
L --PyMuPDF package--> Z[PNG Files]
AA[(Jinja2 Templates)] --> D
AA[(Jinja2 Templates)] --> E
```
## Writing Documentation
The documentation's source files are located in the `docs` directory and it is built using the `mkdocs` package. To work on the documentation and see the changes in real-time, run the following command.
```bash
mkdocs serve
```
## Testing
After updating the code, all tests should pass. To run the tests, use the following command.
```bash
pytest
```
### A note about `testdata` folder
In some of the tests:
- RenderCV generates an output with a sample input.
- Then, the output is compared with a reference output, which has been manually generated and stored in `testdata`. If the files differ, the tests fail.
When the `testdata` folder needs to be updated, it can be manually regenerated by setting `update_testdata` to `True` in `conftest.py` and running the tests.
Whenever the `testdata` folder is generated, the files should be reviewed manually to ensure everything works as expected.

View File

@ -71,8 +71,12 @@ markdown_extensions:
line_spans: __span
pygments_lang_class: true
- pymdownx.inlinehilite
- pymdownx.superfences
- pymdownx.extra
- pymdownx.extra:
pymdownx.superfences:
custom_fences:
- name: mermaid
class: mermaid
format: !!python/name:pymdownx.superfences.fence_code_format
- pymdownx.tabbed: # content tabs
alternate_style: true
- toc:

View File

@ -242,9 +242,7 @@ class EntryWithDate(RenderCVBaseModel):
return date_string
class PublicationEntry(EntryWithDate):
"""This class is the data model of `PublicationEntry`."""
class PublicationEntryBase(RenderCVBaseModel):
title: str = pydantic.Field(
title="Title of the Publication",
description="The title of the publication.",
@ -292,6 +290,12 @@ class PublicationEntry(EntryWithDate):
return f"https://doi.org/{self.doi}"
class PublicationEntry(EntryWithDate, PublicationEntryBase):
"""This class is the data model of `PublicationEntry`."""
pass
class EntryBase(EntryWithDate):
"""This class is the parent class of some of the entry types. It is being used
because some of the entry types have common fields like dates, highlights, location,
@ -565,7 +569,6 @@ class EntryBase(EntryWithDate):
class NormalEntryBase(RenderCVBaseModel):
name: str = pydantic.Field(
title="Name",
description="The name of the NormalEntry.",