Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion yardang/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ def customize(args):
llms_args = {}
for config_option, default in {
"llms_enabled": False,
"llms_description": "",
"llms_description": get_config(section="description", base="project") or "",
"llms_full_build": True,
}.items():
toml_key = config_option.replace("llms_", "").replace("_", "-")
Expand Down
33 changes: 33 additions & 0 deletions yardang/tests/test_llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path
from subprocess import Popen

import pytest
import toml
from sphinx.cmd.build import build_main

from yardang.build import generate_docs_configuration
Expand Down Expand Up @@ -51,6 +53,37 @@ def test_generated_configuration_enables_yardang_llms(tmp_path, monkeypatch):
assert not (tmp_path / "conf.py").exists()


@pytest.mark.parametrize("config_base", ["tool.yardang", "tool.custom.docs"])
@pytest.mark.parametrize(
("llms_description", "project_description", "expected"),
[
(None, "Project overview", "Project overview"),
("LLM overview", "Project overview", "LLM overview"),
(None, None, "General documentation description"),
("", "Project overview", "General documentation description"),
],
)
def test_llms_description_fallback(tmp_path, monkeypatch, config_base, llms_description, project_description, expected):
_write_project(tmp_path)
configuration = toml.load(tmp_path / "pyproject.toml")
if project_description is not None:
configuration["project"]["description"] = project_description
llms_configuration = configuration["tool"]["yardang"]["llms"]
if llms_description is None:
del llms_configuration["description"]
else:
llms_configuration["description"] = llms_description
if config_base == "tool.custom.docs":
configuration["tool"]["custom"] = {"docs": configuration["tool"].pop("yardang")}
(tmp_path / "pyproject.toml").write_text(toml.dumps(configuration))
monkeypatch.chdir(tmp_path)

with generate_docs_configuration(config_base=config_base, description="General documentation description") as conf_dir:
conf_content = (Path(conf_dir) / "conf.py").read_text()

assert f'yardang_llms_description = """{expected}"""' in conf_content


def test_build_generates_llms_outputs_in_one_sphinx_process(tmp_path, monkeypatch):
_write_project(tmp_path)
monkeypatch.chdir(tmp_path)
Expand Down