mirror of
https://github.com/rendercv/rendercv.git
synced 2025-12-23 21:47:55 -05:00
feat: Add no_html and no_png options to rendercv_settings
This commit adds the `no_html` and `no_png` options to the `rendercv_settings` block in the `John_Doe_ClassicTheme_CV.yaml` file. These options allow the user to control whether the HTML and PNG files will be generated during the rendering process. The default values are set to `true` for `no_html` and `false` for `no_png`.
This commit is contained in:
@@ -143,4 +143,6 @@ design:
|
||||
show_timespan_in: []
|
||||
|
||||
rendercv_settings:
|
||||
output_folder_name: output
|
||||
output_folder_name: output
|
||||
no_html: true
|
||||
no_png: false
|
||||
@@ -105,7 +105,7 @@ def cli_command_render(
|
||||
"-nomd",
|
||||
help="Don't generate the Markdown and HTML file.",
|
||||
),
|
||||
] = False,
|
||||
] = None,
|
||||
dont_generate_html: Annotated[
|
||||
bool,
|
||||
typer.Option(
|
||||
@@ -113,7 +113,7 @@ def cli_command_render(
|
||||
"-nohtml",
|
||||
help="Don't generate the HTML file.",
|
||||
),
|
||||
] = False,
|
||||
] = None,
|
||||
dont_generate_png: Annotated[
|
||||
bool,
|
||||
typer.Option(
|
||||
@@ -121,7 +121,7 @@ def cli_command_render(
|
||||
"-nopng",
|
||||
help="Don't generate the PNG file.",
|
||||
),
|
||||
] = False,
|
||||
] = None,
|
||||
# This is a dummy argument for the help message for
|
||||
# extra_data_model_override_argumets:
|
||||
_: Annotated[
|
||||
@@ -187,10 +187,27 @@ def cli_command_render(
|
||||
data_as_a_dict = utilities.set_or_update_values(
|
||||
data_as_a_dict, key_and_values
|
||||
)
|
||||
# update the data of the rendercv settings:
|
||||
render_cv_settings = data_as_a_dict.get("rendercv_settings", dict())
|
||||
|
||||
data_model = data.validate_input_dictionary_and_return_the_data_model(
|
||||
data_as_a_dict
|
||||
)
|
||||
# update the data model values with cli arguments:
|
||||
if dont_generate_html is not None:
|
||||
data_model.rendercv_settings.no_html = dont_generate_html
|
||||
if dont_generate_markdown is not None:
|
||||
data_model.rendercv_settings.no_markdown = dont_generate_markdown
|
||||
if dont_generate_png is not None:
|
||||
data_model.rendercv_settings.no_png = dont_generate_png
|
||||
|
||||
|
||||
# get the values from the rendercv_settings field of the input file:
|
||||
if data_model.rendercv_settings:
|
||||
printer.information("The following rendercv settings are used:")
|
||||
for key, value in data_model.rendercv_settings.dict().items():
|
||||
if value is not None:
|
||||
printer.information(f"{key}: {value}")
|
||||
|
||||
progress.finish_the_current_step()
|
||||
|
||||
|
||||
@@ -105,7 +105,6 @@ def set_or_update_values(
|
||||
|
||||
return dictionary
|
||||
|
||||
|
||||
def copy_files(paths: list[pathlib.Path] | pathlib.Path, new_path: pathlib.Path):
|
||||
"""Copy files to the given path. If there are multiple files, then rename the new
|
||||
path by adding a number to the end of the path.
|
||||
@@ -260,3 +259,24 @@ def parse_render_command_override_arguments(
|
||||
key_and_values[key] = value
|
||||
|
||||
return key_and_values
|
||||
|
||||
def get_rendercv_settings_dictionary(
|
||||
dictionary: dict,
|
||||
key: str,
|
||||
value: list[str],
|
||||
default_value: str,
|
||||
) -> dict:
|
||||
"""Set or update values in a dictionary for the given keys.
|
||||
|
||||
Args:
|
||||
dictionary (dict): The dictionary to set or update the values.
|
||||
key (str): The key to set or update the value.
|
||||
value (list[str]): The value to set or update. This must contain exactly two elements
|
||||
value[0]: the value provided by cli.
|
||||
value[1]: the value provided by rendercv_settings
|
||||
default_value (str): The default value to be chacked against.
|
||||
"""
|
||||
if not isinstance(value, list) or len(value) != 2:
|
||||
raise ValueError("The value must be a list with exactly two elements")
|
||||
|
||||
return dictionary
|
||||
@@ -52,3 +52,15 @@ class RenderCVDataModel(RenderCVBaseModelWithoutExtraKeys):
|
||||
LocaleCatalog()
|
||||
|
||||
return locale_catalog
|
||||
|
||||
@pydantic.field_validator("rendercv_settings")
|
||||
@classmethod
|
||||
def initialize_rendercv_settings(
|
||||
cls, rendercv_settings: RenderCVSettings
|
||||
) -> RenderCVSettings:
|
||||
"""Even if the rendercv settings are not provided, initialize them with the default
|
||||
values."""
|
||||
if rendercv_settings is None:
|
||||
RenderCVSettings()
|
||||
|
||||
return rendercv_settings
|
||||
|
||||
@@ -63,12 +63,53 @@ class RenderCVSettings(pydantic.BaseModel):
|
||||
),
|
||||
)
|
||||
|
||||
markdown_path: Optional[str] = pydantic.Field(
|
||||
default=None,
|
||||
title="Markdown Path",
|
||||
description=(
|
||||
"The path of the Markdown file. If it is not provided, the Markdown file will"
|
||||
" not be generated. The default value is an empty string."
|
||||
),
|
||||
)
|
||||
|
||||
no_html: Optional[bool] = pydantic.Field(
|
||||
default=False,
|
||||
title="Generate HTML Flag",
|
||||
description=(
|
||||
"A boolean value to determine whether the HTML file will be generated. The"
|
||||
" default value is False."
|
||||
),
|
||||
)
|
||||
|
||||
no_markdown: Optional[bool] = pydantic.Field(
|
||||
default=False,
|
||||
title="Generate Markdown Flag",
|
||||
description=(
|
||||
"A boolean value to determine whether the Markdown file will be generated."
|
||||
" The default value is False."
|
||||
),
|
||||
)
|
||||
|
||||
no_png: Optional[bool] = pydantic.Field(
|
||||
default=False,
|
||||
title="Generate PNG Flag",
|
||||
description=(
|
||||
"A boolean value to determine whether the PNG file will be generated. The"
|
||||
" default value is False."
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
|
||||
@pydantic.field_validator(
|
||||
"output_folder_name",
|
||||
"pdf_path",
|
||||
"latex_path",
|
||||
"html_path",
|
||||
"png_path",
|
||||
"no_html",
|
||||
"no_markdown",
|
||||
"no_png",
|
||||
)
|
||||
@classmethod
|
||||
def update_settings(cls, value: Optional[str], info: pydantic.ValidationInfo) -> Optional[str]:
|
||||
|
||||
18
schema.json
18
schema.json
@@ -2036,6 +2036,24 @@
|
||||
"description": "The path of the PNG file.",
|
||||
"title": "PNG Path",
|
||||
"type": "string"
|
||||
},
|
||||
"no_html": {
|
||||
"default": false,
|
||||
"description": "If this option is set to true, then the HTML file will not be generated. The default value is false.",
|
||||
"title": "No HTML",
|
||||
"type": "boolean"
|
||||
},
|
||||
"no_markdown": {
|
||||
"default": false,
|
||||
"description": "If this option is set to true, then the Markdown file will not be generated. The default value is false.",
|
||||
"title": "No Markdown",
|
||||
"type": "boolean"
|
||||
},
|
||||
"no_png": {
|
||||
"default": false,
|
||||
"description": "If this option is set to true, then the PNG file will not be generated. The default value is false.",
|
||||
"title": "No PNG",
|
||||
"type": "boolean"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user