Skip to content

Commit 00cb859

Browse files
committed
update Documentation
1 parent d003be6 commit 00cb859

File tree

9 files changed

+37
-68
lines changed

9 files changed

+37
-68
lines changed

README.md

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,35 +54,12 @@ The documentation for Nutrient DWS Python Client is also available on [Context7]
5454

5555
## Quick Start
5656

57-
## Authentication
58-
59-
### Direct API Key
60-
61-
Provide your API key directly:
62-
6357
```python
6458
from nutrient_dws import NutrientClient
6559

6660
client = NutrientClient(api_key='your_api_key')
6761
```
6862

69-
### Token Provider
70-
71-
Use an async token provider to fetch tokens from a secure source:
72-
73-
```python
74-
import httpx
75-
from nutrient_dws import NutrientClient
76-
77-
async def get_token():
78-
async with httpx.AsyncClient() as http_client:
79-
response = await http_client.get('/api/get-nutrient-token')
80-
data = response.json()
81-
return data['token']
82-
83-
client = NutrientClient(api_key=get_token)
84-
```
85-
8663
## Direct Methods
8764

8865
The client provides numerous async methods for document processing:
@@ -109,7 +86,7 @@ async def main():
10986
asyncio.run(main())
11087
```
11188

112-
For a complete list of available methods with examples, see the [Methods Documentation](./METHODS.md).
89+
For a complete list of available methods with examples, see the [Methods Documentation](docs/METHODS.md).
11390

11491
## Workflow System
11592

@@ -146,7 +123,7 @@ The workflow system follows a staged approach:
146123
3. Set output format
147124
4. Execute or perform a dry run
148125

149-
For detailed information about the workflow system, including examples and best practices, see the [Workflow Documentation](./WORKFLOW.md).
126+
For detailed information about the workflow system, including examples and best practices, see the [Workflow Documentation](docs/WORKFLOW.md).
150127

151128
## Error Handling
152129

@@ -241,7 +218,7 @@ Quick start for contributors:
241218
5. Ensure type checking passes with mypy
242219
6. Follow Python code style with ruff
243220

244-
For detailed contribution guidelines, see the [Contributing Guide](./CONTRIBUTING.md).
221+
For detailed contribution guidelines, see the [Contributing Guide](docs/CONTRIBUTING.md).
245222

246223
## Project Structure
247224

context7.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"$schema": "https://context7.com/schema/context7.json",
33
"projectTitle": "Nutrient DWS Python Client",
44
"description": "Python client library for Nutrient Document Web Services (DWS) API.\n",
5-
"excludeFolders": ["src", "example", ".github"],
6-
"excludeFiles": ["CONTRIBUTING.md", "coverage-report.md", "METHODS.md", "README.md", "WORKFLOW.md"]
5+
"excludeFolders": ["src", "docs", "example", ".github"],
6+
"excludeFiles": ["README.md"]
77
}
File renamed without changes.

METHODS.md renamed to docs/METHODS.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,32 @@ Parameters:
1919
- `base_url` (optional): Custom API base URL (defaults to `https://api.nutrient.io`)
2020
- `timeout` (optional): Request timeout in milliseconds
2121

22+
#### Authentication
23+
24+
Provide your API key directly:
25+
26+
```python
27+
from nutrient_dws import NutrientClient
28+
29+
client = NutrientClient(api_key='your_api_key')
30+
```
31+
32+
Or use an async token provider to fetch tokens from a secure source:
33+
34+
```python
35+
import httpx
36+
from nutrient_dws import NutrientClient
37+
38+
async def get_token():
39+
async with httpx.AsyncClient() as http_client:
40+
response = await http_client.get('/api/get-nutrient-token')
41+
data = response.json()
42+
return data['token']
43+
44+
client = NutrientClient(api_key=get_token)
45+
```
46+
47+
2248
#### Account Methods
2349

2450
##### get_account_info()
@@ -815,7 +841,7 @@ with open('modified-document.pdf', 'wb') as f:
815841

816842
## Workflow Builder Methods
817843

818-
The workflow builder provides a fluent interface for chaining multiple operations. See [WORKFLOW.md](./WORKFLOW.md) for detailed information about workflow methods including:
844+
The workflow builder provides a fluent interface for chaining multiple operations. See [WORKFLOW.md](WORKFLOW.md) for detailed information about workflow methods including:
819845

820846
- `workflow()` - Create a new workflow builder
821847
- `add_file_part()` - Add file parts to the workflow
File renamed without changes.

examples/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ This will:
6464
2. Extract text from the PDF
6565
3. Add a watermark to the PDF
6666
4. Merge multiple documents
67-
5. Process sample.pdf directly with text extraction and image watermarking
6867

6968
### Workflow Examples
7069

@@ -79,7 +78,6 @@ This will:
7978
2. Create a document merging with watermark workflow
8079
3. Extract text with JSON output
8180
4. Execute a complex multi-step workflow
82-
5. Process sample.pdf using workflow pattern
8381

8482
## Output
8583

@@ -90,5 +88,5 @@ All processed files will be saved to the `output/` directory. You can examine th
9088
For more information about the Nutrient DWS Python Client, refer to:
9189

9290
- [README.md](../README.md) - Main documentation
93-
- [METHODS.md](../METHODS.md) - Direct methods documentation
94-
- [LLM_DOC.md](../LLM_DOC.md) - Complete API documentation
91+
- [METHODS.md](../docs/METHODS.md) - Direct methods documentation
92+
- [WORKFLOW.md](../docs/WORKFLOW.md) - Workflow system documentation

examples/src/direct_method.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -125,38 +125,7 @@ async def merge_documents():
125125
raise error
126126

127127

128-
# Example 5: Process sample.pdf directly
129-
async def process_sample_pdf():
130-
print('\nExample 5: Processing sample.pdf directly')
131128

132-
try:
133-
pdf_path = assets_dir / 'sample.pdf'
134-
135-
# Extract text from sample.pdf
136-
extract_result = await client.extract_text(pdf_path)
137-
extract_output_path = output_dir / 'sample-pdf-extracted-text.json'
138-
with open(extract_output_path, 'w') as f:
139-
json.dump(extract_result['data'], f, indent=2, default=str)
140-
141-
watermark_image_path = assets_dir / 'sample.png'
142-
143-
# Add watermark to sample.pdf
144-
watermark_result = await client.watermark_image(pdf_path, watermark_image_path, {
145-
'opacity': 0.4,
146-
})
147-
148-
watermark_output_path = output_dir / 'sample-pdf-watermarked.pdf'
149-
with open(watermark_output_path, 'wb') as f:
150-
f.write(watermark_result['buffer'])
151-
152-
print('Sample PDF processing successful.')
153-
print(f'Extracted text saved to: {extract_output_path}')
154-
print(f'Watermarked PDF saved to: {watermark_output_path}')
155-
156-
return watermark_output_path
157-
except Exception as error:
158-
print(f'Sample PDF processing failed: {error}')
159-
raise error
160129

161130

162131
# Run all examples
@@ -169,7 +138,6 @@ async def run_examples():
169138
await extract_text(converted_pdf_path)
170139
await add_watermark(converted_pdf_path)
171140
await merge_documents()
172-
await process_sample_pdf()
173141

174142
print('\nAll examples completed successfully!')
175143
except Exception as error:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ where = ["src"]
1111
[tool.setuptools.package-data]
1212
nutrient_dws = [
1313
"py.typed",
14-
"../../WORKFLOW.md",
15-
"../../METHODS.md",
14+
"../../docs/WORKFLOW.md",
15+
"../../docs/METHODS.md",
1616
"../../LLM_DOC.md",
1717
]
1818

src/nutrient_dws/builder/builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ async def execute(
545545
mime_info = BuildOutputs.getMimeTypeForOutput(output_config)
546546
result["success"] = True
547547
result["output"] = ContentOutput(
548-
content=cast("str", response),
548+
content=cast("bytes", response).decode("utf-8"),
549549
mimeType=mime_info["mimeType"],
550550
filename=mime_info.get("filename"),
551551
)

0 commit comments

Comments
 (0)