sample_generator
¶
comment_out_section_sub_fields(yaml_string, *, section_header, next_section_header)
¶
Comment out YAML sub-fields between a section header and the next section.
Why
Sample YAML files show design and locale options as comments so beginners see the structure without being overwhelmed. This splits on exact section boundaries, comments the lines between them, then reassembles.
Parameters:
-
yaml_string(str) –Full YAML string.
-
section_header(str) –The section header line(s) to find (e.g., "design:\n theme: classic\n").
-
next_section_header(str) –The next section header that ends this section's sub-fields.
Returns:
-
str–YAML string with sub-fields of the target section commented out.
Source code in src/rendercv/schema/sample_generator.py
create_sample_cv_file(*, file_path=None, name='John Doe')
¶
Generate a sample YAML file containing only the CV section.
Why
Standalone CV files let users focus on content separately from design, locale, and settings configuration.
Parameters:
-
file_path(Path | None, default:None) –Optional path to write file.
-
name(str, default:'John Doe') –Person's full name.
Returns:
-
str | None–YAML string if file_path is None, otherwise None after writing file.
Source code in src/rendercv/schema/sample_generator.py
create_sample_design_file(*, file_path=None, theme='classic')
¶
Generate a sample YAML file containing only the design section.
Why
Standalone design files let users explore all theme options without mixing in CV content or locale settings.
Parameters:
-
file_path(Path | None, default:None) –Optional path to write file.
-
theme(str, default:'classic') –Design theme identifier.
Returns:
-
str | None–YAML string if file_path is None, otherwise None after writing file.
Source code in src/rendercv/schema/sample_generator.py
create_sample_locale_file(*, file_path=None, locale='english')
¶
Generate a sample YAML file containing only the locale section.
Why
Standalone locale files let users customize language and date formatting independently from CV content and design.
Parameters:
-
file_path(Path | None, default:None) –Optional path to write file.
-
locale(str, default:'english') –Language/date format identifier.
Returns:
-
str | None–YAML string if file_path is None, otherwise None after writing file.
Source code in src/rendercv/schema/sample_generator.py
create_sample_rendercv_pydantic_model(*, name='John Doe', theme='classic', locale='english')
¶
Build sample CV model from sample content.
Why
New users need working examples to understand structure. Sample content provides realistic content that validates successfully and renders to all output formats without errors.
Parameters:
-
name(str, default:'John Doe') –Person's full name.
-
theme(str, default:'classic') –Design theme identifier.
-
locale(str, default:'english') –Locale language identifier.
Returns:
-
RenderCVModel–Validated model with sample content.
Source code in src/rendercv/schema/sample_generator.py
create_sample_settings_file(*, file_path=None, omitted_fields=None)
¶
Generate a sample YAML file containing only the settings section.
Why
Standalone settings files let users configure render options independently from CV content, design, and locale.
Parameters:
-
file_path(Path | None, default:None) –Optional path to write file.
Returns:
-
str | None–YAML string if file_path is None, otherwise None after writing file.
Source code in src/rendercv/schema/sample_generator.py
create_sample_yaml_file(*, dictionary, file_path=None)
¶
Convert a dictionary to formatted YAML and optionally write to file.
Why
Multiple sample file generators share the same conversion and file-writing logic. Centralizing it avoids duplication across create_sample_cv_file, create_sample_design_file, etc.
Parameters:
-
dictionary(dict) –Data structure to convert to YAML.
-
file_path(Path | None, default:None) –Optional path to write file.
Returns:
-
str | None–YAML string if file_path is None, otherwise None after writing file.
Source code in src/rendercv/schema/sample_generator.py
create_sample_yaml_input_file(*, file_path=None, name='John Doe', theme='classic', locale='english')
¶
Generate formatted sample YAML with schema hint and commented design options.
Why
New command provides users with immediately usable CV templates. JSON schema hint enables IDE autocompletion, commented design fields show customization options without overwhelming beginners.
Example
Parameters:
-
file_path(Path | None, default:None) –Optional path to write file.
-
name(str, default:'John Doe') –Person's full name.
-
theme(str, default:'classic') –Design theme identifier.
-
locale(str, default:'english') –Language/date format identifier.
Returns:
-
str | None–YAML string if file_path is None, otherwise None after writing file.
Source code in src/rendercv/schema/sample_generator.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
dictionary_to_yaml(dictionary)
¶
Convert dictionary to formatted YAML string with multiline preservation.
Why
Sample YAML generation must produce readable output with proper formatting for multiline strings. Custom representer ensures bullet points and descriptions use pipe syntax.
Parameters:
-
dictionary(dict) –Data structure to convert.
Returns:
-
str–Formatted YAML string.
Source code in src/rendercv/schema/sample_generator.py
expand_nested_bullets(yaml_string)
¶
Expand inline nested bullets in YAML list items to indented sub-items.
Why
YAML dumper renders highlights like "Main point - Sub point" as a
single string. Users expect nested bullets to appear as indented sub-items
in the generated sample file for readability.
Parameters:
-
yaml_string(str) –YAML string with potential inline nested bullets.
Returns:
-
str–YAML string with nested bullets expanded to indented sub-items.
Source code in src/rendercv/schema/sample_generator.py
rendercv_model_to_dictionary(data_model)
¶
Convert a RenderCVModel to a plain dictionary via JSON serialization.
Why
The YAML library sometimes has problems with the dictionary returned by Pydantic's model_dump(). Converting through JSON first produces clean Python dicts that serialize reliably.
Parameters:
-
data_model(RenderCVModel) –Validated RenderCV model.
Returns:
-
dict–Plain dictionary representation of the model.