diff --git a/yardang/build.py b/yardang/build.py index d341907..081f535 100644 --- a/yardang/build.py +++ b/yardang/build.py @@ -622,8 +622,19 @@ def customize(args): fp.write("docs/html\n") if not has_index_md: fp.write("index.md\n") - # yield folder path to sphinx build - yield td + # sphinx-llm starts a nested Sphinx build without forwarding the + # generated configuration directory. Make the same configuration + # available from the source directory for that build. + source_configuration = Path("conf.py") + if use_llms: + source_configuration.write_text(template) + + try: + # yield folder path to sphinx build + yield td + finally: + if use_llms: + source_configuration.unlink(missing_ok=True) @contextmanager diff --git a/yardang/conf.py.j2 b/yardang/conf.py.j2 index 1654791..159cabc 100644 --- a/yardang/conf.py.j2 +++ b/yardang/conf.py.j2 @@ -141,6 +141,8 @@ exclude_patterns = [ ".DS_Store", "node_modules", "_skbuild", + ".venv", + ".venv/*", ".pytest_cache", ".github", ".github/*", diff --git a/yardang/tests/test_all.py b/yardang/tests/test_all.py index c820d09..0b89b6f 100644 --- a/yardang/tests/test_all.py +++ b/yardang/tests/test_all.py @@ -109,6 +109,7 @@ def test_default_excludes_cover_generated_and_repo_docs(self, tmp_path): conf_content = (Path(conf_dir) / "conf.py").read_text() assert '"README.md"' in conf_content assert '"AGENTS.md"' in conf_content + assert '".venv"' in conf_content assert '"docs/.jupyter_cache"' in conf_content assert '"docs/html"' in conf_content finally: diff --git a/yardang/tests/test_llms.py b/yardang/tests/test_llms.py index 65f28c8..cec9260 100644 --- a/yardang/tests/test_llms.py +++ b/yardang/tests/test_llms.py @@ -111,6 +111,9 @@ def test_generate_docs_with_llms_enabled(self, tmp_path): assert "llms_txt_suffix_mode" in conf_content assert "replace" in conf_content assert "A project for LLMs" in conf_content + assert Path("conf.py").read_text() == conf_content + + assert not Path("conf.py").exists() finally: os.chdir(original_cwd)