Use a neutral dotfile in the docling name examples
.gitignore reads as this repository's own file in the helper docstring, the tests and the changelog entry.
This commit is contained in:
parent
8e7e494fd1
commit
e2b930d469
3 changed files with 7 additions and 7 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Dotfiles (`.gitignore`, `.env`) are parsed as their actual format instead of a single unstructured text block. Docling ignores the extension of a name starting with a dot, so converters strip leading dots from the name they hand it.
|
- Dotfiles are parsed as their actual format instead of a single unstructured text block. Docling ignores the extension of a name starting with a dot, so converters strip leading dots from the name they hand it.
|
||||||
|
|
||||||
## [0.71.0] - 2026-07-29
|
## [0.71.0] - 2026-07-29
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ def docling_safe_name(name: str) -> str:
|
||||||
"""Strip leading dots from a filename handed to docling.
|
"""Strip leading dots from a filename handed to docling.
|
||||||
|
|
||||||
Docling ignores the extension of any name starting with a dot, so a name
|
Docling ignores the extension of any name starting with a dot, so a name
|
||||||
derived from a dotfile (".gitignore" -> ".gitignore.md") is classified as
|
derived from a dotfile (".customrc" -> ".customrc.md") is classified as
|
||||||
an unknown format and parsed as one unstructured text block.
|
an unknown format and parsed as one unstructured text block.
|
||||||
"""
|
"""
|
||||||
return name.lstrip(".") or name
|
return name.lstrip(".") or name
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ class TestTextFileHandler:
|
||||||
def test_docling_safe_name(self):
|
def test_docling_safe_name(self):
|
||||||
"""Leading dots are stripped, other names are untouched, and a name of
|
"""Leading dots are stripped, other names are untouched, and a name of
|
||||||
nothing but dots is kept rather than reduced to an empty filename."""
|
nothing but dots is kept rather than reduced to an empty filename."""
|
||||||
assert docling_safe_name(".gitignore.md") == "gitignore.md"
|
assert docling_safe_name(".customrc.md") == "customrc.md"
|
||||||
assert docling_safe_name("notes.md") == "notes.md"
|
assert docling_safe_name("notes.md") == "notes.md"
|
||||||
assert docling_safe_name("...") == "..."
|
assert docling_safe_name("...") == "..."
|
||||||
|
|
||||||
|
|
@ -348,14 +348,14 @@ class TestTextToDoclingWithFormat:
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_dotfile_derived_name_parses_as_markdown(self):
|
async def test_dotfile_derived_name_parses_as_markdown(self):
|
||||||
"""Docling ignores the extension of a stream name starting with a dot,
|
"""Docling ignores the extension of a stream name starting with a dot,
|
||||||
so a name derived from a dotfile (".gitignore" -> ".gitignore.md") must
|
so a name derived from a dotfile (".customrc" -> ".customrc.md") must
|
||||||
be normalized or the whole document collapses to one plain-text block.
|
be normalized or the whole document collapses to one plain-text block.
|
||||||
"""
|
"""
|
||||||
config = AppConfig()
|
config = AppConfig()
|
||||||
converter = DoclingLocalConverter(config)
|
converter = DoclingLocalConverter(config)
|
||||||
|
|
||||||
text = "Overview.\n\n## History\n\n- First item\n- Second item"
|
text = "Overview.\n\n## History\n\n- First item\n- Second item"
|
||||||
doc = await converter.convert_text(text, name=".gitignore.md")
|
doc = await converter.convert_text(text, name=".customrc.md")
|
||||||
labels = [str(getattr(item, "label", "")) for item, _ in doc.iterate_items()]
|
labels = [str(getattr(item, "label", "")) for item, _ in doc.iterate_items()]
|
||||||
assert "section_header" in labels
|
assert "section_header" in labels
|
||||||
assert "list_item" in labels
|
assert "list_item" in labels
|
||||||
|
|
@ -1343,9 +1343,9 @@ class TestDoclingServeConverter:
|
||||||
mock_client.__aexit__ = AsyncMock(return_value=None)
|
mock_client.__aexit__ = AsyncMock(return_value=None)
|
||||||
mock_client_class.return_value = mock_client
|
mock_client_class.return_value = mock_client
|
||||||
|
|
||||||
await converter.convert_text("# Test", name=".gitignore.md")
|
await converter.convert_text("# Test", name=".customrc.md")
|
||||||
uploaded_name = mock_client.post.call_args.kwargs["files"]["files"][0]
|
uploaded_name = mock_client.post.call_args.kwargs["files"]["files"][0]
|
||||||
assert uploaded_name == "gitignore.md"
|
assert uploaded_name == "customrc.md"
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_dotfile_path_uploads_with_detectable_name(self, converter, tmp_path):
|
async def test_dotfile_path_uploads_with_detectable_name(self, converter, tmp_path):
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue