@apify/docusaurus-plugin-typedoc-api 4.2.4 → 4.2.6
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.
- package/assets/styles-8ad572ec.css +44 -0
- package/lib/components/ApiItem.js +53 -29
- package/lib/components/ApiItem.js.map +1 -1
- package/lib/components/ApiItemLayout.js +15 -8
- package/lib/components/ApiItemLayout.js.map +1 -1
- package/lib/components/ApiOptionsLayout.js +35 -0
- package/lib/components/ApiOptionsLayout.js.map +1 -0
- package/lib/components/Comment.js +3 -0
- package/lib/components/Comment.js.map +1 -1
- package/lib/components/Member.js +4 -1
- package/lib/components/Member.js.map +1 -1
- package/lib/components/MemberSignatureBody.js +57 -16
- package/lib/components/MemberSignatureBody.js.map +1 -1
- package/lib/components/MemberSignatureTitle.js +11 -1
- package/lib/components/MemberSignatureTitle.js.map +1 -1
- package/lib/components/Type.js +3 -1
- package/lib/components/Type.js.map +1 -1
- package/lib/index.js +4 -14
- package/lib/index.js.map +1 -1
- package/lib/plugin/data.js +38 -1
- package/lib/plugin/data.js.map +1 -1
- package/package.json +2 -1
- package/src/components/ApiItem.tsx +48 -32
- package/src/components/ApiItemLayout.tsx +11 -6
- package/src/components/ApiOptionsLayout.tsx +22 -0
- package/src/components/Comment.tsx +3 -0
- package/src/components/Member.tsx +6 -2
- package/src/components/MemberSignatureBody.tsx +67 -16
- package/src/components/MemberSignatureTitle.tsx +14 -1
- package/src/components/Type.tsx +3 -1
- package/src/components/styles.css +44 -0
- package/src/index.ts +11 -19
- package/src/plugin/data.ts +37 -2
- package/src/types.ts +5 -1
- package/lib/plugin/python-generator/index.js +0 -23
- package/lib/plugin/python-generator/index.js.map +0 -1
- package/lib/plugin/python-generator/pydoc-markdown.js +0 -72
- package/lib/plugin/python-generator/pydoc-markdown.js.map +0 -1
- package/lib/plugin/python-generator/transform-docs.js +0 -393
- package/lib/plugin/python-generator/transform-docs.js.map +0 -1
- package/src/plugin/python-generator/index.ts +0 -18
- package/src/plugin/python-generator/pydoc-markdown.ts +0 -70
- package/src/plugin/python-generator/transform-docs.ts +0 -417
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
11
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
14
|
-
const fs = require('node:fs');
|
|
15
|
-
const zx = require('zx');
|
|
16
|
-
const _interopDefault = e => e && e.__esModule ? e : {
|
|
17
|
-
default: e
|
|
18
|
-
};
|
|
19
|
-
const fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
20
|
-
|
|
21
|
-
/* eslint-disable */
|
|
22
|
-
const REPO_ROOT_PLACEHOLDER = 'REPO_ROOT_PLACEHOLDER';
|
|
23
|
-
|
|
24
|
-
// TODO: Make these parametrizable (gitRepoUrls array option)
|
|
25
|
-
const APIFY_CLIENT_REPO_URL = 'https://github.com/apify/apify-client-python';
|
|
26
|
-
const APIFY_SDK_REPO_URL = 'https://github.com/apify/apify-sdk-python';
|
|
27
|
-
const APIFY_SHARED_REPO_URL = 'https://github.com/apify/apify-shared-python';
|
|
28
|
-
const CRAWLEE_PYTHON_REPO_URL = 'https://github.com/apify/crawlee-python';
|
|
29
|
-
const REPO_URL_PER_PACKAGE = {
|
|
30
|
-
'apify': APIFY_SDK_REPO_URL,
|
|
31
|
-
'apify_client': APIFY_CLIENT_REPO_URL,
|
|
32
|
-
'apify_shared': APIFY_SHARED_REPO_URL,
|
|
33
|
-
'crawlee': CRAWLEE_PYTHON_REPO_URL
|
|
34
|
-
};
|
|
35
|
-
const TAG_PER_PACKAGE = {};
|
|
36
|
-
let MODULE_SHORTCUTS = {};
|
|
37
|
-
async function initPackageTags({
|
|
38
|
-
moduleName
|
|
39
|
-
}) {
|
|
40
|
-
// For each package, get the installed version, and set the tag to the corresponding version
|
|
41
|
-
for (const pkg of ['apify', 'apify_client', 'apify_shared']) {
|
|
42
|
-
try {
|
|
43
|
-
const packageVersion = await zx.$`python -c 'import ${pkg}; print(${pkg}.__version__)'`;
|
|
44
|
-
if (packageVersion.exitCode === 0) {
|
|
45
|
-
TAG_PER_PACKAGE[pkg] = `v${await packageVersion.text()}`;
|
|
46
|
-
}
|
|
47
|
-
} catch (e) {
|
|
48
|
-
console.warn(`Failed to get version of package ${pkg}`);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
if (!moduleName) {
|
|
52
|
-
const thisPackagePyprojectToml = fs__default.default.readFileSync('../pyproject.toml', 'utf8');
|
|
53
|
-
moduleName = thisPackagePyprojectToml.match(/^name = "(.+)"$/m)?.[1];
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// For the current package, set the tag to 'master'
|
|
57
|
-
TAG_PER_PACKAGE[moduleName] = 'master';
|
|
58
|
-
return TAG_PER_PACKAGE;
|
|
59
|
-
}
|
|
60
|
-
async function initModuleShortcuts() {
|
|
61
|
-
if (!fs__default.default.existsSync('./module_shortcuts.json')) {
|
|
62
|
-
return console.warn('No module_shortcuts.json file found, skipping module shortcuts.');
|
|
63
|
-
}
|
|
64
|
-
MODULE_SHORTCUTS = JSON.parse(fs__default.default.readFileSync('./module_shortcuts.json', 'utf8'));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// Taken from https://github.com/TypeStrong/typedoc/blob/v0.23.24/src/lib/models/reflections/kind.ts, modified
|
|
68
|
-
const TYPEDOC_KINDS = {
|
|
69
|
-
'class': {
|
|
70
|
-
kind: 128,
|
|
71
|
-
kindString: 'Class'
|
|
72
|
-
},
|
|
73
|
-
'function': {
|
|
74
|
-
kind: 2048,
|
|
75
|
-
kindString: 'Method'
|
|
76
|
-
},
|
|
77
|
-
'data': {
|
|
78
|
-
kind: 1024,
|
|
79
|
-
kindString: 'Property'
|
|
80
|
-
},
|
|
81
|
-
'enum': {
|
|
82
|
-
kind: 8,
|
|
83
|
-
kindString: 'Enumeration'
|
|
84
|
-
},
|
|
85
|
-
'enumValue': {
|
|
86
|
-
kind: 16,
|
|
87
|
-
kindString: 'Enumeration Member'
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
const GROUP_ORDER = ['Main Classes', 'Helper Classes', 'Errors', 'Constructors', 'Methods', 'Properties', 'Constants', 'Enumeration Members'];
|
|
91
|
-
const groupSort = (g1, g2) => {
|
|
92
|
-
if (GROUP_ORDER.includes(g1) && GROUP_ORDER.includes(g2)) {
|
|
93
|
-
return GROUP_ORDER.indexOf(g1) - GROUP_ORDER.indexOf(g2);
|
|
94
|
-
}
|
|
95
|
-
return g1.localeCompare(g2);
|
|
96
|
-
};
|
|
97
|
-
function getGroupName(object) {
|
|
98
|
-
const groupPredicates = {
|
|
99
|
-
'Errors': x => x.name.toLowerCase().includes('error'),
|
|
100
|
-
'Main Classes': x => ['Dataset', 'KeyValueStore', 'RequestQueue'].includes(x.name) || x.name.endsWith('Crawler'),
|
|
101
|
-
'Helper Classes': x => x.kindString === 'Class',
|
|
102
|
-
'Methods': x => x.kindString === 'Method',
|
|
103
|
-
'Constructors': x => x.kindString === 'Constructor',
|
|
104
|
-
'Properties': x => x.kindString === 'Property',
|
|
105
|
-
'Constants': x => x.kindString === 'Enumeration',
|
|
106
|
-
'Enumeration Members': x => x.kindString === 'Enumeration Member'
|
|
107
|
-
};
|
|
108
|
-
const _Object$entries$find = Object.entries(groupPredicates).find(([_, predicate]) => predicate(object)),
|
|
109
|
-
_Object$entries$find2 = _slicedToArray(_Object$entries$find, 1),
|
|
110
|
-
group = _Object$entries$find2[0];
|
|
111
|
-
return group;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Strips the Optional[] type from the type string, and replaces generic types with just the main type
|
|
115
|
-
function getBaseType(type) {
|
|
116
|
-
return type?.replace(/Optional\[(.*)\]/g, '$1').replace('ListPage[Dict]', 'ListPage');
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Returns whether a type is a custom class, or a primitive type
|
|
120
|
-
function isCustomClass(type) {
|
|
121
|
-
return !['dict', 'list', 'str', 'int', 'float', 'bool'].includes(type.toLowerCase());
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Infer the Typedoc type from the docspec type
|
|
125
|
-
function inferTypedocType(docspecType) {
|
|
126
|
-
const typeWithoutOptional = getBaseType(docspecType);
|
|
127
|
-
if (!typeWithoutOptional) {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Typically, if a type is a custom class, it will be a reference in Typedoc
|
|
132
|
-
return isCustomClass(typeWithoutOptional) ? {
|
|
133
|
-
type: 'reference',
|
|
134
|
-
name: docspecType
|
|
135
|
-
} : {
|
|
136
|
-
type: 'intrinsic',
|
|
137
|
-
name: docspecType
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Sorts the groups of a Typedoc member, and sorts the children of each group
|
|
142
|
-
function sortChildren(typedocMember) {
|
|
143
|
-
for (let group of typedocMember.groups) {
|
|
144
|
-
group.children.sort((a, b) => {
|
|
145
|
-
const firstName = typedocMember.children.find(x => x.id === a).name;
|
|
146
|
-
const secondName = typedocMember.children.find(x => x.id === b).name;
|
|
147
|
-
return firstName.localeCompare(secondName);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
typedocMember.groups.sort((a, b) => groupSort(a.title, b.title));
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
// Parses the arguments and return value description of a method from its docstring
|
|
154
|
-
function extractArgsAndReturns(docstring) {
|
|
155
|
-
const parameters = (docstring.split('Args:')[1] ?? '').split('Returns:')[0] // Get the part between Args: and Returns:
|
|
156
|
-
.split(/(^|\n)\s*([\w]+)\s*\(.*?\)\s*:\s*/) // Magic regex which splits the arguments into an array, and removes the argument types
|
|
157
|
-
.filter(x => x.length > 1) // Remove empty strings
|
|
158
|
-
.reduce((acc, curr, idx, arr) => {
|
|
159
|
-
// Collect the argument names and types into an object
|
|
160
|
-
if (idx % 2 === 0) {
|
|
161
|
-
return _objectSpread(_objectSpread({}, acc), {}, {
|
|
162
|
-
[curr]: arr[idx + 1]
|
|
163
|
-
}); // If the index is even, the current string is an argument name, and the next string is its type
|
|
164
|
-
}
|
|
165
|
-
return acc;
|
|
166
|
-
}, {});
|
|
167
|
-
const returns = (docstring.split('Returns:')[1] ?? '').split('Raises:')[0] // Get the part between Returns: and Raises:
|
|
168
|
-
.split(':')[1]?.trim() || undefined; // Split the return value into its type and description, return description
|
|
169
|
-
|
|
170
|
-
return {
|
|
171
|
-
parameters,
|
|
172
|
-
returns
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
// Objects with decorators named 'ignore_docs' or with empty docstrings will be ignored
|
|
177
|
-
function isHidden(member) {
|
|
178
|
-
return member.decorations?.some(d => d.name === 'ignore_docs') || member.name === 'ignore_docs';
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// Each object in the Typedoc structure has an unique ID,
|
|
182
|
-
// we'll just increment it for each object we convert
|
|
183
|
-
let oid = 1;
|
|
184
|
-
const symbolIdMap = [];
|
|
185
|
-
|
|
186
|
-
// Converts a docspec object to a Typedoc object, including all its children
|
|
187
|
-
function convertObject(obj, parent, module) {
|
|
188
|
-
const rootModuleName = module.name.split('.')[0];
|
|
189
|
-
for (let member of obj.members ?? []) {
|
|
190
|
-
let typedocKind = TYPEDOC_KINDS[member.type];
|
|
191
|
-
if (member.bases?.includes('Enum')) {
|
|
192
|
-
typedocKind = TYPEDOC_KINDS['enum'];
|
|
193
|
-
}
|
|
194
|
-
let typedocType = inferTypedocType(member.datatype);
|
|
195
|
-
if (member.decorations?.some(d => ['property', 'dualproperty'].includes(d.name))) {
|
|
196
|
-
typedocKind = TYPEDOC_KINDS['data'];
|
|
197
|
-
typedocType = inferTypedocType(member.return_type ?? member.datatype);
|
|
198
|
-
}
|
|
199
|
-
if (parent.kindString === 'Enumeration') {
|
|
200
|
-
typedocKind = TYPEDOC_KINDS['enumValue'];
|
|
201
|
-
typedocType = {
|
|
202
|
-
type: 'literal',
|
|
203
|
-
value: member.value
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
if (member.type in TYPEDOC_KINDS && !isHidden(member)) {
|
|
207
|
-
// Get the URL of the member in GitHub
|
|
208
|
-
const repoBaseUrl = `${REPO_URL_PER_PACKAGE[rootModuleName]}/blob/${TAG_PER_PACKAGE[rootModuleName] ?? 'master'}`;
|
|
209
|
-
const filePathInRepo = member.location.filename.replace(REPO_ROOT_PLACEHOLDER, '');
|
|
210
|
-
const fileGitHubUrl = member.location.filename.replace(REPO_ROOT_PLACEHOLDER, repoBaseUrl);
|
|
211
|
-
const memberGitHubUrl = `${fileGitHubUrl}#L${member.location.lineno}`;
|
|
212
|
-
symbolIdMap.push({
|
|
213
|
-
qualifiedName: member.name,
|
|
214
|
-
sourceFileName: filePathInRepo
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
// Get the module name of the member, and check if it has a shortcut (reexport from an ancestor module)
|
|
218
|
-
const fullName = `${module.name}.${member.name}`;
|
|
219
|
-
let moduleName = module.name;
|
|
220
|
-
if (fullName in MODULE_SHORTCUTS) {
|
|
221
|
-
moduleName = MODULE_SHORTCUTS[fullName].replace(`.${member.name}`, '');
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// Create the Typedoc member object
|
|
225
|
-
let typedocMember = _objectSpread(_objectSpread({
|
|
226
|
-
id: oid++,
|
|
227
|
-
name: member.name,
|
|
228
|
-
module: moduleName
|
|
229
|
-
}, typedocKind), {}, {
|
|
230
|
-
flags: {},
|
|
231
|
-
comment: member.docstring ? {
|
|
232
|
-
summary: [{
|
|
233
|
-
kind: 'text',
|
|
234
|
-
text: member.docstring?.content
|
|
235
|
-
}]
|
|
236
|
-
} : undefined,
|
|
237
|
-
type: typedocType,
|
|
238
|
-
children: [],
|
|
239
|
-
groups: [],
|
|
240
|
-
sources: [{
|
|
241
|
-
filename: filePathInRepo,
|
|
242
|
-
line: member.location.lineno,
|
|
243
|
-
character: 1,
|
|
244
|
-
url: memberGitHubUrl
|
|
245
|
-
}],
|
|
246
|
-
signatures: []
|
|
247
|
-
});
|
|
248
|
-
if (typedocMember.kindString === 'Method') {
|
|
249
|
-
const _extractArgsAndReturn = extractArgsAndReturns(member.docstring?.content ?? ''),
|
|
250
|
-
parameters = _extractArgsAndReturn.parameters,
|
|
251
|
-
returns = _extractArgsAndReturn.returns;
|
|
252
|
-
typedocMember.signatures = [{
|
|
253
|
-
id: oid++,
|
|
254
|
-
name: member.name,
|
|
255
|
-
modifiers: member.modifiers ?? [],
|
|
256
|
-
kind: 4096,
|
|
257
|
-
kindString: 'Call signature',
|
|
258
|
-
flags: {},
|
|
259
|
-
comment: member.docstring ? {
|
|
260
|
-
summary: [{
|
|
261
|
-
kind: 'text',
|
|
262
|
-
text: member.docstring?.content.replace(/\**(Args|Arguments|Returns)[\s\S]+/, '')
|
|
263
|
-
}],
|
|
264
|
-
blockTags: returns ? [{
|
|
265
|
-
tag: '@returns',
|
|
266
|
-
content: [{
|
|
267
|
-
kind: 'text',
|
|
268
|
-
text: returns
|
|
269
|
-
}]
|
|
270
|
-
}] : undefined
|
|
271
|
-
} : undefined,
|
|
272
|
-
type: inferTypedocType(member.return_type),
|
|
273
|
-
parameters: member.args.filter(arg => arg.name !== 'self' && arg.name !== 'cls').map(arg => ({
|
|
274
|
-
id: oid++,
|
|
275
|
-
name: arg.name,
|
|
276
|
-
kind: 32768,
|
|
277
|
-
kindString: 'Parameter',
|
|
278
|
-
flags: {
|
|
279
|
-
isOptional: arg.datatype?.includes('Optional') ? 'true' : undefined,
|
|
280
|
-
'keyword-only': arg.type === 'KEYWORD_ONLY' ? 'true' : undefined
|
|
281
|
-
},
|
|
282
|
-
type: inferTypedocType(arg.datatype),
|
|
283
|
-
comment: parameters[arg.name] ? {
|
|
284
|
-
summary: [{
|
|
285
|
-
kind: 'text',
|
|
286
|
-
text: parameters[arg.name]
|
|
287
|
-
}]
|
|
288
|
-
} : undefined,
|
|
289
|
-
defaultValue: arg.default_value
|
|
290
|
-
}))
|
|
291
|
-
}];
|
|
292
|
-
}
|
|
293
|
-
if (typedocMember.name === '__init__') {
|
|
294
|
-
typedocMember.kind = 512;
|
|
295
|
-
typedocMember.kindString = 'Constructor';
|
|
296
|
-
}
|
|
297
|
-
convertObject(member, typedocMember, module);
|
|
298
|
-
const groupName = getGroupName(typedocMember);
|
|
299
|
-
const group = parent.groups.find(g => g.title === groupName);
|
|
300
|
-
if (group) {
|
|
301
|
-
group.children.push(typedocMember.id);
|
|
302
|
-
} else {
|
|
303
|
-
parent.groups.push({
|
|
304
|
-
title: groupName,
|
|
305
|
-
children: [typedocMember.id]
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
sortChildren(typedocMember);
|
|
309
|
-
parent.children.push(typedocMember);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
async function pydocToTypedoc({
|
|
314
|
-
pydocFile,
|
|
315
|
-
pydocJson,
|
|
316
|
-
outFile,
|
|
317
|
-
moduleName
|
|
318
|
-
}) {
|
|
319
|
-
await initPackageTags({
|
|
320
|
-
moduleName
|
|
321
|
-
});
|
|
322
|
-
await initModuleShortcuts();
|
|
323
|
-
|
|
324
|
-
// Root object of the Typedoc structure
|
|
325
|
-
const typedocApiReference = {
|
|
326
|
-
'id': 0,
|
|
327
|
-
'name': 'apify-client',
|
|
328
|
-
'kind': 1,
|
|
329
|
-
'kindString': 'Project',
|
|
330
|
-
'flags': {},
|
|
331
|
-
'originalName': '',
|
|
332
|
-
'children': [],
|
|
333
|
-
'groups': [],
|
|
334
|
-
'sources': [{
|
|
335
|
-
'fileName': 'src/index.ts',
|
|
336
|
-
'line': 1,
|
|
337
|
-
'character': 0,
|
|
338
|
-
'url': `http://example.com/blob/123456/src/dummy.py`
|
|
339
|
-
}],
|
|
340
|
-
'symbolIdMap': {}
|
|
341
|
-
};
|
|
342
|
-
|
|
343
|
-
// Load the docspec dump files of this module and of apify-shared
|
|
344
|
-
const thisPackageDocspecDump = pydocJson ?? fs__default.default.readFileSync(pydocFile, 'utf8');
|
|
345
|
-
const thisPackageModules = thisPackageDocspecDump.split('\n').filter(line => line !== '');
|
|
346
|
-
|
|
347
|
-
// Convert all the modules, store them in the root object
|
|
348
|
-
for (const module of [...thisPackageModules]) {
|
|
349
|
-
const parsedModule = JSON.parse(module);
|
|
350
|
-
convertObject(parsedModule, typedocApiReference, parsedModule);
|
|
351
|
-
}
|
|
352
|
-
;
|
|
353
|
-
|
|
354
|
-
// Recursively fix references (collect names->ids of all the named entities and then inject those in the reference objects)
|
|
355
|
-
const namesToIds = {};
|
|
356
|
-
function collectIds(obj) {
|
|
357
|
-
for (const child of obj.children ?? []) {
|
|
358
|
-
namesToIds[child.name] = child.id;
|
|
359
|
-
collectIds(child);
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
collectIds(typedocApiReference);
|
|
363
|
-
function fixRefs(obj) {
|
|
364
|
-
for (const child of obj.children ?? []) {
|
|
365
|
-
if (child.type?.type === 'reference') {
|
|
366
|
-
child.type.id = namesToIds[child.type.name];
|
|
367
|
-
}
|
|
368
|
-
if (child.signatures) {
|
|
369
|
-
for (const sig of child.signatures) {
|
|
370
|
-
for (const param of sig.parameters ?? []) {
|
|
371
|
-
if (param.type?.type === 'reference') {
|
|
372
|
-
param.type.id = namesToIds[param.type.name];
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
if (sig.type?.type === 'reference') {
|
|
376
|
-
sig.type.id = namesToIds[sig.type.name];
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
fixRefs(child);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
fixRefs(typedocApiReference);
|
|
384
|
-
|
|
385
|
-
// Sort the children of the root object
|
|
386
|
-
sortChildren(typedocApiReference);
|
|
387
|
-
typedocApiReference.symbolIdMap = Object.fromEntries(Object.entries(symbolIdMap));
|
|
388
|
-
|
|
389
|
-
// Write the Typedoc structure to the output file
|
|
390
|
-
fs__default.default.writeFileSync(outFile, JSON.stringify(typedocApiReference, null, 4));
|
|
391
|
-
}
|
|
392
|
-
exports.pydocToTypedoc = pydocToTypedoc;
|
|
393
|
-
//# sourceMappingURL=transform-docs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transform-docs.js","sources":["../../../src/plugin/python-generator/transform-docs.ts"],"sourcesContent":null,"names":["$","fs"],"mappings":";;;;;;;;;AAAA;AAGA,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AACtD;AACA;AACA,MAAM,qBAAqB,GAAG,8CAA8C,CAAC;AAC7E,MAAM,kBAAkB,GAAG,2CAA2C,CAAC;AACvE,MAAM,qBAAqB,GAAG,8CAA8C,CAAC;AAC7E,MAAM,uBAAuB,GAAG,yCAAyC,CAAC;AAC1E,MAAM,oBAAoB,GAAG;AAC7B,EAAE,OAAO,EAAE,kBAAkB;AAC7B,EAAE,cAAc,EAAE,qBAAqB;AACvC,EAAE,cAAc,EAAE,qBAAqB;AACvC,EAAE,SAAS,EAAE,uBAAuB;AACpC,CAAC,CAAC;AACF,MAAM,eAAe,GAAG,EAAE,CAAC;AAC3B,IAAI,gBAAgB,GAAG,EAAE,CAAC;AAC1B,eAAe,eAAe,CAAC;AAC/B,EAAE,UAAU;AACZ,CAAC,EAAE;AACH;AACA,EAAE,KAAK,MAAM,GAAG,IAAI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KAAK,CAAC,UAAU,EAAE;AAC5B,QAAQ,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,UAAU,EAAE;AAC5C,UAAU,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,UAAU,IAAI,EAAE,EAAE;AACpD,YAAY,IAAI,KAAK,CAAC,IAAI,EAAE,IAAI,KAAK,WAAW,EAAE;AAClD,cAAc,KAAK,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,aAAa;AACb,WAAW;AACX,UAAU,IAAI,GAAG,CAAC,IAAI,EAAE,IAAI,KAAK,WAAW,EAAE;AAC9C,YAAY,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACpD,WAAW;AACX,SAAS;AACT,OAAO;AACP,MAAM,OAAO,CAAC,KAAK,CAAC,CAAC;AACrB,KAAK;AACL,GAAG;AACH,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAC/B;AACA;AACA,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC;AACpC,EAAE,mBAAmB,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;AACpF;AACA;AACA,EAAEA,mBAAE,CAAC,aAAa,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E;;;;"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { spinner } from 'zx';
|
|
2
|
-
import { parseWithPydocMarkdown } from "./pydoc-markdown";
|
|
3
|
-
import { pydocToTypedoc } from "./transform-docs";
|
|
4
|
-
|
|
5
|
-
export async function generateJsonFromPythonProject({
|
|
6
|
-
outFile,
|
|
7
|
-
projectRoot,
|
|
8
|
-
} : { outFile: string, projectRoot: string }): Promise<void> {
|
|
9
|
-
const pydocJson = await parseWithPydocMarkdown({ projectRoot });
|
|
10
|
-
|
|
11
|
-
await spinner('Converting the Python JSON AST to a TypeDoc-compliant file...', async () => {
|
|
12
|
-
await pydocToTypedoc({
|
|
13
|
-
moduleName: 'python', // TODO: get from project config files or passed options
|
|
14
|
-
outFile,
|
|
15
|
-
pydocJson,
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { rmSync, writeFileSync } from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
import { $, ProcessOutput, spinner } from 'zx';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Generates the pydoc-markdown configuration file
|
|
7
|
-
* @returns The pydoc-markdown configuration file as a string
|
|
8
|
-
*/
|
|
9
|
-
function getConfigYml({
|
|
10
|
-
projectRoot
|
|
11
|
-
}: { projectRoot: string }): string {
|
|
12
|
-
return `
|
|
13
|
-
loaders:
|
|
14
|
-
- type: python
|
|
15
|
-
search_path: ["${projectRoot}"]
|
|
16
|
-
processors:
|
|
17
|
-
- type: filter
|
|
18
|
-
skip_empty_modules: true
|
|
19
|
-
- type: crossref
|
|
20
|
-
renderer:
|
|
21
|
-
type: docusaurus
|
|
22
|
-
docs_base_path: docs
|
|
23
|
-
relative_output_path: reference
|
|
24
|
-
relative_sidebar_path: sidebar.json
|
|
25
|
-
sidebar_top_level_label: null
|
|
26
|
-
`
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export async function parseWithPydocMarkdown({
|
|
30
|
-
projectRoot,
|
|
31
|
-
}: {
|
|
32
|
-
projectRoot: string,
|
|
33
|
-
}
|
|
34
|
-
): Promise<string> {
|
|
35
|
-
// Check whether the user has Python and pydoc-markdown installed
|
|
36
|
-
for (const cmd of ['python', 'pydoc-markdown']) {
|
|
37
|
-
try {
|
|
38
|
-
// eslint-disable-next-line no-await-in-loop
|
|
39
|
-
await spinner(`Checking for ${cmd}...`, () => $`${cmd} --version`);
|
|
40
|
-
} catch {
|
|
41
|
-
throw new Error(`Please install ${cmd} to use this plugin with Python projects.`);
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// Generate the JSON file
|
|
46
|
-
try {
|
|
47
|
-
const configYml = getConfigYml({ projectRoot });
|
|
48
|
-
const configPath = path.join(__dirname, 'pydoc-markdown.temp.yml');
|
|
49
|
-
writeFileSync(configPath, configYml);
|
|
50
|
-
|
|
51
|
-
let pydoc: ProcessOutput | null = null;
|
|
52
|
-
|
|
53
|
-
await spinner('Parsing the Python project into a JSON AST...', async () => {
|
|
54
|
-
pydoc = await $`pydoc-markdown --quiet --dump ${configPath}`;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
rmSync(configPath);
|
|
58
|
-
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
60
|
-
let json = await pydoc!.text();
|
|
61
|
-
|
|
62
|
-
json = json.replaceAll(path.resolve(projectRoot), 'REPO_ROOT_PLACEHOLDER');
|
|
63
|
-
|
|
64
|
-
return json;
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
-
} catch (error: any) {
|
|
67
|
-
// eslint-disable-next-line
|
|
68
|
-
throw new Error(`Failed to generate JSON file from Python project:\n\t${error.stderr.split('\n').slice(-2).join('\n')}`);
|
|
69
|
-
}
|
|
70
|
-
}
|