drf-to-mkdoc 0.3.0__py3-none-any.whl → 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of drf-to-mkdoc might be problematic. Click here for more details.
- drf_to_mkdoc/conf/defaults.py +1 -2
- drf_to_mkdoc/conf/settings.py +2 -1
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/settings-modal.js +361 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/form-manager.js +136 -17
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/request-executor.js +18 -2
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/filter-section.css +10 -5
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/settings-modal.css +555 -0
- drf_to_mkdoc/templates/endpoints/list/base.html +1 -0
- drf_to_mkdoc/templates/endpoints/list/filter_section.html +3 -1
- drf_to_mkdoc/templates/endpoints/list/settings_modal.html +138 -0
- drf_to_mkdoc/templates/try-out/form.html +1 -1
- drf_to_mkdoc/utils/endpoint_detail_generator.py +1 -1
- drf_to_mkdoc/utils/endpoint_list_generator.py +2 -0
- drf_to_mkdoc/utils/schema.py +10 -1
- drf_to_mkdoc-0.3.2.dist-info/METADATA +232 -0
- {drf_to_mkdoc-0.3.0.dist-info → drf_to_mkdoc-0.3.2.dist-info}/RECORD +19 -16
- drf_to_mkdoc-0.3.0.dist-info/METADATA +0 -315
- {drf_to_mkdoc-0.3.0.dist-info → drf_to_mkdoc-0.3.2.dist-info}/WHEEL +0 -0
- {drf_to_mkdoc-0.3.0.dist-info → drf_to_mkdoc-0.3.2.dist-info}/licenses/LICENSE +0 -0
- {drf_to_mkdoc-0.3.0.dist-info → drf_to_mkdoc-0.3.2.dist-info}/top_level.txt +0 -0
|
@@ -1,315 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: drf-to-mkdoc
|
|
3
|
-
Version: 0.3.0
|
|
4
|
-
Summary: Generate Markdown API docs from Django/DRF OpenAPI schema for MkDocs
|
|
5
|
-
Author-email: Hossein Shayesteh <shayestehhs1@gmail.com>
|
|
6
|
-
Maintainer-email: Hossein Shayesteh <shayestehhs1@gmail.com>
|
|
7
|
-
License: MIT
|
|
8
|
-
Project-URL: Homepage, https://github.com/shayestehhs/drf-to-mkdoc
|
|
9
|
-
Project-URL: Repository, https://github.com/shayestehhs/drf-to-mkdoc
|
|
10
|
-
Project-URL: Documentation, https://github.com/shayestehhs/drf-to-mkdoc#readme
|
|
11
|
-
Project-URL: Bug Tracker, https://github.com/shayestehhs/drf-to-mkdoc/issues
|
|
12
|
-
Keywords: django,django-rest-framework,documentation,mkdocs,api
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
-
Classifier: Operating System :: OS Independent
|
|
17
|
-
Classifier: Programming Language :: Python :: 3
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
-
Classifier: Framework :: Django
|
|
24
|
-
Classifier: Framework :: Django :: 3.2
|
|
25
|
-
Classifier: Framework :: Django :: 4.0
|
|
26
|
-
Classifier: Framework :: Django :: 4.1
|
|
27
|
-
Classifier: Framework :: Django :: 4.2
|
|
28
|
-
Classifier: Framework :: Django :: 5.0
|
|
29
|
-
Classifier: Topic :: Documentation
|
|
30
|
-
Classifier: Topic :: Software Development :: Documentation
|
|
31
|
-
Requires-Python: >=3.8
|
|
32
|
-
Description-Content-Type: text/markdown
|
|
33
|
-
License-File: LICENSE
|
|
34
|
-
Requires-Dist: Django<6.0,>=3.2
|
|
35
|
-
Requires-Dist: djangorestframework<4.0,>=3.12
|
|
36
|
-
Requires-Dist: PyYAML>=6.0
|
|
37
|
-
Requires-Dist: drf-spectacular>=0.26.0
|
|
38
|
-
Requires-Dist: mkdocs>=1.4.0
|
|
39
|
-
Requires-Dist: mkdocs-material>=9.0.0
|
|
40
|
-
Requires-Dist: coreapi>=2.3.0
|
|
41
|
-
Provides-Extra: dev
|
|
42
|
-
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
43
|
-
Requires-Dist: pytest-django>=4.5.0; extra == "dev"
|
|
44
|
-
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
45
|
-
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
46
|
-
Requires-Dist: flake8>=5.0.0; extra == "dev"
|
|
47
|
-
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
48
|
-
Dynamic: license-file
|
|
49
|
-
|
|
50
|
-
# DRF to MkDocs
|
|
51
|
-
|
|
52
|
-
Generate beautiful, interactive Markdown API documentation from Django REST Framework OpenAPI schema for MkDocs.
|
|
53
|
-
|
|
54
|
-
## Why you'll love it
|
|
55
|
-
|
|
56
|
-
- **Zero-hassle docs**: Beautiful, always-in-sync API docs straight from your codebase
|
|
57
|
-
- **Model deep dive**: Auto-generated model pages with fields, relationships, and choices
|
|
58
|
-
- **ER Diagrams**: Entity-Relationship diagrams showing model relationships
|
|
59
|
-
- **Lightning-fast discovery**: Interactive endpoint index with powerful filters and search
|
|
60
|
-
- **Try-it-out**: Interactive API testing directly in the documentation with request/response examples
|
|
61
|
-
- **AI-powered**: Optional AI-generated documentation with custom field generators(Wait for it...)
|
|
62
|
-
- **DRF-native**: Works with DRF Spectacular; no custom schema wiring needed
|
|
63
|
-
- **MkDocs Material**: Looks great out of the box with the Material theme
|
|
64
|
-
|
|
65
|
-
## Installation
|
|
66
|
-
|
|
67
|
-
See the full installation guide in `docs/installation.md`.
|
|
68
|
-
|
|
69
|
-
## Quick Start
|
|
70
|
-
|
|
71
|
-
1. **Configure your Django project**:
|
|
72
|
-
|
|
73
|
-
```python
|
|
74
|
-
# settings.py
|
|
75
|
-
INSTALLED_APPS = [
|
|
76
|
-
# ... your other apps
|
|
77
|
-
'drf_to_mkdoc',
|
|
78
|
-
]
|
|
79
|
-
|
|
80
|
-
# Required for OpenAPI schema generation
|
|
81
|
-
REST_FRAMEWORK = {
|
|
82
|
-
'DEFAULT_SCHEMA_CLASS': 'drf_to_mkdoc.utils.schema.AutoSchema',
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
SPECTACULAR_SETTINGS = {
|
|
86
|
-
'TITLE': 'Your API',
|
|
87
|
-
'DESCRIPTION': 'Your API description',
|
|
88
|
-
'VERSION': '1.0.0',
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
DRF_TO_MKDOC = {
|
|
93
|
-
'DJANGO_APPS': [
|
|
94
|
-
'users',
|
|
95
|
-
'products',
|
|
96
|
-
'orders',
|
|
97
|
-
'inventory',
|
|
98
|
-
],
|
|
99
|
-
# Optional: Override default paths
|
|
100
|
-
# 'DOCS_DIR': 'docs', # Base directory for all generated docs
|
|
101
|
-
# 'CONFIG_DIR': 'docs/configs',
|
|
102
|
-
# 'ER_DIAGRAMS_DIR': 'er_diagrams', # Directory for ER diagrams (relative to DOCS_DIR)
|
|
103
|
-
# 'MODEL_DOCS_FILE': 'docs/model-docs.json',
|
|
104
|
-
# 'DOC_CONFIG_FILE': 'docs/configs/doc_config.json',
|
|
105
|
-
# 'CUSTOM_SCHEMA_FILE': 'docs/configs/custom_schema.json',
|
|
106
|
-
# 'FIELD_GENERATORS': {
|
|
107
|
-
# 'email': 'faker.email',
|
|
108
|
-
# 'name': 'faker.name',
|
|
109
|
-
# 'created_at': 'datetime.now',
|
|
110
|
-
# },
|
|
111
|
-
# 'ENABLE_AI_DOCS': False,
|
|
112
|
-
}
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
2. **Create MkDocs configuration**:
|
|
116
|
-
Copy the [`docs/mkdocs.yml`](docs/mkdocs.yml) file to your project root and customize it as needed.
|
|
117
|
-
|
|
118
|
-
**Note**: If you change the `ER_DIAGRAMS_DIR` setting, update the navigation path in `mkdocs.yml` accordingly.
|
|
119
|
-
|
|
120
|
-
3. **Build documentation**:
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
python manage.py build_docs --settings=docs_settings
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
### Configuration Options
|
|
127
|
-
|
|
128
|
-
The `DRF_TO_MKDOC` setting supports several configuration options:
|
|
129
|
-
|
|
130
|
-
- **`DJANGO_APPS`** (required): List of Django app names to process
|
|
131
|
-
- **`DOCS_DIR`**: Base directory where docs will be generated (default: `docs`)
|
|
132
|
-
- **`CONFIG_DIR`**: Directory for configuration files (default: `docs/configs`)
|
|
133
|
-
- **`ER_DIAGRAMS_DIR`**: Directory for ER diagrams (default: `er_diagrams`, relative to `DOCS_DIR`)
|
|
134
|
-
- **`FIELD_GENERATORS`**: Custom field value generators for better examples
|
|
135
|
-
- **`ENABLE_AI_DOCS`**: Enable AI-powered documentation features (default: `False`)
|
|
136
|
-
- **`PATH_PARAM_SUBSTITUTE_FUNCTION`**: Custom function for path parameter substitution
|
|
137
|
-
- **`PATH_PARAM_SUBSTITUTE_MAPPING`**: Mapping for path parameter substitution
|
|
138
|
-
|
|
139
|
-
## Available Commands
|
|
140
|
-
|
|
141
|
-
- `build_docs`: Build the complete documentation site with MkDocs
|
|
142
|
-
- `build_endpoint_docs`: Build endpoint documentation from OpenAPI schema
|
|
143
|
-
- `build_model_docs`: Build model documentation from model JSON data
|
|
144
|
-
- `extract_model_data`: Extract model data from Django model introspection and save as JSON
|
|
145
|
-
- `generate_doc_json`: Generate JSON context for new API endpoints to be documented
|
|
146
|
-
- `update_doc_schema`: Update the final schema by copying the documented schema
|
|
147
|
-
|
|
148
|
-
## What you get
|
|
149
|
-
|
|
150
|
-
See a detailed overview of generated files in `docs/structure.md` and a feature breakdown in `docs/features.md`.
|
|
151
|
-
|
|
152
|
-
## Key Features
|
|
153
|
-
|
|
154
|
-
### 🚀 Interactive API Testing (Try-Out)
|
|
155
|
-
- **Live API testing**: Test endpoints directly from the documentation
|
|
156
|
-
- **Request builder**: Interactive forms for parameters, headers, and request body
|
|
157
|
-
- **Response viewer**: Real-time response display with syntax highlighting
|
|
158
|
-
- **Floating action button**: Easy access to testing interface
|
|
159
|
-
- **Multiple examples**: Support for both empty and populated response examples
|
|
160
|
-
|
|
161
|
-
### 📊 Entity-Relationship Diagrams
|
|
162
|
-
- **Visual model relationships**: Interactive ER diagrams showing all model connections
|
|
163
|
-
- **App-specific views**: Detailed diagrams for each Django app with field information
|
|
164
|
-
- **Mermaid-powered**: Clean, professional diagrams with zoom and navigation controls
|
|
165
|
-
- **Auto-generated**: Automatically created from your Django model relationships
|
|
166
|
-
|
|
167
|
-
### 🤖 AI-Powered Documentation
|
|
168
|
-
- **Custom field generators**: Define custom value generators for specific fields
|
|
169
|
-
- **AI documentation**: Optional AI-generated documentation with context analysis
|
|
170
|
-
- **Smart examples**: Enhanced example generation for better API understanding
|
|
171
|
-
|
|
172
|
-
### 📊 Advanced Filtering & Search
|
|
173
|
-
- **Multi-criteria filtering**: Filter by app, HTTP method, path, and search terms
|
|
174
|
-
- **Real-time search**: Instant search across all endpoints
|
|
175
|
-
- **Smart suggestions**: Auto-complete for query parameters and field names
|
|
176
|
-
|
|
177
|
-
### 🎨 Beautiful UI
|
|
178
|
-
- **Material Design**: Modern, responsive interface with dark/light themes
|
|
179
|
-
- **Interactive elements**: Hover effects, animations, and smooth transitions
|
|
180
|
-
- **Mobile-friendly**: Fully responsive design for all devices
|
|
181
|
-
|
|
182
|
-
## How it works
|
|
183
|
-
|
|
184
|
-
Under the hood, drf-to-mkdoc introspects your models and reads your DRF OpenAPI schema to generate clean, organized Markdown. Then MkDocs turns it into a polished static site. Always current, no manual updates.
|
|
185
|
-
|
|
186
|
-
## Explore more
|
|
187
|
-
|
|
188
|
-
- Customizing endpoint docs: `docs/customizing_endpoints.md`
|
|
189
|
-
- Serving docs through Django (with permissions): `docs/serving_mkdocs_with_django.md`
|
|
190
|
-
|
|
191
|
-
## Dependencies
|
|
192
|
-
|
|
193
|
-
- Django >= 3.2, < 6.0
|
|
194
|
-
- Django REST Framework >= 3.12, < 4.0
|
|
195
|
-
- drf-spectacular >= 0.26.0
|
|
196
|
-
- PyYAML >= 6.0
|
|
197
|
-
- MkDocs >= 1.4.0
|
|
198
|
-
- MkDocs Material >= 9.0.0
|
|
199
|
-
- coreapi >= 2.3.0
|
|
200
|
-
|
|
201
|
-
## Development
|
|
202
|
-
|
|
203
|
-
### Setup Development Environment
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
git clone https://github.com/Shayestehhs/drf-to-mkdoc.git
|
|
207
|
-
cd drf-to-mkdoc
|
|
208
|
-
pip install -e ".[dev]"
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Project Structure
|
|
212
|
-
|
|
213
|
-
```
|
|
214
|
-
drf-to-mkdoc/
|
|
215
|
-
├── drf_to_mkdoc/
|
|
216
|
-
│ ├── conf/
|
|
217
|
-
│ │ ├── defaults.py # Default configuration values
|
|
218
|
-
│ │ └── settings.py # Settings management
|
|
219
|
-
│ ├── management/
|
|
220
|
-
│ │ └── commands/
|
|
221
|
-
│ │ ├── build_docs.py # Build MkDocs site
|
|
222
|
-
│ │ ├── build_endpoint_docs.py # Build endpoint documentation
|
|
223
|
-
│ │ ├── build_model_docs.py # Build model documentation
|
|
224
|
-
│ │ ├── extract_model_data.py # Extract model data from Django
|
|
225
|
-
│ │ ├── generate_doc_json.py # Generate JSON context for AI docs
|
|
226
|
-
│ │ └── update_doc_schema.py # Schema updates
|
|
227
|
-
│ ├── static/
|
|
228
|
-
│ │ └── drf-to-mkdoc/
|
|
229
|
-
│ │ ├── javascripts/
|
|
230
|
-
│ │ │ ├── try-out/ # Interactive API testing
|
|
231
|
-
│ │ │ └── endpoints-filter.js # Endpoint filtering
|
|
232
|
-
│ │ └── stylesheets/ # CSS for styling
|
|
233
|
-
│ ├── templates/
|
|
234
|
-
│ │ ├── endpoints/ # Endpoint documentation templates
|
|
235
|
-
│ │ ├── model_detail/ # Model documentation templates
|
|
236
|
-
│ │ └── try-out/ # Interactive testing templates
|
|
237
|
-
│ └── utils/
|
|
238
|
-
│ ├── ai_tools/ # AI-powered documentation features
|
|
239
|
-
│ ├── commons/ # Shared utilities
|
|
240
|
-
│ ├── extractors/ # Query parameter extraction
|
|
241
|
-
│ ├── endpoint_detail_generator.py
|
|
242
|
-
│ ├── endpoint_list_generator.py
|
|
243
|
-
│ ├── model_detail_generator.py
|
|
244
|
-
│ ├── model_list_generator.py
|
|
245
|
-
│ └── schema.py
|
|
246
|
-
├── docs/ # Generated documentation
|
|
247
|
-
│ ├── endpoints/ # API endpoint documentation
|
|
248
|
-
│ ├── models/ # Model documentation
|
|
249
|
-
│ ├── er_diagrams/ # Entity-Relationship diagrams
|
|
250
|
-
│ └── configs/ # Configuration files
|
|
251
|
-
├── pyproject.toml # Project configuration
|
|
252
|
-
└── README.md
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## License
|
|
256
|
-
|
|
257
|
-
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
258
|
-
|
|
259
|
-
## Recommendations
|
|
260
|
-
|
|
261
|
-
### .gitignore Configuration
|
|
262
|
-
|
|
263
|
-
To avoid committing generated files to your repository, add the following to your `.gitignore` file:
|
|
264
|
-
|
|
265
|
-
```gitignore
|
|
266
|
-
# Documentation
|
|
267
|
-
/docs/endpoints/
|
|
268
|
-
/docs/models/
|
|
269
|
-
/docs/er_diagrams/
|
|
270
|
-
/docs/configs/doc-schema.yaml
|
|
271
|
-
|
|
272
|
-
# Build artifacts
|
|
273
|
-
/site/
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
This will ensure that only the source configuration and scripts are versioned, while the generated documentation is excluded.
|
|
277
|
-
|
|
278
|
-
### docs_settings.py Best Practices
|
|
279
|
-
|
|
280
|
-
Create a separate `docs_settings.py` file that inherits from your main settings:
|
|
281
|
-
|
|
282
|
-
```python
|
|
283
|
-
# docs_settings.py
|
|
284
|
-
from .settings import *
|
|
285
|
-
|
|
286
|
-
DRF_TO_MKDOC = {
|
|
287
|
-
'DJANGO_APPS': ['your_app1', 'your_app2'],
|
|
288
|
-
}
|
|
289
|
-
# Other doc settings...
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
Then use the `--settings` argument when running the build command:
|
|
293
|
-
|
|
294
|
-
```bash
|
|
295
|
-
python manage.py build_docs --settings=docs_settings
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
### Project Organization
|
|
299
|
-
|
|
300
|
-
```
|
|
301
|
-
your-project/
|
|
302
|
-
├── settings.py # Main Django settings
|
|
303
|
-
├── docs_settings.py # Documentation-specific settings
|
|
304
|
-
├── mkdocs.yml # MkDocs configuration
|
|
305
|
-
├── docs/ # Generated documentation (gitignored)
|
|
306
|
-
│ ├── endpoints/ # API endpoint docs
|
|
307
|
-
│ ├── models/ # Model documentation
|
|
308
|
-
│ ├── er_diagrams/ # ER diagrams
|
|
309
|
-
│ └── configs/ # Configuration files
|
|
310
|
-
└── site/ # Built site (gitignored)
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
## Contributing
|
|
314
|
-
|
|
315
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for detailed contribution guidelines.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|