start documenting

This commit is contained in:
Sina Atalay 2023-09-10 21:54:36 +02:00
parent e57eb7aeb1
commit 35876ad39f
14 changed files with 165 additions and 108 deletions

View File

@ -1,2 +0,0 @@
# data_model module
::: rendercv.data_model

View File

@ -1,2 +0,0 @@
# __main__ module
::: rendercv.__main__

View File

@ -1,2 +0,0 @@
# tinytex module
::: rendercv.tinytex

0
docs/contact.md Normal file
View File

View File

@ -1,17 +1,5 @@
# Welcome to MkDocs
# Welcome to RenderCV
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
It's a simple tool to render your CV from a YAML file.
## Commands
* `mkdocs new [dir-name]` - Create a new project.
* `mkdocs serve` - Start the live-reloading docs server.
* `mkdocs build` - Build the documentation site.
* `mkdocs -h` - Print help message and exit.
## Project layout
mkdocs.yml # The configuration file.
docs/
index.md # The documentation homepage.
... # Other markdown pages, images and other files.
It's a work in progress, please come back later.

View File

@ -0,0 +1,2 @@
# Main
::: rendercv.__main__

View File

@ -0,0 +1,3 @@
# Data Model
::: rendercv.data_model

1
docs/reference/index.md Normal file
View File

@ -0,0 +1 @@
Test

View File

@ -0,0 +1,2 @@
# TinyTeX
::: rendercv.tinytex

View File

@ -1,29 +1,51 @@
site_name: My Docs
site_name: RenderCV
site_description: A Python application that creates a CV in PDF from a YAML/JSON input file.
site_url: https://sinaatalay.github.io/rendercv/
repo_name: sinaatalay/rendercv
repo_url: https://github.com/sinaatalay/rendercv
edit_uri: edit/main/docs/
theme:
name: material
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: indigo
accent: indigo
toggle:
icon: material/lightbulb-outline
name: "Switch to dark mode"
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: indigo
accent: indigo
toggle:
icon: material/lightbulb
name: "Switch to light mode"
features:
- content.tabs.link
- content.code.annotate
- content.code.copy
nav:
- Home: index.md
- About: about.md
- Quick Start: index.md
- Contact: contact.md
- License: license.md
- Code Reference:
- __main__.py: code/main.md
- data_model.py: code/data_model.md
- tinytex.py: code/tinytex.md
- __main__.py: reference/__main__.md
- data_model.py: reference/data_model.md
- tinytex.py: reference/tinytex.md
plugins:
- search
- mkdocstrings:
handlers:
python:
paths:
- rendercv
options:
show_root_heading: true
members_order: source
show_bases: true
show_root_members_full_path: true
group_by_category: true
show_category_heading: true
show_symbol_type_heading: true
show_symbol_type_toc: true
docstring_section_style: list
merge_init_into_class: true
docstring_style: sphinx
show_docstring_attributes: true
docstring_style: google

View File

@ -0,0 +1,4 @@
"""RenderCV package
A Python application that creates a CV in PDF from a YAML/JSON input file.
"""

View File

@ -1,3 +1,7 @@
"""
This module is a script to run the RenderCV and generate a CV as a PDF.
"""
import os
import json
import logging
@ -10,7 +14,6 @@ from ruamel.yaml import YAML
from rendercv.data_model import RenderCVDataModel
from rendercv.tinytex import run_latex
if __name__ == "__main__":
# logging config:
logging.basicConfig(
level=logging.DEBUG,
@ -29,7 +32,12 @@ if __name__ == "__main__":
def markdown_to_latex(value: str) -> str:
"""
To be continued...
Convert a markdown string to LaTeX.
:param value: The markdown string to convert.
:type value: str
:return: The LaTeX string.
:rtype: str
"""
if not isinstance(value, str):
raise ValueError("markdown_to_latex should only be used on strings!")
@ -47,7 +55,12 @@ if __name__ == "__main__":
def markdown_url_to_url(value: str) -> bool:
"""
To be continued...
Convert a markdown link to a URL.
:param value: The markdown link to convert.
:type value: str
:return: The URL.
:rtype: str
"""
if not isinstance(value, str):
raise ValueError("markdown_to_latex should only be used on strings!")

View File

@ -1,3 +1,8 @@
"""
This module contains classes and functions to parse a specifically structured YAML or
JSON to generate meaningful data for Python.
"""
from datetime import date as Date
from datetime import datetime
from typing import Literal
@ -46,9 +51,9 @@ def check_spelling(sentence: str) -> str:
It uses pyspellchecker. It can also guess the correct version of the
misspelled word, but it is not used because it is very slow.
:param sentence: the sentence to be checked
:param sentence: The sentence to be checked.
:type sentence: str
:return: the same sentence
:return: The same sentence.
"""
modifiedSentence = sentence.lower() # convert to lower case
modifiedSentence = re.sub(
@ -80,7 +85,15 @@ SpellCheckedString = Annotated[str, AfterValidator(check_spelling)]
def compute_time_span_string(start_date: Date, end_date: Date) -> str:
"""
To be continued...
Compute the time span between two dates and return a string that represents it. For,
example, if the time span is 1 year and 3 months, it will return "1 year 3 months".
:param start_date: The start date.
:type start_date: Date
:param end_date: The end date.
:type end_date: Date
:return: The time span string.
:rtype: str
"""
# calculate the number of days between start_date and end_date:
timeSpanInDays = (end_date - start_date).days
@ -197,6 +210,12 @@ class Design(BaseModel):
class Event(BaseModel):
"""s
aa
Attributes:
test
"""
start_date: Date = None
end_date: Date | Literal["present"] = None
date: str = None
@ -355,9 +374,6 @@ class EducationEntry(Event):
@computed_field
@cached_property
def highlight_strings(self) -> list[SpellCheckedString]:
"""
To be continued...
"""
highlight_strings = []
if self.gpa is not None:

View File

@ -1,7 +1,19 @@
"""
This module implements a handler for TinyTeX.
"""
import os
import subprocess
def run_latex(latexFilePath):
"""
Run LuaLateX on the given LaTeX file and generate a PDF.
:param latexFilePath: The path to the LaTeX file to compile.
:type latexFilePath: str
:return: None
:rtype: None
"""
latexFilePath = os.path.normpath(latexFilePath)
latexFile = os.path.basename(latexFilePath)