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.

@@ -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
+ )