Fix #690: Load design/locale overlay files from YAML settings.render_command

When users specified design or locale overlay file paths in their YAML via
settings.render_command.design or settings.render_command.locale, these were
parsed but never actually loaded as overlays. Only CLI flags (--design,
--locale) triggered overlay loading.

Now cli_command_render resolves these paths from the YAML (via the existing
collect_input_file_paths helper) before building arguments, so overlay files
referenced in settings are loaded the same way as CLI-provided ones.
This commit is contained in:
Sina Atalay
2026-03-20 22:08:06 +03:00
parent 847e4f9ea3
commit d5c1e724fa
2 changed files with 50 additions and 5 deletions

View File

@@ -199,6 +199,15 @@ def cli_command_render(
):
input_file_path = pathlib.Path(input_file_name)
# Resolve design/locale overlay files from YAML settings when not
# provided via CLI flags. collect_input_file_paths already handles
# parsing the YAML and resolving paths relative to the input file.
resolved_files = collect_input_file_paths(input_file_path, design, locale, settings)
if design is None and "design" in resolved_files:
design = resolved_files["design"]
if locale is None and "locale" in resolved_files:
locale = resolved_files["locale"]
arguments: BuildRendercvModelArguments = {
"design_yaml_file": design.read_text(encoding="utf-8") if design else None,
"locale_yaml_file": locale.read_text(encoding="utf-8") if locale else None,
@@ -222,11 +231,7 @@ def cli_command_render(
with ProgressPanel(quiet=quiet) as progress_panel:
if watch:
run_function_if_files_change(
list(
collect_input_file_paths(
input_file_path, design, locale, settings
).values()
),
list(resolved_files.values()),
lambda: run_rendercv(input_file_path, progress_panel, **arguments),
)
else:

View File

@@ -204,3 +204,43 @@ class TestCliCommandRender:
typst_file = input_file.parent / "rendercv_output" / "John_Doe_CV.typ"
assert expected_in_output in typst_file.read_text()
@pytest.mark.parametrize(
("render_command_field", "config_content", "expected_in_output"),
[
("design", "design:\n theme: moderncv\n", "Fontin"),
(
"locale",
"locale:\n language: turkish\n",
'locale-catalog-language: "tr"',
),
],
)
def test_loads_overlay_files_from_yaml_settings(
self,
tmp_path,
default_arguments,
render_command_field,
config_content,
expected_in_output,
):
os.chdir(tmp_path)
config_file = tmp_path / f"my_{render_command_field}.yaml"
config_file.write_text(config_content, encoding="utf-8")
# Create a minimal YAML with render_command referencing the overlay file
input_file = tmp_path / "test_cv.yaml"
input_file.write_text(
"cv:\n"
" name: John Doe\n"
"settings:\n"
" render_command:\n"
f" {render_command_field}: my_{render_command_field}.yaml\n",
encoding="utf-8",
)
cli_command_render(input_file_name=input_file, **default_arguments)
typst_file = tmp_path / "rendercv_output" / "John_Doe_CV.typ"
assert expected_in_output in typst_file.read_text()