Add configuration option

This commit is contained in:
Jared Dillard
2025-05-16 13:41:14 -07:00
parent b51f3b099a
commit 69e251171d
5 changed files with 117 additions and 26 deletions
+36
View File
@@ -1,6 +1,8 @@
"""Integration tests for sphinx-llms-txt."""
import sys
from pathlib import Path
from sphinx.testing.util import _clean_up_global_state
def test_build_html_with_llms_txt(basic_sphinx_app):
@@ -68,3 +70,37 @@ def test_custom_filename(temp_dir, rootdir):
# Safe unlink that works with older Python versions
if hasattr(app, "docutils_conf_path") and app.docutils_conf_path.exists():
app.docutils_conf_path.unlink()
def test_max_lines_limit(temp_dir, rootdir):
"""Test that the max lines limit works correctly."""
from sphinx.testing.util import SphinxTestApp
src_dir = rootdir / "basic"
# Create a new test app with a small line limit
app = SphinxTestApp(
srcdir=src_dir,
builddir=temp_dir,
buildername="html",
freshenv=True,
confoverrides={
"llms_txt_filename": "limited.txt",
"llms_txt_max_lines": 10, # Set a small limit to trigger the warning
"llms_txt_verbose": True,
},
)
app.build()
# Check that the output file was NOT created (since it would exceed the limit)
output_file = Path(app.outdir) / "limited.txt"
assert not output_file.exists(), f"Output file {output_file} exists but should not when limit is exceeded"
# Custom cleanup to avoid missing_ok issue
sys.path[:] = app._saved_path
_clean_up_global_state()
# Safe unlink
if hasattr(app, "docutils_conf_path") and app.docutils_conf_path.exists():
app.docutils_conf_path.unlink()
+1
View File
@@ -60,6 +60,7 @@ def test_set_config():
config = {
"llms_txt_filename": "custom.txt",
"llms_txt_verbose": True,
"llms_txt_max_lines": 1000,
}
manager.set_config(config)
assert manager.config == config