Skip to content

Commit 15e0bbb

Browse files
committed
- Updated the documentation
1 parent 637a61e commit 15e0bbb

2 files changed

Lines changed: 544 additions & 42 deletions

File tree

README.md

Lines changed: 95 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![PyPI version](https://img.shields.io/pypi/v/py-json-analyzer.svg)](https://pypi.org/project/py-json-analyzer/)
2-
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
2+
[![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](https://www.python.org/downloads/)
33
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
44

55
# JSON Explorer
@@ -21,7 +21,7 @@
2121
### Code Generation
2222

2323
- Generate strongly-typed data structures from JSON
24-
- Multiple language support (Go, with Python, TypeScript, Rust coming soon)
24+
- Multiple language support (Go, Python, with TypeScript and Rust coming soon)
2525
- Smart type detection and conflict resolution
2626
- Configurable naming conventions and templates
2727
- JSON serialization tags and annotations
@@ -38,7 +38,7 @@
3838

3939
## Requirements
4040

41-
- Python >= 3.9
41+
- Python >= 3.11
4242

4343
Required packages:
4444

@@ -92,6 +92,30 @@ pip install -e .
9292
pytest
9393
```
9494

95+
### Test Coverage
96+
97+
The project includes comprehensive tests for:
98+
99+
- **Core modules**: Analysis, search, statistics, tree view, plotting
100+
- **Codegen core modules**: Naming, schema, configuration, templates
101+
- **Generators**: Go and Python with all styles
102+
- **Codegen registry**: Language registration and lookup
103+
- **Codegen integration**: End-to-end workflows
104+
- **Edge cases**: None handling, conflicts, deep nesting
105+
106+
Run specific test suites:
107+
108+
```bash
109+
# Core functionality
110+
pytest tests/test_core.py -v
111+
112+
# Go generator
113+
pytest tests/test_go_generator.py -v
114+
115+
# Python generator
116+
pytest tests/test_python_generator.py -v
117+
```
118+
95119
---
96120

97121
## CLI Usage
@@ -166,6 +190,16 @@ Go-specific options:
166190
--no-omitempty Don't add omitempty to JSON tags in Go
167191
--json-tag-case {original,snake,camel}
168192
Case style for JSON tag names in Go
193+
194+
Python-specific options:
195+
--python-style {dataclass,pydantic,typeddict}
196+
Python code style (default: dataclass)
197+
--no-slots Don't use __slots__ in dataclasses
198+
--frozen Make dataclasses frozen (immutable)
199+
--kw-only Make dataclass fields keyword-only
200+
--no-pydantic-field Don't use Field() in Pydantic models
201+
--pydantic-forbid-extra
202+
Forbid extra fields in Pydantic models
169203
```
170204

171205
### Examples
@@ -192,10 +226,16 @@ json_explorer data.json --search "isinstance(value, int) and value > 10" --searc
192226
json_explorer --list-languages
193227

194228
# Generate Go structs
195-
json_explorer data.json --generate go
229+
json_explorer data.json --generate go --output models.go
230+
231+
# Generate Python dataclasses
232+
json_explorer data.json --generate python --output models.py
233+
234+
# Generate Pydantic models
235+
json_explorer data.json --generate python --python-style pydantic --output models.py
196236

197237
# Generate with custom configuration
198-
json_explorer data.json --generate go --output models.go --package-name models
238+
json_explorer data.json --generate go --package-name models --root-name User
199239

200240
# Interactive code generation
201241
json_explorer data.json --interactive # Then select code generation menu
@@ -282,10 +322,18 @@ from json_explorer.codegen import (
282322
)
283323
from json_explorer.analyzer import analyze_json
284324

285-
# Quick generation
325+
# Quick generation - Go
286326
go_code = quick_generate(test_data, language="go")
287327
print(go_code)
288328

329+
# Quick generation - Python dataclass
330+
python_code = quick_generate(test_data, language="python", style="dataclass")
331+
print(python_code)
332+
333+
# Quick generation - Pydantic model
334+
pydantic_code = quick_generate(test_data, language="python", style="pydantic")
335+
print(pydantic_code)
336+
289337
# Detailed generation workflow
290338
analysis = analyze_json(test_data)
291339
config = create_config(
@@ -307,21 +355,24 @@ print("Supported languages:", languages)
307355
go_info = get_language_info("go")
308356
print("Go generator info:", go_info)
309357

358+
python_info = get_language_info("python")
359+
print("Python generator info:", python_info)
360+
310361
# Interactive code generation
311-
from json_explorer.codegen import create_interactive_handler
362+
from json_explorer.codegen.interactive import CodegenInteractiveHandler
312363

313-
handler = create_interactive_handler(test_data)
364+
handler = CodegenInteractiveHandler(test_data)
314365
handler.run_interactive() # Launches interactive interface
315366
```
316367

317368
### Supported Languages
318369

319-
| Language | Status | Features |
320-
| -------------- | --------------- | ------------------------------------------------ |
321-
| **Go** | ✅ Full Support | Structs, JSON tags, pointers, configurable types |
322-
| **Python** | 🚧 Coming Soon | Dataclasses, Pydantic models, type hints |
323-
| **TypeScript** | 🚧 Coming Soon | Interfaces, types, optional properties |
324-
| **Rust** | 🚧 Coming Soon | Structs, Serde annotations, Option types |
370+
| Language | Status | Features |
371+
| -------------- | --------------- | --------------------------------------------------- |
372+
| **Go** | ✅ Full Support | Structs, JSON tags, pointers, configurable types |
373+
| **Python** | ✅ Full Support | Dataclasses, Pydantic models, TypedDict, type hints |
374+
| **TypeScript** | 🚧 Coming Soon | Interfaces, types, optional properties |
375+
| **Rust** | 🚧 Coming Soon | Structs, Serde annotations, Option types |
325376

326377
### Code Generation Features
327378

@@ -336,7 +387,7 @@ handler.run_interactive() # Launches interactive interface
336387

337388
## Configuration
338389

339-
### Code Generation Config Example
390+
### Go Configuration Example
340391

341392
```json
342393
{
@@ -346,30 +397,53 @@ handler.run_interactive() # Launches interactive interface
346397
"json_tag_omitempty": true,
347398
"struct_case": "pascal",
348399
"field_case": "pascal",
349-
"use_pointers_for_optional": true,
350-
"int_type": "int64",
351-
"float_type": "float64"
400+
"language_config": {
401+
"use_pointers_for_optional": true,
402+
"int_type": "int64",
403+
"float_type": "float64"
404+
}
405+
}
406+
```
407+
408+
### Python Configuration Example
409+
410+
```json
411+
{
412+
"package_name": "models",
413+
"add_comments": true,
414+
"struct_case": "pascal",
415+
"field_case": "snake",
416+
"language_config": {
417+
"style": "pydantic",
418+
"use_optional": true,
419+
"pydantic_use_field": true,
420+
"pydantic_use_alias": true,
421+
"pydantic_config_dict": true
422+
}
352423
}
353424
```
354425

355426
Load configuration:
356427

357428
```bash
358429
json_explorer data.json --generate go --config config.json
430+
json_explorer data.json --generate python --config config.json
359431
```
360432

361433
---
362434

363435
## API Reference
364436

365-
For the complete API reference got to [JSON Explorer API Documentation](https://ms-32154.github.io/py-json-analyzer/) or see the source code.
437+
For the complete API reference go to [JSON Explorer API Documentation](https://ms-32154.github.io/py-json-analyzer/) or see the source code.
366438

367439
---
368440

369441
## License
370442

371443
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
372444

445+
---
446+
373447
## Contributing
374448

375449
Contributions are welcome! Please feel free to submit a Pull Request.
@@ -380,6 +454,8 @@ Contributions are welcome! Please feel free to submit a Pull Request.
380454
4. Push to the branch (`git push origin feature/AmazingFeature`)
381455
5. Open a Pull Request
382456

457+
---
458+
383459
## Support
384460

385461
If you encounter any issues or have questions, please:

0 commit comments

Comments
 (0)