Compare commits
4
Commits
v0.7.1
...
double-ext
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e37f5483e8 | ||
|
|
10794dce65 | ||
|
|
f6596dd1ec | ||
|
|
29c3932488 |
@@ -10,7 +10,7 @@ jobs:
|
|||||||
pre-commit:
|
pre-commit:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
- name: Set up Python 3.10
|
- name: Set up Python 3.10
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
@@ -23,7 +23,7 @@ jobs:
|
|||||||
python-version: ['3.9', '3.10', '3.11', '3.12']
|
python-version: ['3.9', '3.10', '3.11', '3.12']
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v5
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v6
|
uses: actions/setup-python@v6
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
0.7.2
|
||||||
|
-----
|
||||||
|
|
||||||
|
- Fix double extension in llms.txt URLs when source suffix matches sourcelink suffix
|
||||||
|
`#63 <https://github.com/jdillard/sphinx-llms-txt/issues/63>`_
|
||||||
|
|
||||||
0.7.1
|
0.7.1
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ For optimal LLM support, see the alternative builders below and the :ref:`CMake
|
|||||||
|
|
||||||
.. rubric:: Footnotes
|
.. rubric:: Footnotes
|
||||||
|
|
||||||
.. [#sphinxllm] See `sphinx-llm <https://github.com/jacobtomlinson/sphinx-llm>`_ as an alternative for CMake-free Markdown builds.
|
.. [#sphinxllm] See `sphinx-llm <https://github.com/NVIDIA/sphinx-llm>`_ as an alternative for CMake-free Markdown builds.
|
||||||
.. [#native] Uses raw :confval:`_sources/ <sphinx:html_copy_source>` files created by Sphinx's HTML builder with some minor enhancements.
|
.. [#native] Uses raw :confval:`_sources/ <sphinx:html_copy_source>` files created by Sphinx's HTML builder with some minor enhancements.
|
||||||
.. [#autodoc] Directives like ``autodoc`` will appear as raw directive syntax rather than the extracted docstrings.
|
.. [#autodoc] Directives like ``autodoc`` will appear as raw directive syntax rather than the extracted docstrings.
|
||||||
.. [#pending] PRs that add ``llms-full.txt`` concatenation support have yet to be released.
|
.. [#pending] PRs that add ``llms-full.txt`` concatenation support have yet to be released.
|
||||||
|
|||||||
@@ -26,6 +26,11 @@ Highlights
|
|||||||
Filter content, include source code files, or integrate with alternative output formats like Markdown for even better LLM compatibility.
|
Filter content, include source code files, or integrate with alternative output formats like Markdown for even better LLM compatibility.
|
||||||
See :doc:`getting-started` for output format options and :doc:`configuration-values` for all settings.
|
See :doc:`getting-started` for output format options and :doc:`configuration-values` for all settings.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
For better default output without configuration, see `sphinx-llm <https://github.com/NVIDIA/sphinx-llm>`_ from NVIDIA.
|
||||||
|
sphinx-llms-txt is best when customized with alternative output formats, content filtering, or source code inclusion.
|
||||||
|
|
||||||
.. toctree::
|
.. toctree::
|
||||||
:maxdepth: 2
|
:maxdepth: 2
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ from .manager import LLMSFullManager
|
|||||||
from .processor import DocumentProcessor
|
from .processor import DocumentProcessor
|
||||||
from .writer import FileWriter
|
from .writer import FileWriter
|
||||||
|
|
||||||
__version__ = "0.7.1"
|
__version__ = "0.7.2"
|
||||||
|
|
||||||
# Export classes needed by tests
|
# Export classes needed by tests
|
||||||
__all__ = [
|
__all__ = [
|
||||||
|
|||||||
@@ -163,11 +163,17 @@ class FileWriter:
|
|||||||
|
|
||||||
title = page_titles.get(docname, docname)
|
title = page_titles.get(docname, docname)
|
||||||
|
|
||||||
|
# Avoid duplicate extensions when suffix matches
|
||||||
|
# sourcelink_suffix (e.g., both are ".txt")
|
||||||
|
effective_sourcelink_suffix = sourcelink_suffix
|
||||||
|
if suffix and suffix == sourcelink_suffix:
|
||||||
|
effective_sourcelink_suffix = ""
|
||||||
|
|
||||||
uri = uri_template.format(
|
uri = uri_template.format(
|
||||||
base_url=base_url,
|
base_url=base_url,
|
||||||
docname=docname,
|
docname=docname,
|
||||||
suffix=suffix or "",
|
suffix=suffix or "",
|
||||||
sourcelink_suffix=sourcelink_suffix,
|
sourcelink_suffix=effective_sourcelink_suffix,
|
||||||
)
|
)
|
||||||
|
|
||||||
f.write(f"- [{title}]({uri})\n")
|
f.write(f"- [{title}]({uri})\n")
|
||||||
|
|||||||
@@ -132,6 +132,48 @@ def test_uri_template_custom(tmp_path):
|
|||||||
assert "- [Home Page](https://example.com/raw/index.rst)" in content
|
assert "- [Home Page](https://example.com/raw/index.rst)" in content
|
||||||
|
|
||||||
|
|
||||||
|
def test_uri_template_no_double_extension_when_suffix_matches_sourcelink(tmp_path):
|
||||||
|
"""Test that .txt suffix + .txt sourcelink_suffix doesn't produce .txt.txt URLs."""
|
||||||
|
build_dir = tmp_path / "build"
|
||||||
|
build_dir.mkdir()
|
||||||
|
|
||||||
|
sources_dir = build_dir / "_sources"
|
||||||
|
sources_dir.mkdir()
|
||||||
|
|
||||||
|
class MockApp:
|
||||||
|
class Config:
|
||||||
|
html_sourcelink_suffix = ".txt"
|
||||||
|
|
||||||
|
config = Config()
|
||||||
|
|
||||||
|
config = {
|
||||||
|
"llms_txt_file": True,
|
||||||
|
"llms_txt_filename": "llms.txt",
|
||||||
|
"html_baseurl": "https://example.com",
|
||||||
|
}
|
||||||
|
writer = FileWriter(config, str(build_dir), MockApp())
|
||||||
|
|
||||||
|
page_titles = {
|
||||||
|
"index": "Home Page",
|
||||||
|
"contents": "Table of Contents",
|
||||||
|
}
|
||||||
|
|
||||||
|
# .txt source files — suffix matches sourcelink_suffix
|
||||||
|
page_order = [("index", ".txt"), ("contents", ".txt")]
|
||||||
|
|
||||||
|
writer.write_verbose_info_to_file(page_order, page_titles, 0, sources_dir)
|
||||||
|
|
||||||
|
verbose_file = build_dir / "llms.txt"
|
||||||
|
with open(verbose_file, "r", encoding="utf-8") as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
# Should NOT have double .txt.txt extension
|
||||||
|
assert ".txt.txt" not in content
|
||||||
|
# Should have single .txt extension
|
||||||
|
assert "- [Home Page](https://example.com/_sources/index.txt)" in content
|
||||||
|
assert "- [Table of Contents](https://example.com/_sources/contents.txt)" in content
|
||||||
|
|
||||||
|
|
||||||
def test_uri_template_invalid_fallback(tmp_path):
|
def test_uri_template_invalid_fallback(tmp_path):
|
||||||
"""
|
"""
|
||||||
Test that invalid template falls back to default sources template when
|
Test that invalid template falls back to default sources template when
|
||||||
|
|||||||
Reference in New Issue
Block a user