Skip to content

API Reference

Dokumentasi API ini dibuat secara otomatis untuk paket generatecv.

Fungsi Inti

Fungsi utama untuk menghasilkan CV dan memuat data.

generatepdf()

Generate a PDF CV from the provided data.

Parameters:

Name Type Description Default
cv_data CV

CV model containing the CV data

required
output_path str

Path where the PDF will be saved

required
style str

Style name for the CV (e.g., 'classic', 'modern', 'minimal')

'classic'
page_size str

Size of the page ('A4' or 'letter')

'A4'

Returns:

Type Description
str

Path to the generated PDF file

Source code in src/generatecv/pdf_generator.py
def generatepdf(
    cv_data: CV, output_path: str, style: str = "classic", page_size: str = "A4"
) -> str:
    """Generate a PDF CV from the provided data.

    Args:
        cv_data: CV model containing the CV data
        output_path: Path where the PDF will be saved
        style: Style name for the CV (e.g., 'classic', 'modern', 'minimal')
        page_size: Size of the page ('A4' or 'letter')

    Returns:
        Path to the generated PDF file
    """
    generator = _PDFGenerator(output_path, cv_data, style, page_size)
    return str(generator.generate())

yamltocv()

Convert YAML file to CV object.

Parameters:

Name Type Description Default
output_path str

Path where the PDF will be saved. If None, a default path is generated.

required
style str

Style name for the CV (e.g., 'classic', 'modern', 'minimal')

'classic'
page_size str

Size of the page ('A4' or 'letter')

'A4'
yaml_path str

Path to the YAML file containing the CV data

required

Returns:

Type Description
CV

CV object created from the YAML data

Source code in src/generatecv/pdf_generator.py
def yamltocv(
    output_path: str, yaml_path: str, style: str = "classic", page_size: str = "A4"
) -> CV:
    """Convert YAML file to CV object.

    Args:
        output_path: Path where the PDF will be saved.
            If None, a default path is generated.
        style: Style name for the CV (e.g., 'classic', 'modern', 'minimal')
        page_size: Size of the page ('A4' or 'letter')
        yaml_path: Path to the YAML file containing the CV data

    Returns:
        CV object created from the YAML data
    """  # Add AI summary generation logic here

    yaml_data = parse_yaml_file(yaml_path)
    cv_data = validate_cv_data(yaml_data)

    return cv_data

Struktur Data Utama (generatecv.models.CV)

Model Pydantic utama yang menampung semua data CV.

Bases: BaseModel

Main CV model that contains all sections.

Source code in src/generatecv/models.py
class CV(BaseModel):
    """Main CV model that contains all sections."""

    personal_info: PersonalInfo = Field(
        description="Personal information of the individual."
    )
    education: list[Education] = Field(
        description="List of educational qualifications."
    )
    experience: list[CompanyExperience] = Field(
        description="List of professional experiences, grouped by company."
    )  # Updated here
    skills: list[Skill] | None = Field(
        default=None, description="List of skills categorized by area."
    )
    projects: list[Project] | None = Field(
        default=None, description="List of personal or professional projects."
    )
    certifications: list[Certificate] | None = Field(
        default=None, description="List of certifications obtained."
    )
    languages: list[Language] | None = Field(
        default=None, description="List of languages spoken and their proficiency."
    )
    references: list[Reference] | None = Field(
        default=None, description="List of professional references."
    )
    publications: list[str] | None = Field(
        default=None, description="List of publications, if any."
    )
    awards: list[str] | None = Field(
        default=None, description="List of awards and honors received."
    )
    interests: list[str] | None = Field(
        default=None, description="List of personal interests or hobbies."
    )
    custom_sections: dict[str, str | list[str]] | None = Field(
        default=None,
        description="Allows for adding custom sections to the CV as key-value pairs, "
        "where value can be a string or list of strings.",
    )

PersonalInfo

Bases: BaseModel

Model for personal information section.

Source code in src/generatecv/models.py
class PersonalInfo(BaseModel):
    """Model for personal information section."""

    name: str = Field(description="Full name of the individual.")
    email: EmailStr = Field(description="Primary email address.")
    phone: str | None = Field(
        default=None, description="Contact phone number (e.g., +1-555-123-4567)."
    )
    location: str | None = Field(
        default=None,
        description="Current city and country of residence (e.g., San Francisco, CA).",
    )
    website: HttpUrl | None = Field(
        default=None, description="Personal website or portfolio URL."
    )
    linkedin: HttpUrl | None = Field(default=None, description="LinkedIn profile URL.")
    github: HttpUrl | None = Field(default=None, description="GitHub profile URL.")
    summary: str | None = Field(
        default=None, description="A brief professional summary or objective statement."
    )
    title: str | None = Field(
        default=None,
        description="Current job title or professional headline "
        "(e.g., Senior Software Engineer).",
    )

Education

Bases: BaseModel

Model for education entries.

Source code in src/generatecv/models.py
class Education(BaseModel):
    """Model for education entries."""

    institution: str = Field(description="Name of the educational institution.")
    degree: str = Field(
        description="Degree obtained (e.g., Bachelor of Science in Computer Science)."
    )
    start_date: str = Field(
        description="Start date of education (e.g., YYYY-MM or Sep 2018)."
    )
    end_date: str | None = Field(
        default=None,
        description="End date of education (e.g., YYYY-MM, Jun 2022, or 'Present').",
    )
    location: str | None = Field(
        default=None, description="Location of the institution (e.g., Stanford, CA)."
    )
    details: str | None = Field(
        default=None, description="Additional details, such as thesis title or honors."
    )
    gpa: str | None = Field(
        default=None, description="Grade Point Average (e.g., 3.8/4.0)."
    )

CompanyExperience

Bases: BaseModel

Model for professional experience at a single company with multiple roles.

This model allows grouping multiple role entries under a single company.

Source code in src/generatecv/models.py
class CompanyExperience(BaseModel):
    """Model for professional experience at a single company with multiple roles.

    This model allows grouping multiple role entries under a single company.
    """

    company: str = Field(description="Name of the company or organization.")
    location: str | None = Field(
        default=None, description="Main location of the company (e.g., New York, NY)."
    )  # Company-level location
    roles: list[Role] = Field(description="List of roles held at this company.")

Role

Bases: BaseModel

Model for a specific role within a company.

Source code in src/generatecv/models.py
class Role(BaseModel):
    """Model for a specific role within a company."""

    title: str = Field(description="Job title or position held.")
    start_date: str = Field(
        description="Start date of this role (e.g., YYYY-MM or Jun 2020)."
    )
    end_date: str | None = Field(
        default=None,
        description="End date of this role (e.g., YYYY-MM, Aug 2022, or 'Present').",
    )
    location: str | None = Field(
        default=None,
        description="Location where this role was performed "
        "(if different from company's main location).",
    )
    description: str | None = Field(
        default=None, description="A brief overview of responsibilities and the role."
    )
    achievements: list[str] | None = Field(
        default=None,
        description="List of key achievements or accomplishments for this role.",
    )

Skill

Bases: BaseModel

Model for skills section.

Source code in src/generatecv/models.py
class Skill(BaseModel):
    """Model for skills section."""

    category: str = Field(
        description="Category of the skill (e.g., Languages, Tools, Frameworks)."
    )
    name: str = Field(description="Name of the skill (e.g., Python, Docker, React).")

Project

Bases: BaseModel

Model for projects section.

Source code in src/generatecv/models.py
class Project(BaseModel):
    """Model for projects section."""

    name: str = Field(description="Name of the project.")
    description: str | None = Field(
        default=None, description="A brief description of the project."
    )
    technologies: list[str] | None = Field(
        default=None, description="List of technologies used in the project."
    )
    link: HttpUrl | None = Field(
        default=None,
        description="URL to the project (e.g., GitHub repository or live demo).",
    )
    start_date: str | None = Field(
        default=None,
        description="Start date of the project (e.g., YYYY-MM or Jan 2021).",
    )
    end_date: str | None = Field(
        default=None,
        description="End date of the project (e.g., YYYY-MM, Mar 2021, or 'Ongoing').",
    )
    achievements: list[str] | None = Field(
        default=None, description="List of key achievements or outcomes of the project."
    )

Certificate

Bases: BaseModel

Model for certifications section.

Source code in src/generatecv/models.py
class Certificate(BaseModel):
    """Model for certifications section."""

    name: str = Field(description="Name of the certificate.")
    issuer: str = Field(description="Issuing organization or authority.")
    date: str | None = Field(
        default=None, description="Date of certification (e.g., YYYY-MM or Oct 2020)."
    )
    description: str | None = Field(
        default=None, description="A brief description of the certification."
    )
    link: HttpUrl | None = Field(
        default=None, description="URL to the certificate or verification page."
    )

Language

Bases: BaseModel

Model for language proficiency.

Source code in src/generatecv/models.py
class Language(BaseModel):
    """Model for language proficiency."""

    name: str = Field(description="Name of the language (e.g., English, Spanish).")
    proficiency: str = Field(
        description="Proficiency level (e.g., Native, Fluent, Conversational)."
    )

Reference

Bases: BaseModel

Model for professional references.

Source code in src/generatecv/models.py
class Reference(BaseModel):
    """Model for professional references."""

    name: str = Field(description="Name of the reference.")
    position: str = Field(description="Position or title of the reference.")
    company: str = Field(description="Company or organization of the reference.")
    contact: str | None = Field(
        default=None,
        description="Contact information (e.g., email or phone). "
        "'Available upon request' is also valid.",
    )
    relation: str | None = Field(
        default=None,
        description="Relationship to the individual (e.g., Former Manager, Colleague).",
    )

Modul Lainnya

Styles

Modul generatecv.styles menangani penampilan visual dari PDF yang dihasilkan.

CVStyle

Bases: ABC

Base class for CV styling.

Source code in src/generatecv/styles/base_style.py
class CVStyle(ABC):
    """Base class for CV styling."""

    def __init__(self) -> None:
        """Initialize the style."""
        self.styles = getSampleStyleSheet()
        self._setup_styles()

    @abstractmethod
    def _setup_styles(self) -> None:
        """Setup the styles. Should be implemented by subclasses."""
        pass

    def get_styles(self) -> StyleSheet1:
        """Get the styles dictionary."""
        return self.styles

__init__()

Initialize the style.

Source code in src/generatecv/styles/base_style.py
def __init__(self) -> None:
    """Initialize the style."""
    self.styles = getSampleStyleSheet()
    self._setup_styles()

get_styles()

Get the styles dictionary.

Source code in src/generatecv/styles/base_style.py
def get_styles(self) -> StyleSheet1:
    """Get the styles dictionary."""
    return self.styles

ClassicStyle

Bases: CVStyle

Classic style for CVs.

Source code in src/generatecv/styles/classic_style.py
class ClassicStyle(CVStyle):
    """Classic style for CVs."""

    def _setup_styles(self) -> None:
        """Setup classic style."""
        # Name style
        self.styles.add(
            ParagraphStyle(
                name="Name",
                parent=self.styles["Heading1"],
                fontSize=16,  # Increased font size
                spaceAfter=4,  # Adjusted spacing
                leading=22,  # Added leading
            )
        )

        # Section headings
        self.styles.add(
            ParagraphStyle(
                name="SectionHeading",
                parent=self.styles["Heading2"],
                fontSize=12,  # Increased font size
                spaceAfter=4,  # Adjusted spacing
                fontName="Times-Bold",
                leading=18,  # Added leading
            )
        )

        # Contact info style
        self.styles.add(
            ParagraphStyle(
                name="ContactInfo",
                parent=self.styles["Normal"],
                fontSize=10,
                spaceAfter=4,  # Adjusted spacing
                leading=12,  # Added leading
            )
        )

        # Experience title style
        self.styles.add(
            ParagraphStyle(
                name="ExperienceTitle",
                parent=self.styles["Normal"],
                fontSize=10,
                fontName="Times-Bold",
                spaceAfter=2,  # Adjusted spacing
                leading=14,  # Added leading
            )
        )

        # Role Title style (new)
        self.styles.add(
            ParagraphStyle(
                name="RoleTitle",
                parent=self.styles["Normal"],
                fontSize=12,
                fontName="Times-Bold",
                leftIndent=0,  # Removed indent
                spaceBefore=3,  # Adjusted spacing
                spaceAfter=2,  # Adjusted spacing
                leading=12,  # Added leading
            )
        )

        # Experience details style
        self.styles.add(
            ParagraphStyle(
                name="ExperienceDetails",
                parent=self.styles["Normal"],
                fontSize=10,
                fontName="Times-Italic",
                leftIndent=0,  # Ensure no indent
                spaceAfter=2,  # Adjusted spacing
                leading=12,  # Added leading
            )
        )

        # Normal text style
        normal_style = self.styles["Normal"]
        normal_style.fontSize = 10
        normal_style.spaceAfter = 6
        normal_style.fontName = "Times-Roman"
        normal_style.leading = 12  # Added leading

        # Paragraph style (similar to Normal)
        self.styles.add(
            ParagraphStyle(
                name="Paragraph",
                parent=self.styles["Normal"],
                fontSize=10,
                spaceAfter=4,
                fontName="Times-Roman",
                leading=12,
                firstLineIndent=15,
            )
        )