drf-to-mkdoc 0.2.2__py3-none-any.whl → 0.2.4__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 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/field-sections-loader.js +29 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/query-parameters-loader.js +16 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/field-extractor.js +200 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/form-manager.js +465 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/main.js +50 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/modal.js +359 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/query-parameters-extractor.js +94 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/request-executor.js +327 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/response-modal.js +173 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/suggestions.js +123 -0
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out/tabs.js +77 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/badges.css +13 -5
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/theme-toggle.css +297 -25
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/try-out/fab.css +204 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/try-out/response.css +323 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/try-out/variables.css +139 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/field-sections.css +136 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/buttons.css +71 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/fab.css +47 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/form.css +663 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/key-value.css +161 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/main.css +57 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/modal.css +334 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/response.css +618 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/tabs.css +114 -0
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/try-out/variables.css +94 -0
- drf_to_mkdoc/templates/endpoints/detail/base.html +3 -1
- drf_to_mkdoc/templates/endpoints/detail/query_parameters.html +1 -8
- drf_to_mkdoc/templates/endpoints/detail/request_body.html +2 -0
- drf_to_mkdoc/templates/endpoints/detail/responses.html +4 -4
- drf_to_mkdoc/templates/try-out/fab.html +68 -0
- drf_to_mkdoc/templates/try-out/form.html +260 -0
- drf_to_mkdoc/templates/try-out/main.html +4 -0
- drf_to_mkdoc/templates/try-out/modal.html +82 -0
- drf_to_mkdoc/templates/try-out/response-modal.html +149 -0
- drf_to_mkdoc/templatetags/custom_filters.py +33 -1
- drf_to_mkdoc/utils/commons/schema_utils.py +5 -14
- drf_to_mkdoc/utils/endpoint_detail_generator.py +141 -21
- drf_to_mkdoc/utils/extractors/query_parameter_extractors.py +0 -15
- {drf_to_mkdoc-0.2.2.dist-info → drf_to_mkdoc-0.2.4.dist-info}/METADATA +68 -9
- {drf_to_mkdoc-0.2.2.dist-info → drf_to_mkdoc-0.2.4.dist-info}/RECORD +45 -18
- drf_to_mkdoc/static/drf-to-mkdoc/javascripts/try-out-sidebar.js +0 -879
- drf_to_mkdoc/static/drf-to-mkdoc/stylesheets/endpoints/try-out-sidebar.css +0 -728
- {drf_to_mkdoc-0.2.2.dist-info → drf_to_mkdoc-0.2.4.dist-info}/WHEEL +0 -0
- {drf_to_mkdoc-0.2.2.dist-info → drf_to_mkdoc-0.2.4.dist-info}/licenses/LICENSE +0 -0
- {drf_to_mkdoc-0.2.2.dist-info → drf_to_mkdoc-0.2.4.dist-info}/top_level.txt +0 -0
drf_to_mkdoc/conf/defaults.py
CHANGED
|
@@ -7,6 +7,7 @@ DEFAULTS = {
|
|
|
7
7
|
"CUSTOM_SCHEMA_FILE": "docs/configs/custom_schema.json", # Path to custom schema file
|
|
8
8
|
"PATH_PARAM_SUBSTITUTE_FUNCTION": None,
|
|
9
9
|
"PATH_PARAM_SUBSTITUTE_MAPPING": {},
|
|
10
|
+
"FIELD_GENERATORS": {},
|
|
10
11
|
# AI documentation settings
|
|
11
12
|
"ENABLE_AI_DOCS": False,
|
|
12
13
|
"AI_CONFIG_DIR_NAME": "ai_code", # Directory name for AI-generated code files
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Loader script for field sections functionality
|
|
2
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
3
|
+
// Load CSS
|
|
4
|
+
function loadCSS(url) {
|
|
5
|
+
const link = document.createElement('link');
|
|
6
|
+
link.rel = 'stylesheet';
|
|
7
|
+
link.href = url;
|
|
8
|
+
document.head.appendChild(link);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Load JavaScript
|
|
12
|
+
function loadScript(url, callback) {
|
|
13
|
+
const script = document.createElement('script');
|
|
14
|
+
script.src = url;
|
|
15
|
+
script.onload = callback || function() {};
|
|
16
|
+
document.body.appendChild(script);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Base URL for static files
|
|
20
|
+
const baseUrl = document.querySelector('meta[name="static-url"]')?.getAttribute('content') || '';
|
|
21
|
+
|
|
22
|
+
// Load CSS file
|
|
23
|
+
loadCSS(baseUrl + '/static/drf-to-mkdoc/stylesheets/field-sections.css');
|
|
24
|
+
|
|
25
|
+
// Load field extractor script
|
|
26
|
+
loadScript(baseUrl + '/static/drf-to-mkdoc/javascripts/try-out/field-extractor.js');
|
|
27
|
+
|
|
28
|
+
console.log('Field sections functionality loaded');
|
|
29
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Query parameters loader script
|
|
2
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
3
|
+
// Load JavaScript
|
|
4
|
+
function loadScript(url, callback) {
|
|
5
|
+
const script = document.createElement('script');
|
|
6
|
+
script.src = url;
|
|
7
|
+
script.onload = callback || function() {};
|
|
8
|
+
document.body.appendChild(script);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Base URL for static files
|
|
12
|
+
const baseUrl = document.querySelector('meta[name="static-url"]')?.getAttribute('content') || '';
|
|
13
|
+
|
|
14
|
+
// Load query parameters extractor script
|
|
15
|
+
loadScript(baseUrl + '/static/drf-to-mkdoc/javascripts/try-out/query-parameters-extractor.js');
|
|
16
|
+
});
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Field extractor for documentation content
|
|
2
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
3
|
+
// Extract filter fields and pagination fields from documentation
|
|
4
|
+
const FieldExtractor = {
|
|
5
|
+
init: function() {
|
|
6
|
+
// Extract fields from documentation
|
|
7
|
+
const fields = this.extractFieldsFromDocumentation();
|
|
8
|
+
|
|
9
|
+
// Make fields available for suggestions
|
|
10
|
+
if (fields && (fields.filter_fields.length > 0 || fields.pagination_fields.length > 0)) {
|
|
11
|
+
window.queryParametersData = window.queryParametersData || {};
|
|
12
|
+
|
|
13
|
+
// Add filter fields
|
|
14
|
+
if (fields.filter_fields.length > 0) {
|
|
15
|
+
window.queryParametersData.filter_fields = fields.filter_fields;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Add pagination fields
|
|
19
|
+
if (fields.pagination_fields.length > 0) {
|
|
20
|
+
window.queryParametersData.pagination_fields = fields.pagination_fields;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Initialize suggestions if TryOutSuggestions is available
|
|
24
|
+
if (window.TryOutSuggestions) {
|
|
25
|
+
window.TryOutSuggestions.init();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
extractFieldsFromDocumentation: function() {
|
|
31
|
+
const result = {
|
|
32
|
+
filter_fields: [],
|
|
33
|
+
pagination_fields: []
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
// Look for filter fields section
|
|
37
|
+
const filterFieldsHeading = document.querySelector('h3#filter-fields');
|
|
38
|
+
if (filterFieldsHeading) {
|
|
39
|
+
const filterFieldsList = filterFieldsHeading.nextElementSibling;
|
|
40
|
+
if (filterFieldsList && filterFieldsList.tagName === 'UL') {
|
|
41
|
+
const filterFields = Array.from(filterFieldsList.querySelectorAll('li code'))
|
|
42
|
+
.map(code => code.textContent.trim());
|
|
43
|
+
|
|
44
|
+
if (filterFields.length > 0) {
|
|
45
|
+
result.filter_fields = filterFields;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Look for pagination fields section
|
|
51
|
+
const paginationFieldsHeading = document.querySelector('h3#pagination-fields');
|
|
52
|
+
if (paginationFieldsHeading) {
|
|
53
|
+
const paginationFieldsList = paginationFieldsHeading.nextElementSibling;
|
|
54
|
+
if (paginationFieldsList && paginationFieldsList.tagName === 'UL') {
|
|
55
|
+
const paginationFields = Array.from(paginationFieldsList.querySelectorAll('li code'))
|
|
56
|
+
.map(code => code.textContent.trim());
|
|
57
|
+
|
|
58
|
+
if (paginationFields.length > 0) {
|
|
59
|
+
result.pagination_fields = paginationFields;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return result;
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
formatDocumentation: function() {
|
|
68
|
+
// Format filter fields section
|
|
69
|
+
this.formatSection('filter-fields', 'Filter Fields');
|
|
70
|
+
|
|
71
|
+
// Format pagination fields section
|
|
72
|
+
this.formatSection('pagination-fields', 'Pagination Fields');
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
formatSection: function(sectionId, title) {
|
|
76
|
+
const heading = document.querySelector(`h3#${sectionId}`);
|
|
77
|
+
if (!heading) return;
|
|
78
|
+
|
|
79
|
+
const list = heading.nextElementSibling;
|
|
80
|
+
if (!list || list.tagName !== 'UL') return;
|
|
81
|
+
|
|
82
|
+
// Create a new container div
|
|
83
|
+
const container = document.createElement('div');
|
|
84
|
+
container.className = 'api-parameters-section';
|
|
85
|
+
container.id = `${sectionId}-container`;
|
|
86
|
+
|
|
87
|
+
// Create a new heading
|
|
88
|
+
const newHeading = document.createElement('h3');
|
|
89
|
+
newHeading.id = sectionId;
|
|
90
|
+
newHeading.innerHTML = heading.innerHTML;
|
|
91
|
+
|
|
92
|
+
// Create a new list container
|
|
93
|
+
const listContainer = document.createElement('div');
|
|
94
|
+
listContainer.className = 'parameters-list';
|
|
95
|
+
|
|
96
|
+
// Create a description paragraph
|
|
97
|
+
const description = document.createElement('p');
|
|
98
|
+
description.className = 'parameters-description';
|
|
99
|
+
|
|
100
|
+
if (sectionId === 'filter-fields') {
|
|
101
|
+
description.textContent = 'These fields can be used to filter the API results. Add them as query parameters to your request.';
|
|
102
|
+
} else if (sectionId === 'pagination-fields') {
|
|
103
|
+
description.textContent = 'These fields control pagination of the API results.';
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Process the list items to enhance them
|
|
107
|
+
const enhancedList = this.enhanceParametersList(list);
|
|
108
|
+
|
|
109
|
+
// Move the list into the container
|
|
110
|
+
listContainer.appendChild(enhancedList);
|
|
111
|
+
|
|
112
|
+
// Add elements to the container
|
|
113
|
+
container.appendChild(newHeading);
|
|
114
|
+
container.appendChild(description);
|
|
115
|
+
container.appendChild(listContainer);
|
|
116
|
+
|
|
117
|
+
// Replace the old elements with the new container
|
|
118
|
+
heading.parentNode.insertBefore(container, heading);
|
|
119
|
+
list.parentNode.removeChild(list);
|
|
120
|
+
heading.parentNode.removeChild(heading);
|
|
121
|
+
|
|
122
|
+
// Add try-it buttons
|
|
123
|
+
this.addTryItButtons(container, sectionId);
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
enhanceParametersList: function(list) {
|
|
127
|
+
// Clone the list
|
|
128
|
+
const enhancedList = list.cloneNode(true);
|
|
129
|
+
|
|
130
|
+
// Process each list item
|
|
131
|
+
Array.from(enhancedList.querySelectorAll('li')).forEach(li => {
|
|
132
|
+
const code = li.querySelector('code');
|
|
133
|
+
if (code) {
|
|
134
|
+
// Create a button to try this parameter
|
|
135
|
+
const tryButton = document.createElement('button');
|
|
136
|
+
tryButton.className = 'try-param-btn';
|
|
137
|
+
tryButton.textContent = 'Try it';
|
|
138
|
+
tryButton.dataset.param = code.textContent.trim();
|
|
139
|
+
tryButton.addEventListener('click', (e) => {
|
|
140
|
+
e.preventDefault();
|
|
141
|
+
this.addParameterToTryOut(e.target.dataset.param);
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
li.appendChild(tryButton);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return enhancedList;
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
addTryItButtons: function(container, sectionId) {
|
|
152
|
+
// Create a button to try all parameters in this section
|
|
153
|
+
const tryAllButton = document.createElement('button');
|
|
154
|
+
tryAllButton.className = 'try-all-params-btn';
|
|
155
|
+
tryAllButton.textContent = 'Try All Parameters';
|
|
156
|
+
|
|
157
|
+
tryAllButton.addEventListener('click', (e) => {
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
|
|
160
|
+
// Get all parameters in this section
|
|
161
|
+
const params = Array.from(container.querySelectorAll('code'))
|
|
162
|
+
.map(code => code.textContent.trim());
|
|
163
|
+
|
|
164
|
+
// Add all parameters to try-out form
|
|
165
|
+
params.forEach(param => this.addParameterToTryOut(param));
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Add the button to the container
|
|
169
|
+
container.appendChild(tryAllButton);
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
addParameterToTryOut: function(paramName) {
|
|
173
|
+
// Find the try-out modal or form
|
|
174
|
+
const tryOutModal = document.getElementById('tryOutModal');
|
|
175
|
+
if (!tryOutModal) return;
|
|
176
|
+
|
|
177
|
+
// Show the modal if it's not already visible
|
|
178
|
+
if (tryOutModal.style.display !== 'flex') {
|
|
179
|
+
if (window.ModalManager && window.ModalManager.openTryOut) {
|
|
180
|
+
window.ModalManager.openTryOut();
|
|
181
|
+
} else {
|
|
182
|
+
tryOutModal.style.display = 'flex';
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Add the parameter to the query parameters
|
|
187
|
+
if (window.TryOutSidebar && window.TryOutSidebar.addQueryParam) {
|
|
188
|
+
window.TryOutSidebar.addQueryParam(paramName);
|
|
189
|
+
} else if (window.FormManager && window.FormManager.addQueryParam) {
|
|
190
|
+
window.FormManager.addQueryParam(paramName);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
// Initialize field extractor
|
|
196
|
+
FieldExtractor.init();
|
|
197
|
+
|
|
198
|
+
// Format documentation sections
|
|
199
|
+
FieldExtractor.formatDocumentation();
|
|
200
|
+
});
|