drf-to-mkdoc 0.3.0__py3-none-any.whl → 0.3.1__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.

@@ -14,6 +14,5 @@ DEFAULTS = {
14
14
  "AI_CONFIG_DIR_NAME": "ai_code", # Directory name for AI-generated code files
15
15
  "AI_OPERATION_MAP_FILE": "docs/configs/operation_map.json", # Path to operation map file
16
16
  "SERIALIZERS_INHERITANCE_DEPTH": 1, # Maximum depth for class inheritance analysis
17
- # Django apps - required, no default
18
- "DJANGO_APPS": None, # List of Django app names to process
17
+ "DJANGO_APPS": [], # If it is empty list, there is no any exclusion
19
18
  }
@@ -7,13 +7,14 @@ from drf_to_mkdoc.conf.defaults import DEFAULTS
7
7
 
8
8
 
9
9
  class DRFToMkDocSettings:
10
- required_settings: ClassVar[list[str]] = ["DJANGO_APPS"]
10
+ required_settings: ClassVar[list[str]] = []
11
11
  project_settings: ClassVar[dict[str, Any]] = {"PROJECT_NAME": "drf-to-mkdoc"}
12
12
 
13
13
  settings_types: ClassVar[dict[str, type]] = {
14
14
  "ENABLE_AI_DOCS": bool,
15
15
  "AI_CONFIG_DIR_NAME": str,
16
16
  "SERIALIZERS_INHERITANCE_DEPTH": int,
17
+ "DJANGO_APPS": list,
17
18
  }
18
19
 
19
20
  settings_ranges: ClassVar[dict[str, tuple[int, int]]] = {
@@ -160,9 +160,25 @@ const RequestExecutor = {
160
160
  }
161
161
  }
162
162
 
163
- // Get method
163
+ // Get method - try multiple sources for reliability
164
+ let method = 'GET'; // Default fallback
165
+
166
+ // First try: method badge data attribute
164
167
  const methodBadge = document.querySelector('.method-badge');
165
- const method = methodBadge?.dataset.method || 'GET';
168
+ if (methodBadge?.dataset.method) {
169
+ method = methodBadge.dataset.method;
170
+ } else {
171
+ // Second try: try-out form data attribute
172
+ const tryOutForm = document.querySelector('.try-out-form');
173
+ if (tryOutForm?.dataset.method) {
174
+ method = tryOutForm.dataset.method.toUpperCase();
175
+ } else {
176
+ // Third try: method badge text content
177
+ if (methodBadge?.textContent) {
178
+ method = methodBadge.textContent.trim();
179
+ }
180
+ }
181
+ }
166
182
 
167
183
  return {
168
184
  url: fullUrl,
@@ -742,7 +742,7 @@ def parse_endpoints_from_schema(paths: dict[str, Any]) -> dict[str, list[dict[st
742
742
 
743
743
  for path, methods in paths.items():
744
744
  app_name = extract_app_from_operation_id(next(iter(methods.values()))["operationId"])
745
- if app_name not in django_apps:
745
+ if django_apps and app_name not in django_apps:
746
746
  continue
747
747
 
748
748
  for method, endpoint_data in methods.items():
@@ -2,7 +2,7 @@ import inspect
2
2
  import logging
3
3
  from importlib import import_module
4
4
  from types import SimpleNamespace
5
- from typing import Any
5
+ from typing import Any, List
6
6
 
7
7
  from drf_spectacular.openapi import AutoSchema as SpectacularAutoSchema
8
8
  from drf_spectacular.plumbing import ComponentRegistry
@@ -208,6 +208,15 @@ class AutoSchema(SpectacularAutoSchema):
208
208
  directly to the operation during schema generation instead of using a postprocessing hook.
209
209
  """
210
210
 
211
+ def __init__(self, *args, **kwargs):
212
+ self.tags = kwargs.pop("tags", [])
213
+ super().__init__()
214
+
215
+ def get_tags(self) -> List[str]:
216
+ if self.tags:
217
+ return self.tags
218
+ return super().get_tags()
219
+
211
220
  def get_operation(
212
221
  self,
213
222
  path: str,
@@ -0,0 +1,232 @@
1
+ Metadata-Version: 2.4
2
+ Name: drf-to-mkdoc
3
+ Version: 0.3.1
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
+ Unlock effortless API documentation for your Django REST Framework project. Automatically generate beautiful, interactive, and maintainable docs that accelerate developer onboarding and streamline your team's workflow.
53
+
54
+ ---
55
+
56
+ ## Why DRF to MkDocs?
57
+
58
+ `DRF to MkDocs` bridges the gap between your API's OpenAPI schema and user-friendly, maintainable documentation. It introspects your Django models and DRF views to automatically generate a polished, feature-rich documentation site that stays in sync with your codebase, empowering your team to build better APIs, faster.
59
+
60
+ - **Effortless Documentation**: Automate the entire process of generating and updating your API docs. Say goodbye to manual work and outdated information.
61
+ - **Accelerate Onboarding**: Provide new joiners with interactive, easy-to-navigate documentation. The "Try-it-out" feature and clear model relationships help them become productive from day one.
62
+ - **Deeply Integrated with DRF**: Leverages `drf-spectacular` for accurate schema generation, ensuring your documentation is a true reflection of your API.
63
+ - **Enhance Developer Experience**: Features like the interactive API console and in-depth model pages streamline development, testing, and debugging for the entire team.
64
+ - **Beautiful & Professional**: Built on MkDocs with the Material theme for a clean, modern, and responsive UI that you'll be proud to share.
65
+
66
+ ## Gallery
67
+
68
+ <details>
69
+ <summary>🚀 Interactive Endpoint List & Filtering</summary>
70
+ <img width="1434" height="943" alt="List-EndPoint" src="https://github.com/user-attachments/assets/f886fc7f-afa0-4faa-b9c2-d6f754ca3597" />
71
+ </details>
72
+
73
+ <details>
74
+ <summary>🔬 Detailed Endpoint View with "Try-it-out"</summary>
75
+ <img width="958" height="887" alt="Detail-EndPoint" src="https://github.com/user-attachments/assets/9d9e3d4b-cb92-4ece-831e-aef45ceec768" />
76
+ <img width="532" height="804" alt="Try-it-out" src="https://github.com/user-attachments/assets/0f483922-60c4-4f62-8fb4-bc7372e82a03" />
77
+ </details>
78
+
79
+ <details>
80
+ <summary>📚 Rich Model Documentation</summary>
81
+ <img width="906" height="885" alt="Model-fields" src="https://github.com/user-attachments/assets/a1ca369c-ad40-4b05-83ec-ceb1f80aab23" />
82
+ <img width="848" height="886" alt="Model" src="https://github.com/user-attachments/assets/683d6d26-a8e4-4c05-8b5f-11a61a62cb0c" />
83
+ </details>
84
+
85
+ <details>
86
+ <summary>📈 Entity-Relationship Diagrams</summary>
87
+ <img width="953" height="606" alt="ER-Diagram" src="https://github.com/user-attachments/assets/3d0b1cb0-7ebf-4d4a-a181-1b7dbc9c6a01" />
88
+ </details>
89
+
90
+ ## Key Features
91
+
92
+ | Feature | Description |
93
+ | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
94
+ | 🚀 **Interactive API Console** | Test endpoints directly from the documentation with a "Try-it-out" feature, complete with a request builder and response viewer. |
95
+ | 🔍 **Advanced Filtering & Search** | Instantly find endpoints with multi-criteria filtering by app, method, path, and a real-time search. |
96
+ | 📚 **In-Depth Model Pages** | Automatically generate detailed pages for each model, including fields, relationships, choices, and methods. |
97
+ | 📊 **Entity-Relationship Diagrams** | Visualize model relationships with auto-generated, interactive ER diagrams for each app and for the entire project. |
98
+ | 🎨 **Modern & Responsive UI** | A beautiful and intuitive interface powered by MkDocs Material, featuring light/dark themes and full mobile support. |
99
+ | 🔧 **Highly Customizable** | Override templates, configure settings, and use custom functions to tailor the documentation to your project's specific needs. |
100
+ | ⚙️ **Simple Integration** | Works seamlessly with existing DRF projects and `drf-spectacular` without requiring complex setup. |
101
+ | 🤖 **AI-Powered Enhancements** | (Working on it...) Leverage AI to generate smarter examples and more descriptive documentation for your API. |
102
+
103
+ ## Getting Started
104
+
105
+ ### 1. Installation
106
+
107
+ ```bash
108
+ pip install drf-to-mkdoc
109
+ ```
110
+
111
+ ### 2. Configure Your Django Project
112
+
113
+ In your `settings.py`:
114
+
115
+ ```python
116
+ # settings.py
117
+
118
+ INSTALLED_APPS = [
119
+ # ... your other apps
120
+ 'drf_to_mkdoc',
121
+ 'drf_spectacular', # Required for schema generation
122
+ ]
123
+
124
+ # Required for OpenAPI schema generation
125
+ REST_FRAMEWORK = {
126
+ 'DEFAULT_SCHEMA_CLASS': 'drf_to_mkdoc.utils.schema.AutoSchema',
127
+ }
128
+
129
+ SPECTACULAR_SETTINGS = {
130
+ 'TITLE': 'Your API',
131
+ 'DESCRIPTION': 'Your API description',
132
+ 'VERSION': '1.0.0',
133
+ }
134
+
135
+ # DRF to MkDocs specific settings
136
+ DRF_TO_MKDOC = {
137
+ 'DJANGO_APPS': [
138
+ 'users',
139
+ 'products',
140
+ # ... list all apps you want to document
141
+ ],
142
+ }
143
+ ```
144
+
145
+ ### 3. Create MkDocs Configuration
146
+
147
+ Create an `mkdocs.yml` file in your project root. You can start with the [default configuration](docs/mkdocs.yml) and customize it.
148
+
149
+ ### 4. Build Your Documentation
150
+
151
+ ```bash
152
+ python manage.py build_docs
153
+ ```
154
+
155
+ For more detailed instructions, see the full [Installation and Setup Guide](docs/installation.md).
156
+
157
+ ## Usage and Customization
158
+
159
+ ### Building Your Documentation
160
+
161
+ To build the entire documentation site, run the following command. This will generate a static site in your `site/` directory.
162
+
163
+ ```bash
164
+ python manage.py build_docs
165
+ ```
166
+
167
+ For more granular control, `DRF to MkDocs` provides several commands, such as `build_endpoint_docs` and `build_model_docs`.
168
+
169
+ ### Serving Docs with Django
170
+
171
+ You can serve your documentation directly from your Django application, protecting it with Django's authentication system. This is ideal for private or internal APIs.
172
+
173
+ For a complete guide, see [Serving Docs with Django](docs/serving_docs_with_django.md).
174
+
175
+ ### Customizing the OpenAPI Schema
176
+
177
+ `DRF to MkDocs` allows you to override and extend the auto-generated OpenAPI schema by providing a custom JSON file. This gives you fine-grained control over the final documentation, enabling you to add examples, descriptions, or even custom endpoints.
178
+
179
+ For more details, refer to the [Customizing Endpoints](docs/customizing_endpoints.md) guide.
180
+
181
+ ### Best Practices
182
+
183
+ For better project organization, we recommend creating a separate `docs_settings.py` for documentation-specific configurations and using the `--settings` flag:
184
+
185
+ ```bash
186
+ python manage.py build_docs --settings=my_project.docs_settings
187
+ ```
188
+
189
+ This keeps your production settings clean and your documentation configuration isolated.
190
+
191
+ ## Configuration
192
+
193
+ You can customize the behavior of `DRF to MkDocs` by configuring the `DRF_TO_MKDOC` dictionary in your settings file.
194
+
195
+ | Key | Description | Default |
196
+ | -------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------- |
197
+ | `DJANGO_APPS` (required) | A list of Django app names to process. | `[]` |
198
+ | `DOCS_DIR` | The base directory where documentation will be generated. | `'docs'` |
199
+ | `ER_DIAGRAMS_DIR` | The directory for ER diagrams, relative to `DOCS_DIR`. | `'er_diagrams'` |
200
+ | `FIELD_GENERATORS` | Custom field value generators for creating better examples. | `{}` |
201
+ | `ENABLE_AI_DOCS` | A flag to enable AI-powered documentation features. | `False` |
202
+ | `PATH_PARAM_SUBSTITUTE_FUNCTION` | A custom function for substituting path parameters in URLs. | `None` |
203
+ | `PATH_PARAM_SUBSTITUTE_MAPPING` | A mapping for substituting common path parameters (e.g., `{'pk': 1}`). | `{}` |
204
+
205
+ ## How It Works
206
+
207
+ `DRF to MkDocs` operates in a few stages:
208
+
209
+ 1. **Model Introspection**: It deeply analyzes your Django models, mapping out their fields, relationships (like ForeignKeys and ManyToManyFields), and metadata.
210
+ 2. **Schema Generation**: It uses `drf-spectacular` to generate a detailed OpenAPI schema for your API endpoints.
211
+ 3. **Template Rendering**: It renders Jinja2 templates for each endpoint, model, and ER diagram, creating Markdown files.
212
+ 4. **MkDocs Build**: Finally, it invokes MkDocs to build a static HTML site from the generated Markdown files.
213
+
214
+ This process ensures that your documentation is always an accurate and comprehensive reflection of your codebase.
215
+
216
+ ## Contributing
217
+
218
+ Contributions are welcome! Whether it's a bug report, a new feature, or an improvement to the documentation, we appreciate your help. To ensure code quality, we use **CoderabbitAI** for automated code reviews on all pull requests.
219
+
220
+ Please see our [Contributing Guidelines](CONTRIBUTING.md) to get started.
221
+
222
+ ### Development Setup
223
+
224
+ ```bash
225
+ git clone https://github.com/Shayestehhs/drf-to-mkdoc.git
226
+ cd drf-to-mkdoc
227
+ pip install -e ".[dev]"
228
+ ```
229
+
230
+ ## License
231
+
232
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1,8 +1,8 @@
1
1
  drf_to_mkdoc/__init__.py,sha256=IbTW5uKQvJRG9ncHRuk_AGKHPn4ruxs5LqDpUFgUhws,180
2
2
  drf_to_mkdoc/apps.py,sha256=-NrC_dRr6GmLmNQhkNh819B7V1SS4DYDv5JOR0TtuJM,560
3
3
  drf_to_mkdoc/conf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- drf_to_mkdoc/conf/defaults.py,sha256=69z61GT02PqaBvo4W-wuyI9Xrdgph_qIbGrzx0EG5gg,1104
5
- drf_to_mkdoc/conf/settings.py,sha256=5oGHe3du6W4zQtfO3D2RWopLm7OqZQ11ftRUqiJcaS4,5483
4
+ drf_to_mkdoc/conf/defaults.py,sha256=5qbjvHvhhkQChRdy3tJvGRoJ1uXzBfoiHf71kt3a3XI,1072
5
+ drf_to_mkdoc/conf/settings.py,sha256=sxg3VIlhUkcxL1g-21E3FSuwqH4MfL9C3m2QwGw5rqA,5499
6
6
  drf_to_mkdoc/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
7
  drf_to_mkdoc/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  drf_to_mkdoc/management/commands/build_docs.py,sha256=k2N8i7sNWPJGVzUSdkDu47FleCSjIxClRq1dWBHwhjQ,4057
@@ -19,7 +19,7 @@ drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/form-manager.js,sha256=6KIe
19
19
  drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/main.js,sha256=W0Vv9jdCturToACs_wapZ37ux0nRXy1d3GqfXq-0NuI,1821
20
20
  drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/modal.js,sha256=IUg33Er2cF6qzIbxgnvlj8C_fSjNariyfFd3zswu3wU,14238
21
21
  drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/query-parameters-extractor.js,sha256=3b6XshRFdf5TeZNktgxEBenEFWTTEsKjYZll0xMUv3Q,3542
22
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/request-executor.js,sha256=CsIusYZ5RIJXQFN3eh3ZcTLgf6hoZJ7E9BP1_EGsSiA,11904
22
+ drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/request-executor.js,sha256=lBKP-GbUyXKhIGS1q0V0GxeJueRHTjfaDorIgB-LClg,12565
23
23
  drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/response-modal.js,sha256=D8Xd9rEAJpMPExVxSmJ7PaQXCmIfRPhyv6t93A0AP0w,5671
24
24
  drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/suggestions.js,sha256=WOXppK1HgYFDbVkCvchBKxL8rc_974roJAxZE2EBdDo,4396
25
25
  drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/tabs.js,sha256=WwAjbisNap0lOQ3pZyWkW0G7hXvy_gFjHMCCPUu50a8,2791
@@ -87,12 +87,12 @@ drf_to_mkdoc/templates/try-out/modal.html,sha256=G3Ye6DntMVVYUnmbwkrf-YcYmw7AxtC
87
87
  drf_to_mkdoc/templates/try-out/response-modal.html,sha256=mjt1bud07Y3BXp7716mQMlrv8xGRaQr4W2XRNKJWwGA,5980
88
88
  drf_to_mkdoc/templatetags/custom_filters.py,sha256=b_0ExGgBKUIlNkJ8nXlc6mrhhiUUxtdq9thXH-yzEq4,3761
89
89
  drf_to_mkdoc/utils/__init__.py,sha256=6dFTb07S6yIf-INMy0Mlgf5purNir687ZU9WZtITh4k,68
90
- drf_to_mkdoc/utils/endpoint_detail_generator.py,sha256=qYFM84KuiygNMNGQ_aiT6nxVexWtM8mZb3WfFrV8zVU,28375
90
+ drf_to_mkdoc/utils/endpoint_detail_generator.py,sha256=toZ3JWlVHtsYPJLG8ZDvLYtfsbNr3P-YEINKpOElwQ4,28391
91
91
  drf_to_mkdoc/utils/endpoint_list_generator.py,sha256=yVX7qVUTuKF3TPFgm6FI-vVsVZQ7XHMXmZZalgSN8pk,3579
92
92
  drf_to_mkdoc/utils/er_diagram_generator.py,sha256=9X4L2XPVSKwxHZQspOSMg7TacAzImeXGgYPzhlsL-U8,7962
93
93
  drf_to_mkdoc/utils/model_detail_generator.py,sha256=_ac2PYSzSwRUgUn-J-nmg7mfQGn8SU_4vkMpMRIxgEU,2619
94
94
  drf_to_mkdoc/utils/model_list_generator.py,sha256=Ki-CwIYKmUbPm3_jUPLPosPfppyVLrZMkqbuPPO3Ycw,1988
95
- drf_to_mkdoc/utils/schema.py,sha256=sDhVITdIFp1TJYnqCd4wF69i-lwXGlTsNJ2-ngXkccc,10070
95
+ drf_to_mkdoc/utils/schema.py,sha256=vVLnnVt3ANaHSAdrsjOEfkakZZufeR5PUSuo2dyR4vU,10311
96
96
  drf_to_mkdoc/utils/ai_tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
97
  drf_to_mkdoc/utils/ai_tools/enums.py,sha256=K39bJjHgXwNst2NL6z-5bztW3ZU5iCxg2b0KEodD6eM,238
98
98
  drf_to_mkdoc/utils/ai_tools/exceptions.py,sha256=yFauOtuSRGRnQt41u2qCMvWEbN0eblgKwXuH-GX3Wbk,634
@@ -109,8 +109,8 @@ drf_to_mkdoc/utils/commons/path_utils.py,sha256=Pi9g1xXDPsRzmn4kTeNSVtXG9v6n1h2Z
109
109
  drf_to_mkdoc/utils/commons/schema_utils.py,sha256=1mQxzo08J6tlVmTIJ0hCQ6wCZUWMuV82POhLWUfOYtI,7567
110
110
  drf_to_mkdoc/utils/extractors/__init__.py,sha256=BvC8gKOPVI9gU1Piw0jRhKQ2ER5s1moAxgq7ZYkJWNI,86
111
111
  drf_to_mkdoc/utils/extractors/query_parameter_extractors.py,sha256=xELPYI6tcqfkxOa475JPMaxRzRGUX--Z9oYRlKgXb7w,7964
112
- drf_to_mkdoc-0.3.0.dist-info/licenses/LICENSE,sha256=3n9_ckIREsH8ogCxWW6dFsw_WfGcluG2mHcgl9i_UU0,1068
113
- drf_to_mkdoc-0.3.0.dist-info/METADATA,sha256=Qdnb11wv-MfHGoC0oGA160pjaNXUzcwL6J_noRbi-8c,11950
114
- drf_to_mkdoc-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
- drf_to_mkdoc-0.3.0.dist-info/top_level.txt,sha256=ZzJecR6j_tvLZiubUBEgawHflozC4DQy9ooNf1yDJ3Q,13
116
- drf_to_mkdoc-0.3.0.dist-info/RECORD,,
112
+ drf_to_mkdoc-0.3.1.dist-info/licenses/LICENSE,sha256=3n9_ckIREsH8ogCxWW6dFsw_WfGcluG2mHcgl9i_UU0,1068
113
+ drf_to_mkdoc-0.3.1.dist-info/METADATA,sha256=vsGgQCWq3UUXiVIPrNo8DvyKkkFxXiolEVmtZNu2iwI,11692
114
+ drf_to_mkdoc-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
115
+ drf_to_mkdoc-0.3.1.dist-info/top_level.txt,sha256=ZzJecR6j_tvLZiubUBEgawHflozC4DQy9ooNf1yDJ3Q,13
116
+ drf_to_mkdoc-0.3.1.dist-info/RECORD,,
@@ -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.