Skip to content

Commit

Permalink
update docstrings (#8117)
Browse files Browse the repository at this point in the history
  • Loading branch information
agnieszka-m authored Jul 30, 2024
1 parent 42f59fc commit 1d4883f
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions haystack/components/converters/txt.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,14 @@
@component
class TextFileToDocument:
"""
Converts text files to Documents.
Converts text files to documents your pipeline can query.
By default, it uses UTF-8 encoding when converting files but
you can also set custom encoding.
It can attach metadata to the resulting documents.
### Usage example
Usage example:
```python
from haystack.components.converters.txt import TextFileToDocument
Expand All @@ -31,12 +36,12 @@ class TextFileToDocument:

def __init__(self, encoding: str = "utf-8"):
"""
Create a TextFileToDocument component.
Creates a TextFileToDocument component.
:param encoding:
The encoding of the text files.
Note that if the encoding is specified in the metadata of a source ByteStream,
it will override this value.
The encoding of the text files to convert.
If the encoding is specified in the metadata of a source ByteStream,
it overrides this value.
"""
self.encoding = encoding

Expand All @@ -47,21 +52,20 @@ def run(
meta: Optional[Union[Dict[str, Any], List[Dict[str, Any]]]] = None,
):
"""
Converts text files to Documents.
Converts text files to documents.
:param sources:
List of HTML file paths or ByteStream objects.
List of HTML file paths or ByteStream objects to convert.
:param meta:
Optional metadata to attach to the Documents.
This value can be either a list of dictionaries or a single dictionary.
If it's a single dictionary, its content is added to the metadata of all produced Documents.
If it's a list, the length of the list must match the number of sources, because the two lists will
be zipped.
If `sources` contains ByteStream objects, their `meta` will be added to the output Documents.
Optional metadata to attach to the documents.
This value can be a list of dictionaries or a single dictionary.
If it's a single dictionary, its content is added to the metadata of all produced documents.
If it's a list, its length must match the number of sources as they're zipped together.
For ByteStream objects, their `meta` is added to the output documents.
:returns:
A dictionary with the following keys:
- `documents`: Created Documents
- `documents`: A list of converted documents.
"""
documents = []

Expand Down

0 comments on commit 1d4883f

Please sign in to comment.