drf-to-mkdoc 0.1.0__py3-none-any.whl → 0.1.3__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/__init__.py +6 -6
- drf_to_mkdoc/apps.py +14 -14
- drf_to_mkdoc/conf/settings.py +44 -44
- drf_to_mkdoc/management/commands/build_docs.py +76 -76
- drf_to_mkdoc/management/commands/generate_doc_json.py +512 -512
- drf_to_mkdoc/management/commands/generate_docs.py +138 -138
- drf_to_mkdoc/management/commands/generate_model_docs.py +327 -327
- drf_to_mkdoc/management/commands/update_doc_schema.py +53 -53
- drf_to_mkdoc/utils/__init__.py +3 -3
- drf_to_mkdoc/utils/endpoint_generator.py +945 -945
- drf_to_mkdoc/utils/extractors/__init__.py +3 -3
- drf_to_mkdoc/utils/extractors/query_parameter_extractors.py +229 -229
- drf_to_mkdoc/utils/md_generators/query_parameters_generators.py +72 -72
- drf_to_mkdoc/utils/model_generator.py +269 -269
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/METADATA +247 -247
- drf_to_mkdoc-0.1.3.dist-info/RECORD +25 -0
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/licenses/LICENSE +21 -21
- drf_to_mkdoc-0.1.0.dist-info/RECORD +0 -25
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/WHEEL +0 -0
- {drf_to_mkdoc-0.1.0.dist-info → drf_to_mkdoc-0.1.3.dist-info}/top_level.txt +0 -0
|
@@ -1,138 +1,138 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
|
|
3
|
-
from pathlib import Path
|
|
4
|
-
|
|
5
|
-
from django.core.management.base import BaseCommand
|
|
6
|
-
|
|
7
|
-
from drf_to_mkdoc.utils.common import get_schema, load_model_json_data
|
|
8
|
-
from drf_to_mkdoc.utils.endpoint_generator import (
|
|
9
|
-
create_endpoints_index,
|
|
10
|
-
generate_endpoint_files,
|
|
11
|
-
parse_endpoints_from_schema,
|
|
12
|
-
)
|
|
13
|
-
from drf_to_mkdoc.utils.model_generator import create_models_index, generate_model_docs
|
|
14
|
-
from drf_to_mkdoc.conf.settings import drf_to_mkdoc_settings
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class Command(BaseCommand):
|
|
19
|
-
help = "Generate complete API documentation (models + endpoints + navigation)"
|
|
20
|
-
|
|
21
|
-
def add_arguments(self, parser):
|
|
22
|
-
parser.add_argument(
|
|
23
|
-
"--endpoints-only",
|
|
24
|
-
action="store_true",
|
|
25
|
-
help="Generate only endpoint documentation",
|
|
26
|
-
)
|
|
27
|
-
parser.add_argument(
|
|
28
|
-
"--models-only",
|
|
29
|
-
action="store_true",
|
|
30
|
-
help="Generate only model documentation",
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
def handle(self, *args, **options):
|
|
34
|
-
self.stdout.write(self.style.SUCCESS("🚀 Starting documentation generation..."))
|
|
35
|
-
|
|
36
|
-
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
37
|
-
docs_dir.mkdir(parents=True, exist_ok=True)
|
|
38
|
-
|
|
39
|
-
if options["models_only"]:
|
|
40
|
-
self._generate_models_only()
|
|
41
|
-
elif options["endpoints_only"]:
|
|
42
|
-
self._generate_endpoints_only()
|
|
43
|
-
else:
|
|
44
|
-
self._generate_all()
|
|
45
|
-
|
|
46
|
-
self.stdout.write(self.style.SUCCESS("✅ Documentation generation complete!"))
|
|
47
|
-
|
|
48
|
-
def _generate_models_only(self):
|
|
49
|
-
"""Generate only model documentation"""
|
|
50
|
-
self.stdout.write("📋 Generating model documentation...")
|
|
51
|
-
|
|
52
|
-
# Load model data
|
|
53
|
-
json_data = load_model_json_data()
|
|
54
|
-
models_data = json_data.get("models", {}) if json_data else {}
|
|
55
|
-
|
|
56
|
-
if not models_data:
|
|
57
|
-
self.stdout.write(self.style.WARNING("⚠️ No model data found"))
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
61
|
-
|
|
62
|
-
# Generate model documentation
|
|
63
|
-
generate_model_docs(models_data, docs_dir)
|
|
64
|
-
create_models_index(models_data, docs_dir)
|
|
65
|
-
|
|
66
|
-
self.stdout.write(self.style.SUCCESS("✅ Model documentation generated"))
|
|
67
|
-
|
|
68
|
-
def _generate_endpoints_only(self):
|
|
69
|
-
"""Generate only endpoint documentation"""
|
|
70
|
-
self.stdout.write("🔗 Generating endpoint documentation...")
|
|
71
|
-
|
|
72
|
-
# Load schema
|
|
73
|
-
schema = get_schema()
|
|
74
|
-
if not schema:
|
|
75
|
-
self.stdout.write(self.style.ERROR("❌ Failed to load OpenAPI schema"))
|
|
76
|
-
return
|
|
77
|
-
|
|
78
|
-
paths = schema.get("paths", {})
|
|
79
|
-
components = schema.get("components", {})
|
|
80
|
-
|
|
81
|
-
self.stdout.write(f"📊 Loaded {len(paths)} API paths")
|
|
82
|
-
|
|
83
|
-
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
84
|
-
|
|
85
|
-
# Parse and generate endpoints
|
|
86
|
-
endpoints_by_app = parse_endpoints_from_schema(paths)
|
|
87
|
-
total_endpoints = generate_endpoint_files(endpoints_by_app, components)
|
|
88
|
-
create_endpoints_index(endpoints_by_app, docs_dir)
|
|
89
|
-
|
|
90
|
-
self.stdout.write(
|
|
91
|
-
self.style.SUCCESS(
|
|
92
|
-
f"✅ Generated {total_endpoints} endpoint files with Django view introspection"
|
|
93
|
-
)
|
|
94
|
-
)
|
|
95
|
-
|
|
96
|
-
def _generate_all(self):
|
|
97
|
-
"""Generate complete documentation"""
|
|
98
|
-
self.stdout.write("📚 Generating complete documentation...")
|
|
99
|
-
|
|
100
|
-
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
101
|
-
|
|
102
|
-
# Load data
|
|
103
|
-
json_data = load_model_json_data()
|
|
104
|
-
models_data = json_data.get("models", {}) if json_data else {}
|
|
105
|
-
schema = get_schema()
|
|
106
|
-
|
|
107
|
-
if not schema:
|
|
108
|
-
self.stdout.write(self.style.ERROR("❌ Failed to load OpenAPI schema"))
|
|
109
|
-
return
|
|
110
|
-
|
|
111
|
-
paths = schema.get("paths", {})
|
|
112
|
-
components = schema.get("components", {})
|
|
113
|
-
|
|
114
|
-
self.stdout.write(f"📊 Loaded {len(paths)} API paths")
|
|
115
|
-
|
|
116
|
-
# Generate model documentation
|
|
117
|
-
if models_data:
|
|
118
|
-
self.stdout.write("📋 Generating model documentation...")
|
|
119
|
-
try:
|
|
120
|
-
generate_model_docs(models_data)
|
|
121
|
-
create_models_index(models_data, docs_dir)
|
|
122
|
-
except Exception as e:
|
|
123
|
-
self.stdout.write(self.style.WARNING(f"⚠️ Failed to generate model docs: {e}"))
|
|
124
|
-
self.stdout.write(self.style.WARNING("Continuing with endpoint generation..."))
|
|
125
|
-
else:
|
|
126
|
-
self.stdout.write(self.style.WARNING("⚠️ No model data found"))
|
|
127
|
-
|
|
128
|
-
# Generate endpoint documentation
|
|
129
|
-
self.stdout.write("🔗 Generating endpoint documentation...")
|
|
130
|
-
endpoints_by_app = parse_endpoints_from_schema(paths)
|
|
131
|
-
total_endpoints = generate_endpoint_files(endpoints_by_app, components)
|
|
132
|
-
create_endpoints_index(endpoints_by_app, docs_dir)
|
|
133
|
-
|
|
134
|
-
self.stdout.write(
|
|
135
|
-
self.style.SUCCESS(
|
|
136
|
-
f"✅ Generated {total_endpoints} endpoint files with Django view introspection"
|
|
137
|
-
)
|
|
138
|
-
)
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
from django.core.management.base import BaseCommand
|
|
6
|
+
|
|
7
|
+
from drf_to_mkdoc.utils.common import get_schema, load_model_json_data
|
|
8
|
+
from drf_to_mkdoc.utils.endpoint_generator import (
|
|
9
|
+
create_endpoints_index,
|
|
10
|
+
generate_endpoint_files,
|
|
11
|
+
parse_endpoints_from_schema,
|
|
12
|
+
)
|
|
13
|
+
from drf_to_mkdoc.utils.model_generator import create_models_index, generate_model_docs
|
|
14
|
+
from drf_to_mkdoc.conf.settings import drf_to_mkdoc_settings
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class Command(BaseCommand):
|
|
19
|
+
help = "Generate complete API documentation (models + endpoints + navigation)"
|
|
20
|
+
|
|
21
|
+
def add_arguments(self, parser):
|
|
22
|
+
parser.add_argument(
|
|
23
|
+
"--endpoints-only",
|
|
24
|
+
action="store_true",
|
|
25
|
+
help="Generate only endpoint documentation",
|
|
26
|
+
)
|
|
27
|
+
parser.add_argument(
|
|
28
|
+
"--models-only",
|
|
29
|
+
action="store_true",
|
|
30
|
+
help="Generate only model documentation",
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
def handle(self, *args, **options):
|
|
34
|
+
self.stdout.write(self.style.SUCCESS("🚀 Starting documentation generation..."))
|
|
35
|
+
|
|
36
|
+
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
37
|
+
docs_dir.mkdir(parents=True, exist_ok=True)
|
|
38
|
+
|
|
39
|
+
if options["models_only"]:
|
|
40
|
+
self._generate_models_only()
|
|
41
|
+
elif options["endpoints_only"]:
|
|
42
|
+
self._generate_endpoints_only()
|
|
43
|
+
else:
|
|
44
|
+
self._generate_all()
|
|
45
|
+
|
|
46
|
+
self.stdout.write(self.style.SUCCESS("✅ Documentation generation complete!"))
|
|
47
|
+
|
|
48
|
+
def _generate_models_only(self):
|
|
49
|
+
"""Generate only model documentation"""
|
|
50
|
+
self.stdout.write("📋 Generating model documentation...")
|
|
51
|
+
|
|
52
|
+
# Load model data
|
|
53
|
+
json_data = load_model_json_data()
|
|
54
|
+
models_data = json_data.get("models", {}) if json_data else {}
|
|
55
|
+
|
|
56
|
+
if not models_data:
|
|
57
|
+
self.stdout.write(self.style.WARNING("⚠️ No model data found"))
|
|
58
|
+
return
|
|
59
|
+
|
|
60
|
+
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
61
|
+
|
|
62
|
+
# Generate model documentation
|
|
63
|
+
generate_model_docs(models_data, docs_dir)
|
|
64
|
+
create_models_index(models_data, docs_dir)
|
|
65
|
+
|
|
66
|
+
self.stdout.write(self.style.SUCCESS("✅ Model documentation generated"))
|
|
67
|
+
|
|
68
|
+
def _generate_endpoints_only(self):
|
|
69
|
+
"""Generate only endpoint documentation"""
|
|
70
|
+
self.stdout.write("🔗 Generating endpoint documentation...")
|
|
71
|
+
|
|
72
|
+
# Load schema
|
|
73
|
+
schema = get_schema()
|
|
74
|
+
if not schema:
|
|
75
|
+
self.stdout.write(self.style.ERROR("❌ Failed to load OpenAPI schema"))
|
|
76
|
+
return
|
|
77
|
+
|
|
78
|
+
paths = schema.get("paths", {})
|
|
79
|
+
components = schema.get("components", {})
|
|
80
|
+
|
|
81
|
+
self.stdout.write(f"📊 Loaded {len(paths)} API paths")
|
|
82
|
+
|
|
83
|
+
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
84
|
+
|
|
85
|
+
# Parse and generate endpoints
|
|
86
|
+
endpoints_by_app = parse_endpoints_from_schema(paths)
|
|
87
|
+
total_endpoints = generate_endpoint_files(endpoints_by_app, components)
|
|
88
|
+
create_endpoints_index(endpoints_by_app, docs_dir)
|
|
89
|
+
|
|
90
|
+
self.stdout.write(
|
|
91
|
+
self.style.SUCCESS(
|
|
92
|
+
f"✅ Generated {total_endpoints} endpoint files with Django view introspection"
|
|
93
|
+
)
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
def _generate_all(self):
|
|
97
|
+
"""Generate complete documentation"""
|
|
98
|
+
self.stdout.write("📚 Generating complete documentation...")
|
|
99
|
+
|
|
100
|
+
docs_dir = Path(drf_to_mkdoc_settings.DOCS_DIR)
|
|
101
|
+
|
|
102
|
+
# Load data
|
|
103
|
+
json_data = load_model_json_data()
|
|
104
|
+
models_data = json_data.get("models", {}) if json_data else {}
|
|
105
|
+
schema = get_schema()
|
|
106
|
+
|
|
107
|
+
if not schema:
|
|
108
|
+
self.stdout.write(self.style.ERROR("❌ Failed to load OpenAPI schema"))
|
|
109
|
+
return
|
|
110
|
+
|
|
111
|
+
paths = schema.get("paths", {})
|
|
112
|
+
components = schema.get("components", {})
|
|
113
|
+
|
|
114
|
+
self.stdout.write(f"📊 Loaded {len(paths)} API paths")
|
|
115
|
+
|
|
116
|
+
# Generate model documentation
|
|
117
|
+
if models_data:
|
|
118
|
+
self.stdout.write("📋 Generating model documentation...")
|
|
119
|
+
try:
|
|
120
|
+
generate_model_docs(models_data)
|
|
121
|
+
create_models_index(models_data, docs_dir)
|
|
122
|
+
except Exception as e:
|
|
123
|
+
self.stdout.write(self.style.WARNING(f"⚠️ Failed to generate model docs: {e}"))
|
|
124
|
+
self.stdout.write(self.style.WARNING("Continuing with endpoint generation..."))
|
|
125
|
+
else:
|
|
126
|
+
self.stdout.write(self.style.WARNING("⚠️ No model data found"))
|
|
127
|
+
|
|
128
|
+
# Generate endpoint documentation
|
|
129
|
+
self.stdout.write("🔗 Generating endpoint documentation...")
|
|
130
|
+
endpoints_by_app = parse_endpoints_from_schema(paths)
|
|
131
|
+
total_endpoints = generate_endpoint_files(endpoints_by_app, components)
|
|
132
|
+
create_endpoints_index(endpoints_by_app, docs_dir)
|
|
133
|
+
|
|
134
|
+
self.stdout.write(
|
|
135
|
+
self.style.SUCCESS(
|
|
136
|
+
f"✅ Generated {total_endpoints} endpoint files with Django view introspection"
|
|
137
|
+
)
|
|
138
|
+
)
|