How cookercandle/kadomaker works
Project Type and Purpose
• This is a command-line tool designed to generate PDF flashcards for learning Japanese.
• Its primary purpose is to take a JSON file (files/words.json) containing the flashcards data (with kanji, reading, and translation) and output a formatted PDF. The design supports both landscape and portrait orientations (landscape.py and portrait.py).
Key Components Based on the File Structure
• Entry Point Scripts:
• landscape.py and portrait.py: These are the executable scripts that trigger PDF generation. They serve as the main interfaces to run the application in different layouts.
• Data Files:
• files/words.json: The source of flashcards data.
• files/yumin.ttf (mentioned in the README but not shown in the file tree): A font file, crucial for rendering Japanese scripts correctly.
• Output Directory:
• output/: Contains the generated PDF files (e.g., landscape-dars.pdf and portrait-dars.pdf).
• Core Library Modules (located in the sources directory):
• sources/__init__.py: Initializes the library module.
• sources/fonts.py: Likely handles font-related functionality including loading and setting up custom Japanese fonts.
• sources/words.py: Manages processing and structuring flashcards from the input JSON.
• sources/wrap.py: Takes care of text wrapping for long translations and possibly layouts the flashcards neatly.
• Configuration and Dependency Files:
• requirements.txt: Lists all Python dependencies needed.
• .gitignore, LICENSE, and README.md: Standard project meta-information.
Architectural Patterns & Relationships
• Layered/Modular Design Pattern:
• The project clearly separates the presentation (entry scripts) from the core processing logic (modules in the sources folder).
• Input → Processing → Output Flow:
• Input: The JSON file (files/words.json) provides the flashcards data.
• Processing: The sources modules handle parsing, layout computations, text wrapping, and applying fonts as specified.
• Output: The PDF files are generated and saved in the output folder.
• Separation of Orientation Logic:
• Two distinct scripts (landscape.py and portrait.py) indicate that layout adjustments for different print orientations are handled somewhat separately but reuse the core processing libraries.