--- jupytext: text_representation: extension: .md format_name: myst format_version: 0.13 jupytext_version: 1.10.3 kernelspec: name: python3 --- # User Guide ## Command Line For command line guide refer to {doc}`/getting_started/index` ## Quick API Walkthrough ### Introduction A resume contains two parts a sidebar and and a main body. {py:mod}`cliriculum.resume.Resume` The sidebar is divided in a contact section in the top corner and another section (generally for skills). `contact` information is set via JSON file, to understand acceptable fields refer to {py:mod}`cliriculum.deserializers.Contact` The other section is defined by a markdown file . The main section is generated by a markdown file and metadata files (JSON files). Two "augmenting" files are accepted respectively one for location data (see {py:mod}`cliriculum.deserializers.location` for available fields) and one for date data (see {py:mod}`cliriculum.deserializers.Dates` for available fields) The contact file would look like: ```JSON { "name":"cliriculum", "profession": "cli", "website": { "url": "https://www.github.com/sondalex/cliriculum", "text":"github.com/sondalex/cliriculum", "classes":"fa-brands fa-github" } } ``` The file for the other section of sidebar would look like: ```markdown # Dependencies * Mistletoe * paged.js ``` The main file would look like: ```markdown # Resume builder Build your resume with only Markdown and JSON. If you wish more customization you can use `css`. ## A Python cli-tool ``` ```{code-cell} ipython3 :tags: [remove-cell] from tempfile import TemporaryDirectory import os from pathlib import Path tmpdir = TemporaryDirectory() tmpdirpath = Path(tmpdir.name) def write(dir, filename, string): with open(dir/ filename, "w") as f: f.write(string) return dir/ filename main_str = """ # Resume builder Build your resume with only Markdown and JSON. If you wish more customization you can use `css`. ## A Python cli-tool """ side_str = """ # Dependencies * Mistletoe * paged.js """ contact_str = """ { "name":"cliriculum", "profession": "cli", "website": {"url":"https://www.github.com/sondalex/cliriculum", "text":"github.com/sondalex/cliriculum", "classes":"fa-brands fa-github"} } """ main_md = write(dir=tmpdirpath, filename="main.md", string=main_str) sidebar_md = write(dir=tmpdirpath, filename="side.md", string=side_str) contact = write(dir=tmpdirpath, filename="contact.json", string=contact_str) # create resume directory if not os.path.exists("resume"): os.mkdir("resume") ``` To generate the HTML representation of the resume: ```{code-cell} ipython3 # :tags: [remove-cell] from cliriculum.resume import Resume resume = Resume() html = resume(sidebar_md=sidebar_md, main_md=main_md, contact=contact) print(html) ``` If you write this HTML to filesystem and serve it via an HTTP server, it won't display correctly, because necessary web resources i.e css stylesheets and JS scripts were not copied. A working HTML resume structure would look like this: ```text index.html paged.polyfill.js style.css style.js fontawesome/ - css/ - all.css - v4-shims.css ``` {py:mod}`cliriculum.utils.copy_resources` copies all those files except `index.html`. Therefore, to create a minimal working resume (note that `resume/` should exist): ```{code-cell} ipython3 from cliriculum.utils import copy_resources copy_resources("resume") with open("resume/index.html", "w") as f: f.write(html) ``` If you open a terminal and run: ```bash cd resume/ python -m http.server ``` open the link with your browser (preferably Chromium based i.e. Chromium, Chrome, Brave, ...) and you'll see how your resume looks like. You can then convert the resume to PDF in a web browser (generally with `ctrl+p` or `cmd+p`) ### Automating PDF creation To generate the PDF on the fly (for instance to automate the procedure) {py:mod}`cliriculum.pdf.chromium_print` is the right utility. ```{code-cell} ipython3 from cliriculum.pdf import chromium_print chromium_print(directory="resume", filename="output.pdf", verbose=True) ``` ### How it looks? ```{code-cell} ipython3 :tags: [remove-input] from IPython.display import display from pdf2image import convert_from_path images = convert_from_path("resume/output.pdf") display(images[0]) ``` ```{code-cell} ipython3 :tags: [remove-cell] tmpdir.cleanup() from shutil import rmtree rmtree("resume") ```