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
1 change: 1 addition & 0 deletions yardang/sphinx/llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class _MarkdownRenderer:
name = "yardang-llms"
format = "markdown"
default_translator_class = _LlmsMarkdownTranslator
download_dir = "_downloads"

def __init__(self, app: Sphinx):
self.app = app
Expand Down
7 changes: 6 additions & 1 deletion yardang/tests/test_llms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,13 @@ def _write_project(tmp_path: Path, *, full_build: bool = True) -> None:
full-build = {str(full_build).lower()}
"""
)
(tmp_path / "README.md").write_text("# Test Project\n\nProject overview.\n\nSee the [guide](guide.md).\n")
(tmp_path / "README.md").write_text(
"# Test Project\n\nProject overview.\n\nSee the [guide](guide.md).\n\n{download}`Download the sample <files/sample.txt>`.\n"
)
(tmp_path / "guide.md").write_text("# Guide\n\nGuide summary for language models.\n\nReturn to the [overview](index.md).\n")
(tmp_path / "orphan.md").write_text("# Orphan\n\nThis page is not in the toctree.\n")
(tmp_path / "files").mkdir(exist_ok=True)
(tmp_path / "files" / "sample.txt").write_text("sample\n")


def test_generated_configuration_enables_yardang_llms(tmp_path, monkeypatch):
Expand Down Expand Up @@ -68,6 +72,7 @@ def tracked_popen(command, *args, **kwargs):
assert (output / "llms-full.txt").is_file()
assert "(guide.html.md)" in (output / "index.html.md").read_text()
assert "(index.html.md)" in (output / "guide.html.md").read_text()
assert "](_downloads/" in (output / "index.html.md").read_text()

sitemap = (output / "llms.txt").read_text()
assert sitemap.startswith("# Test Project\n\n> A project for LLMs\n")
Expand Down