@apify/docusaurus-plugin-typedoc-api 4.4.12 → 5.1.0
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/README.md +38 -296
- package/lib/components/AnchorLink.d.ts +5 -0
- package/lib/components/AnchorLink.d.ts.map +1 -0
- package/lib/components/AnchorLink.js +7 -26
- package/lib/components/AnchorLink.js.map +1 -1
- package/lib/components/ApiChangelog.d.ts +6 -0
- package/lib/components/ApiChangelog.d.ts.map +1 -0
- package/lib/components/ApiChangelog.js +7 -24
- package/lib/components/ApiChangelog.js.map +1 -1
- package/lib/components/ApiDataContext.d.ts +6 -0
- package/lib/components/ApiDataContext.d.ts.map +1 -0
- package/lib/components/ApiDataContext.js +12 -15
- package/lib/components/ApiDataContext.js.map +1 -1
- package/lib/components/ApiIndex.d.ts +14 -0
- package/lib/components/ApiIndex.d.ts.map +1 -0
- package/lib/components/ApiIndex.js +33 -93
- package/lib/components/ApiIndex.js.map +1 -1
- package/lib/components/ApiItem.d.ts +6 -0
- package/lib/components/ApiItem.d.ts.map +1 -0
- package/lib/components/ApiItem.js +131 -191
- package/lib/components/ApiItem.js.map +1 -1
- package/lib/components/ApiItemLayout.d.ts +14 -0
- package/lib/components/ApiItemLayout.d.ts.map +1 -0
- package/lib/components/ApiItemLayout.js +21 -97
- package/lib/components/ApiItemLayout.js.map +1 -1
- package/lib/components/ApiOptionsContext.d.ts +5 -0
- package/lib/components/ApiOptionsContext.d.ts.map +1 -0
- package/lib/components/ApiOptionsContext.js +5 -9
- package/lib/components/ApiOptionsContext.js.map +1 -1
- package/lib/components/ApiOptionsLayout.d.ts +4 -0
- package/lib/components/ApiOptionsLayout.d.ts.map +1 -0
- package/lib/components/ApiOptionsLayout.js +10 -34
- package/lib/components/ApiOptionsLayout.js.map +1 -1
- package/lib/components/ApiPage.d.ts +11 -0
- package/lib/components/ApiPage.d.ts.map +1 -0
- package/lib/components/ApiPage.js +50 -63
- package/lib/components/ApiPage.js.map +1 -1
- package/lib/components/Breadcrumb.d.ts +7 -0
- package/lib/components/Breadcrumb.d.ts.map +1 -0
- package/lib/components/Breadcrumb.js +17 -49
- package/lib/components/Breadcrumb.js.map +1 -1
- package/lib/components/Comment.d.ts +10 -0
- package/lib/components/Comment.d.ts.map +1 -0
- package/lib/components/Comment.js +33 -60
- package/lib/components/Comment.js.map +1 -1
- package/lib/components/CommentBadges.d.ts +9 -0
- package/lib/components/CommentBadges.d.ts.map +1 -0
- package/lib/components/CommentBadges.js +16 -28
- package/lib/components/CommentBadges.js.map +1 -1
- package/lib/components/DefaultValue.d.ts +10 -0
- package/lib/components/DefaultValue.d.ts.map +1 -0
- package/lib/components/DefaultValue.js +25 -55
- package/lib/components/DefaultValue.js.map +1 -1
- package/lib/components/Flags.d.ts +6 -0
- package/lib/components/Flags.d.ts.map +1 -0
- package/lib/components/Flags.js +11 -22
- package/lib/components/Flags.js.map +1 -1
- package/lib/components/Footer.d.ts +2 -0
- package/lib/components/Footer.d.ts.map +1 -0
- package/lib/components/Footer.js +4 -16
- package/lib/components/Footer.js.map +1 -1
- package/lib/components/Hierarchy.d.ts +6 -0
- package/lib/components/Hierarchy.d.ts.map +1 -0
- package/lib/components/Hierarchy.js +5 -25
- package/lib/components/Hierarchy.js.map +1 -1
- package/lib/components/Icon.d.ts +6 -0
- package/lib/components/Icon.d.ts.map +1 -0
- package/lib/components/Icon.js +10 -21
- package/lib/components/Icon.js.map +1 -1
- package/lib/components/Index.d.ts +9 -0
- package/lib/components/Index.d.ts.map +1 -0
- package/lib/components/Index.js +30 -113
- package/lib/components/Index.js.map +1 -1
- package/lib/components/Markdown.d.ts +5 -0
- package/lib/components/Markdown.d.ts.map +1 -0
- package/lib/components/Markdown.js +138 -202
- package/lib/components/Markdown.js.map +1 -1
- package/lib/components/Member.d.ts +5 -0
- package/lib/components/Member.d.ts.map +1 -0
- package/lib/components/Member.js +40 -69
- package/lib/components/Member.js.map +1 -1
- package/lib/components/MemberDeclaration.d.ts +5 -0
- package/lib/components/MemberDeclaration.d.ts.map +1 -0
- package/lib/components/MemberDeclaration.js +20 -71
- package/lib/components/MemberDeclaration.js.map +1 -1
- package/lib/components/MemberGetterSetter.d.ts +8 -0
- package/lib/components/MemberGetterSetter.d.ts.map +1 -0
- package/lib/components/MemberGetterSetter.js +13 -68
- package/lib/components/MemberGetterSetter.js.map +1 -1
- package/lib/components/MemberReference.d.ts +6 -0
- package/lib/components/MemberReference.d.ts.map +1 -0
- package/lib/components/MemberReference.js +18 -48
- package/lib/components/MemberReference.js.map +1 -1
- package/lib/components/MemberSignatureBody.d.ts +9 -0
- package/lib/components/MemberSignatureBody.d.ts.map +1 -0
- package/lib/components/MemberSignatureBody.js +85 -182
- package/lib/components/MemberSignatureBody.js.map +1 -1
- package/lib/components/MemberSignatureTitle.d.ts +11 -0
- package/lib/components/MemberSignatureTitle.d.ts.map +1 -0
- package/lib/components/MemberSignatureTitle.js +27 -81
- package/lib/components/MemberSignatureTitle.js.map +1 -1
- package/lib/components/MemberSignatures.d.ts +7 -0
- package/lib/components/MemberSignatures.d.ts.map +1 -0
- package/lib/components/MemberSignatures.js +18 -66
- package/lib/components/MemberSignatures.js.map +1 -1
- package/lib/components/MemberSources.d.ts +7 -0
- package/lib/components/MemberSources.d.ts.map +1 -0
- package/lib/components/MemberSources.js +10 -34
- package/lib/components/MemberSources.js.map +1 -1
- package/lib/components/Members.d.ts +6 -0
- package/lib/components/Members.d.ts.map +1 -0
- package/lib/components/Members.js +29 -49
- package/lib/components/Members.js.map +1 -1
- package/lib/components/MembersGroup.d.ts +6 -0
- package/lib/components/MembersGroup.d.ts.map +1 -0
- package/lib/components/MembersGroup.js +16 -40
- package/lib/components/MembersGroup.js.map +1 -1
- package/lib/components/Parameter.d.ts +6 -0
- package/lib/components/Parameter.d.ts.map +1 -0
- package/lib/components/Parameter.js +35 -171
- package/lib/components/Parameter.js.map +1 -1
- package/lib/components/Reflection.d.ts +6 -0
- package/lib/components/Reflection.d.ts.map +1 -0
- package/lib/components/Reflection.js +29 -132
- package/lib/components/Reflection.js.map +1 -1
- package/lib/components/SourceLink.d.ts +10 -0
- package/lib/components/SourceLink.d.ts.map +1 -0
- package/lib/components/SourceLink.js +16 -36
- package/lib/components/SourceLink.js.map +1 -1
- package/lib/components/Type.d.ts +12 -0
- package/lib/components/Type.d.ts.map +1 -0
- package/lib/components/Type.js +142 -464
- package/lib/components/Type.js.map +1 -1
- package/lib/components/TypeAndParent.d.ts +6 -0
- package/lib/components/TypeAndParent.d.ts.map +1 -0
- package/lib/components/TypeAndParent.js +11 -27
- package/lib/components/TypeAndParent.js.map +1 -1
- package/lib/components/TypeParameters.d.ts +6 -0
- package/lib/components/TypeParameters.d.ts.map +1 -0
- package/lib/components/TypeParameters.js +10 -38
- package/lib/components/TypeParameters.js.map +1 -1
- package/lib/components/TypeParametersGeneric.d.ts +6 -0
- package/lib/components/TypeParametersGeneric.d.ts.map +1 -0
- package/lib/components/TypeParametersGeneric.js +8 -27
- package/lib/components/TypeParametersGeneric.js.map +1 -1
- package/lib/components/VersionBanner.d.ts +2 -0
- package/lib/components/VersionBanner.d.ts.map +1 -0
- package/lib/components/VersionBanner.js +18 -49
- package/lib/components/VersionBanner.js.map +1 -1
- package/lib/hooks/useBreadcrumbs.d.ts +2 -0
- package/lib/hooks/useBreadcrumbs.d.ts.map +1 -0
- package/lib/hooks/useBreadcrumbs.js +5 -8
- package/lib/hooks/useBreadcrumbs.js.map +1 -1
- package/lib/hooks/useGitRefName.d.ts +2 -0
- package/lib/hooks/useGitRefName.d.ts.map +1 -0
- package/lib/hooks/useGitRefName.js +5 -8
- package/lib/hooks/useGitRefName.js.map +1 -1
- package/lib/hooks/useMinimalLayout.d.ts +2 -0
- package/lib/hooks/useMinimalLayout.d.ts.map +1 -0
- package/lib/hooks/useMinimalLayout.js +5 -8
- package/lib/hooks/useMinimalLayout.js.map +1 -1
- package/lib/hooks/useReflection.d.ts +4 -0
- package/lib/hooks/useReflection.d.ts.map +1 -0
- package/lib/hooks/useReflection.js +15 -21
- package/lib/hooks/useReflection.js.map +1 -1
- package/lib/hooks/useReflectionMap.d.ts +3 -0
- package/lib/hooks/useReflectionMap.d.ts.map +1 -0
- package/lib/hooks/useReflectionMap.js +5 -8
- package/lib/hooks/useReflectionMap.js.map +1 -1
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +349 -361
- package/lib/index.js.map +1 -1
- package/lib/markdownLoader.d.ts +6 -0
- package/lib/markdownLoader.d.ts.map +1 -0
- package/lib/markdownLoader.js +6 -10
- package/lib/markdownLoader.js.map +1 -1
- package/lib/plugin/data.d.ts +21 -0
- package/lib/plugin/data.d.ts.map +1 -0
- package/lib/plugin/data.js +391 -429
- package/lib/plugin/data.js.map +1 -1
- package/lib/plugin/python/consts.d.ts +35 -0
- package/lib/plugin/python/consts.d.ts.map +1 -0
- package/lib/plugin/python/consts.js +44 -44
- package/lib/plugin/python/consts.js.map +1 -1
- package/lib/plugin/python/index.d.ts +12 -0
- package/lib/plugin/python/index.d.ts.map +1 -0
- package/lib/plugin/python/index.js +25 -36
- package/lib/plugin/python/index.js.map +1 -1
- package/lib/plugin/python/inheritance.d.ts +42 -0
- package/lib/plugin/python/inheritance.d.ts.map +1 -0
- package/lib/plugin/python/inheritance.js +148 -153
- package/lib/plugin/python/inheritance.js.map +1 -1
- package/lib/plugin/python/packageVersions.d.ts +7 -0
- package/lib/plugin/python/packageVersions.d.ts.map +1 -0
- package/lib/plugin/python/packageVersions.js +30 -38
- package/lib/plugin/python/packageVersions.js.map +1 -1
- package/lib/plugin/python/transformation.d.ts +90 -0
- package/lib/plugin/python/transformation.d.ts.map +1 -0
- package/lib/plugin/python/transformation.js +424 -391
- package/lib/plugin/python/transformation.js.map +1 -1
- package/lib/plugin/python/type-parsing/index.d.ts +34 -0
- package/lib/plugin/python/type-parsing/index.d.ts.map +1 -0
- package/lib/plugin/python/type-parsing/index.js +78 -85
- package/lib/plugin/python/type-parsing/index.js.map +1 -1
- package/lib/plugin/python/types.d.ts +107 -0
- package/lib/plugin/python/types.d.ts.map +1 -0
- package/lib/plugin/python/types.js +2 -2
- package/lib/plugin/python/types.js.map +1 -1
- package/lib/plugin/python/utils.d.ts +40 -0
- package/lib/plugin/python/utils.d.ts.map +1 -0
- package/lib/plugin/python/utils.js +74 -73
- package/lib/plugin/python/utils.js.map +1 -1
- package/lib/plugin/sidebar.d.ts +6 -0
- package/lib/plugin/sidebar.d.ts.map +1 -0
- package/lib/plugin/sidebar.js +94 -96
- package/lib/plugin/sidebar.js.map +1 -1
- package/lib/plugin/structure/0.23.d.ts +3 -0
- package/lib/plugin/structure/0.23.d.ts.map +1 -0
- package/lib/plugin/structure/0.23.js +33 -41
- package/lib/plugin/structure/0.23.js.map +1 -1
- package/lib/plugin/url.d.ts +6 -0
- package/lib/plugin/url.d.ts.map +1 -0
- package/lib/plugin/url.js +36 -46
- package/lib/plugin/url.js.map +1 -1
- package/lib/plugin/version.d.ts +5 -0
- package/lib/plugin/version.d.ts.map +1 -0
- package/lib/plugin/version.js +73 -78
- package/lib/plugin/version.js.map +1 -1
- package/lib/types.d.ts +142 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +2 -2
- package/lib/types.js.map +1 -1
- package/lib/utils/helpers.d.ts +2 -0
- package/lib/utils/helpers.d.ts.map +1 -0
- package/lib/utils/helpers.js +5 -7
- package/lib/utils/helpers.js.map +1 -1
- package/lib/utils/hierarchy.d.ts +8 -0
- package/lib/utils/hierarchy.d.ts.map +1 -0
- package/lib/utils/hierarchy.js +31 -33
- package/lib/utils/hierarchy.js.map +1 -1
- package/lib/utils/icons.d.ts +5 -0
- package/lib/utils/icons.d.ts.map +1 -0
- package/lib/utils/icons.js +82 -114
- package/lib/utils/icons.js.map +1 -1
- package/lib/utils/links.d.ts +2 -0
- package/lib/utils/links.d.ts.map +1 -0
- package/lib/utils/links.js +24 -41
- package/lib/utils/links.js.map +1 -1
- package/lib/utils/markdown.d.ts +4 -0
- package/lib/utils/markdown.d.ts.map +1 -0
- package/lib/utils/markdown.js +45 -54
- package/lib/utils/markdown.js.map +1 -1
- package/lib/utils/reexports.d.ts +5 -0
- package/lib/utils/reexports.d.ts.map +1 -0
- package/lib/utils/reexports.js +90 -90
- package/lib/utils/reexports.js.map +1 -1
- package/lib/utils/removeScopes.d.ts +2 -0
- package/lib/utils/removeScopes.d.ts.map +1 -0
- package/lib/utils/removeScopes.js +7 -0
- package/lib/utils/removeScopes.js.map +1 -0
- package/lib/utils/visibility.d.ts +6 -0
- package/lib/utils/visibility.d.ts.map +1 -0
- package/lib/utils/visibility.js +14 -19
- package/lib/utils/visibility.js.map +1 -1
- package/package.json +29 -17
- package/python-scripts/docspec-gen/google_docstring_processor.py +54 -20
- package/src/components/ApiIndex.tsx +1 -1
- package/src/index.ts +2 -2
- package/src/plugin/data.ts +3 -3
- package/src/plugin/python/index.ts +3 -3
- package/src/plugin/python/packageVersions.ts +3 -3
- package/src/plugin/python/transformation.ts +89 -15
- package/src/plugin/python/types.ts +3 -4
- package/src/plugin/sidebar.ts +1 -1
- package/src/plugin/url.ts +1 -1
- package/src/plugin/version.ts +1 -1
- package/src/utils/links.ts +1 -12
- package/src/utils/removeScopes.ts +10 -0
- /package/{assets/styles-8ad572ec.css → lib/components/styles.css} +0 -0
|
@@ -1,414 +1,447 @@
|
|
|
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
|
-
const consts = require('./consts.js');
|
|
9
|
-
const inheritance = require('./inheritance.js');
|
|
10
|
-
const index = require('./type-parsing/index.js');
|
|
11
|
-
const utils = require('./utils.js');
|
|
12
|
-
|
|
13
1
|
/* eslint-disable max-classes-per-file */
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
getNewId() {
|
|
24
|
-
return this.oidGenerator.next().value;
|
|
25
|
-
}
|
|
26
|
-
addNewReference(object) {
|
|
27
|
-
if (object.sources?.[0]?.fileName) {
|
|
28
|
-
this.symbolIdMap[object.id] = {
|
|
29
|
-
qualifiedName: object.name,
|
|
30
|
-
sourceFileName: object.sources?.[0]?.fileName
|
|
31
|
-
};
|
|
2
|
+
import { REPO_ROOT_PLACEHOLDER, TYPEDOC_KINDS } from './consts';
|
|
3
|
+
import { InheritanceGraph } from './inheritance';
|
|
4
|
+
import { PythonTypeResolver } from './type-parsing';
|
|
5
|
+
import { getGroupName, isHidden, isOverload, projectUsesDocsGroupDecorator, sortChildren } from './utils';
|
|
6
|
+
export class SymbolIdTracker {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.symbolIdMap = {};
|
|
9
|
+
this.idToReference = {};
|
|
10
|
+
this.oidGenerator = this.generateOID();
|
|
32
11
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
getIdByName(name) {
|
|
41
|
-
return Object.entries(this.symbolIdMap).find(([, {
|
|
42
|
-
qualifiedName
|
|
43
|
-
}]) => qualifiedName === name)?.[0];
|
|
44
|
-
}
|
|
45
|
-
getTypeDocById(id) {
|
|
46
|
-
return this.idToReference[id];
|
|
47
|
-
}
|
|
48
|
-
*generateOID() {
|
|
49
|
-
let id = 1;
|
|
50
|
-
while (true) {
|
|
51
|
-
yield id++;
|
|
12
|
+
/**
|
|
13
|
+
* Returns automatically incrementing OID. Every call to this function will return a new unique OID.
|
|
14
|
+
* @returns {number} The OID.
|
|
15
|
+
*/
|
|
16
|
+
getNewId() {
|
|
17
|
+
return this.oidGenerator.next().value;
|
|
52
18
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
moduleShortcuts;
|
|
61
|
-
gitRevision;
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Stack of the docstrings of the current context.
|
|
65
|
-
*
|
|
66
|
-
* Used to read the class Google-style docstrings from the class' properties and methods.
|
|
67
|
-
*/
|
|
68
|
-
contextStack = [];
|
|
69
|
-
settings = {
|
|
70
|
-
useDocsGroup: false
|
|
71
|
-
};
|
|
72
|
-
constructor({
|
|
73
|
-
moduleShortcuts,
|
|
74
|
-
gitRevision
|
|
75
|
-
}) {
|
|
76
|
-
this.pythonTypeResolver = new index.PythonTypeResolver();
|
|
77
|
-
this.symbolIdTracker = new SymbolIdTracker();
|
|
78
|
-
this.inheritanceGraph = new inheritance.InheritanceGraph(this.symbolIdTracker);
|
|
79
|
-
this.moduleShortcuts = moduleShortcuts ?? {};
|
|
80
|
-
this.gitRevision = gitRevision;
|
|
81
|
-
}
|
|
82
|
-
transform(docspecModules) {
|
|
83
|
-
// Root object of the Typedoc structure, accumulator for the recursive walk
|
|
84
|
-
const typedocApiReference = {
|
|
85
|
-
children: [],
|
|
86
|
-
flags: {},
|
|
87
|
-
groups: [],
|
|
88
|
-
id: 0,
|
|
89
|
-
kind: 1,
|
|
90
|
-
kindString: 'Project',
|
|
91
|
-
name: 'apify-client',
|
|
92
|
-
sources: [{
|
|
93
|
-
character: 0,
|
|
94
|
-
fileName: 'src/index.ts',
|
|
95
|
-
line: 1
|
|
96
|
-
}],
|
|
97
|
-
symbolIdMap: this.symbolIdTracker.symbolIdMap
|
|
98
|
-
};
|
|
99
|
-
this.settings.useDocsGroup = utils.projectUsesDocsGroupDecorator(docspecModules);
|
|
100
|
-
|
|
101
|
-
// Convert all the modules, store them in the root object
|
|
102
|
-
for (const module of docspecModules) {
|
|
103
|
-
this.walkAndTransform({
|
|
104
|
-
currentDocspecNode: module,
|
|
105
|
-
moduleName: module.name,
|
|
106
|
-
parentTypeDoc: typedocApiReference
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
this.inheritanceGraph.resolveInheritance();
|
|
110
|
-
this.pythonTypeResolver.resolveTypes();
|
|
111
|
-
this.fixRefs(typedocApiReference);
|
|
112
|
-
utils.sortChildren(typedocApiReference);
|
|
113
|
-
this.unpackKwargs();
|
|
114
|
-
return typedocApiReference;
|
|
115
|
-
}
|
|
116
|
-
getContext() {
|
|
117
|
-
return this.contextStack[this.contextStack.length - 1];
|
|
118
|
-
}
|
|
119
|
-
popContext() {
|
|
120
|
-
this.contextStack.pop();
|
|
121
|
-
}
|
|
122
|
-
newContext(context) {
|
|
123
|
-
this.contextStack.push(context);
|
|
124
|
-
}
|
|
125
|
-
unpackKwargs() {
|
|
126
|
-
const signatures = this.symbolIdTracker.getMethodSignatures();
|
|
127
|
-
for (const sig of signatures) {
|
|
128
|
-
const unpackedParams = [];
|
|
129
|
-
for (const param of sig.parameters ?? []) {
|
|
130
|
-
if (param.type.type !== 'reference' || param.type?.name !== 'Unpack') {
|
|
131
|
-
unpackedParams.push(param);
|
|
132
|
-
// eslint-disable-next-line no-continue
|
|
133
|
-
continue;
|
|
19
|
+
addNewReference(object) {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
|
+
if ((_b = (_a = object.sources) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.fileName) {
|
|
22
|
+
this.symbolIdMap[object.id] = {
|
|
23
|
+
qualifiedName: object.name,
|
|
24
|
+
sourceFileName: (_d = (_c = object.sources) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.fileName,
|
|
25
|
+
};
|
|
134
26
|
}
|
|
135
|
-
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
137
|
-
param.type.typeArguments[0]?.target
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-argument
|
|
139
|
-
?? this.symbolIdTracker.getIdByName(param.type.typeArguments[0]?.name));
|
|
140
|
-
unpackedParams.push(...(typedDict?.children.map(x => _objectSpread(_objectSpread({}, x), {}, {
|
|
141
|
-
flags: {
|
|
142
|
-
'keyword-only': true,
|
|
143
|
-
optional: true
|
|
144
|
-
}
|
|
145
|
-
})) ?? []));
|
|
146
|
-
}
|
|
147
|
-
sig.parameters = unpackedParams;
|
|
27
|
+
this.idToReference[object.id] = object;
|
|
148
28
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Recursively traverse the Typedoc structure and fix the references to the named entities.
|
|
153
|
-
*
|
|
154
|
-
* Searches for the {@link TypeDocType} structure with the `type` property set to `reference`, and replaces the `target` property
|
|
155
|
-
* with the corresponding ID of the named entity.
|
|
156
|
-
*/
|
|
157
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
158
|
-
fixRefs(obj) {
|
|
159
|
-
for (const key of Object.keys(obj)) {
|
|
160
|
-
if (key === 'name' && obj?.type === 'reference' && this.symbolIdTracker.getIdByName(obj?.name ?? '')) {
|
|
161
|
-
obj.target = this.symbolIdTracker.getIdByName(obj?.name ?? '');
|
|
162
|
-
}
|
|
163
|
-
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
164
|
-
this.fixRefs(obj[key]);
|
|
165
|
-
}
|
|
29
|
+
getMethodSignatures() {
|
|
30
|
+
return Object.values(this.idToReference).filter(({ kindString }) => kindString === 'Call signature');
|
|
166
31
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
comment: docstring.text ? {
|
|
171
|
-
blockTags: docstring?.returns ? [{
|
|
172
|
-
content: [{
|
|
173
|
-
kind: 'text',
|
|
174
|
-
text: docstring.returns
|
|
175
|
-
}],
|
|
176
|
-
tag: '@returns'
|
|
177
|
-
}] : undefined,
|
|
178
|
-
summary: [{
|
|
179
|
-
kind: 'text',
|
|
180
|
-
text: docstring?.text
|
|
181
|
-
}]
|
|
182
|
-
} : undefined,
|
|
183
|
-
flags: {},
|
|
184
|
-
id: this.symbolIdTracker.getNewId(),
|
|
185
|
-
kind: 4096,
|
|
186
|
-
kindString: 'Call signature',
|
|
187
|
-
modifiers: docspecObject.modifiers ?? [],
|
|
188
|
-
name: docspecObject.name,
|
|
189
|
-
parameters: docspecObject.args?.filter(arg => arg.name !== 'self' && arg.name !== 'cls').map(arg => {
|
|
190
|
-
const paramTypeDoc = {
|
|
191
|
-
comment: docstring.args?.[arg.name] ? {
|
|
192
|
-
summary: [{
|
|
193
|
-
kind: 'text',
|
|
194
|
-
text: docstring.args[arg.name]
|
|
195
|
-
}]
|
|
196
|
-
} : undefined,
|
|
197
|
-
defaultValue: arg.default_value,
|
|
198
|
-
flags: {
|
|
199
|
-
isOptional: arg.datatype?.includes('Optional') || arg.default_value !== undefined,
|
|
200
|
-
'keyword-only': arg.type === 'KEYWORD_ONLY'
|
|
201
|
-
},
|
|
202
|
-
id: this.symbolIdTracker.getNewId(),
|
|
203
|
-
kind: 32_768,
|
|
204
|
-
kindString: 'Parameter',
|
|
205
|
-
name: arg.name,
|
|
206
|
-
type: this.pythonTypeResolver.registerType(arg.datatype)
|
|
207
|
-
};
|
|
208
|
-
this.symbolIdTracker.addNewReference(paramTypeDoc);
|
|
209
|
-
return paramTypeDoc;
|
|
210
|
-
}),
|
|
211
|
-
type: this.pythonTypeResolver.registerType(docspecObject.return_type)
|
|
212
|
-
};
|
|
213
|
-
this.symbolIdTracker.addNewReference(methodTypeDoc);
|
|
214
|
-
return methodTypeDoc;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* Given a docspec object outputted by `pydoc-markdown`, transforms this object into the Typedoc structure,
|
|
219
|
-
* and appends it as a child of the `parentTypeDoc` Typedoc object (which serves as an accumulator for the recursion).
|
|
220
|
-
* @param obj
|
|
221
|
-
* @param parent
|
|
222
|
-
* @param module
|
|
223
|
-
*/
|
|
224
|
-
walkAndTransform({
|
|
225
|
-
currentDocspecNode,
|
|
226
|
-
parentTypeDoc,
|
|
227
|
-
moduleName
|
|
228
|
-
}) {
|
|
229
|
-
if (currentDocspecNode?.datatype === 'TypeAlias') {
|
|
230
|
-
this.pythonTypeResolver.registerType(currentDocspecNode.value, currentDocspecNode.name);
|
|
32
|
+
getIdByName(name) {
|
|
33
|
+
var _a;
|
|
34
|
+
return (_a = Object.entries(this.symbolIdMap).find(([, { qualifiedName }]) => qualifiedName === name)) === null || _a === void 0 ? void 0 : _a[0];
|
|
231
35
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
this.walkAndTransform({
|
|
235
|
-
currentDocspecNode: docspecMember,
|
|
236
|
-
moduleName,
|
|
237
|
-
// Skips the hidden member, i.e. its children will be appended to the parent of the hidden member
|
|
238
|
-
parentTypeDoc
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
return;
|
|
36
|
+
getTypeDocById(id) {
|
|
37
|
+
return this.idToReference[id];
|
|
242
38
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
currentDocspecNode.parsedDocstring = this.parseDocstring(currentDocspecNode);
|
|
249
|
-
const isOverloadedMethod = typedocKind.kindString === 'Method' && utils.isOverload(currentDocspecNode);
|
|
250
|
-
if (isOverloadedMethod) {
|
|
251
|
-
parentTypeDoc.overloads ??= [];
|
|
252
|
-
parentTypeDoc.overloads.push(currentDocspecNode);
|
|
253
|
-
return;
|
|
39
|
+
*generateOID() {
|
|
40
|
+
let id = 1;
|
|
41
|
+
while (true) {
|
|
42
|
+
yield id++;
|
|
43
|
+
}
|
|
254
44
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
45
|
+
}
|
|
46
|
+
;
|
|
47
|
+
export class DocspecTransformer {
|
|
48
|
+
constructor({ moduleShortcuts, gitRevision }) {
|
|
49
|
+
/**
|
|
50
|
+
* Stack of the docstrings of the current context.
|
|
51
|
+
*
|
|
52
|
+
* Used to read the class Google-style docstrings from the class' properties and methods.
|
|
53
|
+
*/
|
|
54
|
+
this.contextStack = [];
|
|
55
|
+
this.settings = { useDocsGroup: false };
|
|
56
|
+
this.pythonTypeResolver = new PythonTypeResolver();
|
|
57
|
+
this.symbolIdTracker = new SymbolIdTracker();
|
|
58
|
+
this.inheritanceGraph = new InheritanceGraph(this.symbolIdTracker);
|
|
59
|
+
this.moduleShortcuts = moduleShortcuts !== null && moduleShortcuts !== void 0 ? moduleShortcuts : {};
|
|
60
|
+
this.gitRevision = gitRevision;
|
|
261
61
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
62
|
+
transform(docspecModules) {
|
|
63
|
+
// Root object of the Typedoc structure, accumulator for the recursive walk
|
|
64
|
+
const typedocApiReference = {
|
|
65
|
+
children: [],
|
|
66
|
+
flags: {},
|
|
67
|
+
groups: [],
|
|
68
|
+
id: 0,
|
|
69
|
+
kind: 1,
|
|
70
|
+
kindString: 'Project',
|
|
71
|
+
name: 'apify-client',
|
|
72
|
+
sources: [
|
|
73
|
+
{
|
|
74
|
+
character: 0,
|
|
75
|
+
fileName: 'src/index.ts',
|
|
76
|
+
line: 1,
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
symbolIdMap: this.symbolIdTracker.symbolIdMap,
|
|
80
|
+
};
|
|
81
|
+
this.settings.useDocsGroup = projectUsesDocsGroupDecorator(docspecModules);
|
|
82
|
+
// Convert all the modules, store them in the root object
|
|
83
|
+
for (const module of docspecModules) {
|
|
84
|
+
this.walkAndTransform({
|
|
85
|
+
currentDocspecNode: module,
|
|
86
|
+
moduleName: module.name,
|
|
87
|
+
parentTypeDoc: typedocApiReference,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
this.inheritanceGraph.resolveInheritance();
|
|
91
|
+
this.pythonTypeResolver.resolveTypes();
|
|
92
|
+
this.fixRefs(typedocApiReference);
|
|
93
|
+
sortChildren(typedocApiReference);
|
|
94
|
+
this.unpackKwargs();
|
|
95
|
+
return typedocApiReference;
|
|
96
|
+
}
|
|
97
|
+
getContext() {
|
|
98
|
+
return this.contextStack[this.contextStack.length - 1];
|
|
298
99
|
}
|
|
299
|
-
|
|
300
|
-
|
|
100
|
+
popContext() {
|
|
101
|
+
this.contextStack.pop();
|
|
301
102
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
currentDocspecNode: docspecMember,
|
|
305
|
-
moduleName,
|
|
306
|
-
parentTypeDoc: currentTypedocNode
|
|
307
|
-
});
|
|
103
|
+
newContext(context) {
|
|
104
|
+
this.contextStack.push(context);
|
|
308
105
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
for (const
|
|
313
|
-
|
|
314
|
-
|
|
106
|
+
unpackKwargs() {
|
|
107
|
+
var _a, _b, _c, _d, _e, _f;
|
|
108
|
+
const signatures = this.symbolIdTracker.getMethodSignatures();
|
|
109
|
+
for (const sig of signatures) {
|
|
110
|
+
const unpackedParams = [];
|
|
111
|
+
for (const param of (_a = sig.parameters) !== null && _a !== void 0 ? _a : []) {
|
|
112
|
+
if (param.type.type !== 'reference' || ((_b = param.type) === null || _b === void 0 ? void 0 : _b.name) !== 'Unpack') {
|
|
113
|
+
unpackedParams.push(param);
|
|
114
|
+
// eslint-disable-next-line no-continue
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const typedDict = this.symbolIdTracker.getTypeDocById((
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
119
|
+
(_d = (_c = param.type.typeArguments[0]) === null || _c === void 0 ? void 0 : _c.target) !== null && _d !== void 0 ? _d : this.symbolIdTracker.getIdByName((_e = param.type.typeArguments[0]) === null || _e === void 0 ? void 0 : _e.name)));
|
|
120
|
+
unpackedParams.push(...((_f = typedDict === null || typedDict === void 0 ? void 0 : typedDict.children.map((x) => (Object.assign(Object.assign({}, x), { flags: { 'keyword-only': true, optional: true } })))) !== null && _f !== void 0 ? _f : []));
|
|
121
|
+
}
|
|
122
|
+
sig.parameters = unpackedParams;
|
|
315
123
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Recursively traverse the Typedoc structure and fix the references to the named entities.
|
|
127
|
+
*
|
|
128
|
+
* Searches for the {@link TypeDocType} structure with the `type` property set to `reference`, and replaces the `target` property
|
|
129
|
+
* with the corresponding ID of the named entity.
|
|
130
|
+
*/
|
|
131
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
132
|
+
fixRefs(obj) {
|
|
133
|
+
var _a, _b;
|
|
134
|
+
for (const key of Object.keys(obj)) {
|
|
135
|
+
if (key === 'name' && (obj === null || obj === void 0 ? void 0 : obj.type) === 'reference' && this.symbolIdTracker.getIdByName((_a = obj === null || obj === void 0 ? void 0 : obj.name) !== null && _a !== void 0 ? _a : '')) {
|
|
136
|
+
obj.target = this.symbolIdTracker.getIdByName((_b = obj === null || obj === void 0 ? void 0 : obj.name) !== null && _b !== void 0 ? _b : '');
|
|
137
|
+
}
|
|
138
|
+
if (typeof obj[key] === 'object' && obj[key] !== null) {
|
|
139
|
+
this.fixRefs(obj[key]);
|
|
140
|
+
}
|
|
323
141
|
}
|
|
324
|
-
}
|
|
325
|
-
currentTypedocNode.overloads = undefined;
|
|
326
|
-
this.inheritanceGraph.registerNode(currentTypedocNode);
|
|
327
142
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
143
|
+
makeMethodSignature(docspecObject, docstring) {
|
|
144
|
+
var _a, _b;
|
|
145
|
+
const methodTypeDoc = {
|
|
146
|
+
comment: docstring.text
|
|
147
|
+
? {
|
|
148
|
+
blockTags: (docstring === null || docstring === void 0 ? void 0 : docstring.returns)
|
|
149
|
+
? [{ content: [{ kind: 'text', text: docstring.returns }], tag: '@returns' }]
|
|
150
|
+
: undefined,
|
|
151
|
+
summary: [
|
|
152
|
+
{
|
|
153
|
+
kind: 'text',
|
|
154
|
+
text: docstring === null || docstring === void 0 ? void 0 : docstring.text,
|
|
155
|
+
},
|
|
156
|
+
],
|
|
157
|
+
}
|
|
158
|
+
: undefined,
|
|
159
|
+
flags: {},
|
|
160
|
+
id: this.symbolIdTracker.getNewId(),
|
|
161
|
+
kind: 4096,
|
|
162
|
+
kindString: 'Call signature',
|
|
163
|
+
modifiers: (_a = docspecObject.modifiers) !== null && _a !== void 0 ? _a : [],
|
|
164
|
+
name: docspecObject.name,
|
|
165
|
+
parameters: (_b = docspecObject.args) === null || _b === void 0 ? void 0 : _b.filter((arg) => arg.name !== 'self' && arg.name !== 'cls').map((arg) => {
|
|
166
|
+
var _a, _b;
|
|
167
|
+
const paramTypeDoc = {
|
|
168
|
+
comment: ((_a = docstring.args) === null || _a === void 0 ? void 0 : _a[arg.name])
|
|
169
|
+
? {
|
|
170
|
+
summary: [
|
|
171
|
+
{
|
|
172
|
+
kind: 'text',
|
|
173
|
+
text: docstring.args[arg.name],
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
}
|
|
177
|
+
: undefined,
|
|
178
|
+
defaultValue: arg.default_value,
|
|
179
|
+
flags: {
|
|
180
|
+
isOptional: ((_b = arg.datatype) === null || _b === void 0 ? void 0 : _b.includes('Optional')) || arg.default_value !== undefined,
|
|
181
|
+
'keyword-only': arg.type === 'KEYWORD_ONLY',
|
|
182
|
+
},
|
|
183
|
+
id: this.symbolIdTracker.getNewId(),
|
|
184
|
+
kind: 32768,
|
|
185
|
+
kindString: 'Parameter',
|
|
186
|
+
name: arg.name,
|
|
187
|
+
type: this.pythonTypeResolver.registerType(arg.datatype),
|
|
188
|
+
};
|
|
189
|
+
this.symbolIdTracker.addNewReference(paramTypeDoc);
|
|
190
|
+
return paramTypeDoc;
|
|
191
|
+
}),
|
|
192
|
+
type: this.pythonTypeResolver.registerType(docspecObject.return_type),
|
|
193
|
+
};
|
|
194
|
+
this.symbolIdTracker.addNewReference(methodTypeDoc);
|
|
195
|
+
return methodTypeDoc;
|
|
343
196
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
197
|
+
/**
|
|
198
|
+
* Given a docspec object outputted by `pydoc-markdown`, transforms this object into the Typedoc structure,
|
|
199
|
+
* and appends it as a child of the `parentTypeDoc` Typedoc object (which serves as an accumulator for the recursion).
|
|
200
|
+
* @param obj
|
|
201
|
+
* @param parent
|
|
202
|
+
* @param module
|
|
203
|
+
*/
|
|
204
|
+
walkAndTransform({ currentDocspecNode, parentTypeDoc, moduleName, }) {
|
|
205
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
206
|
+
if ((currentDocspecNode === null || currentDocspecNode === void 0 ? void 0 : currentDocspecNode.datatype) === 'TypeAlias') {
|
|
207
|
+
this.pythonTypeResolver.registerType(currentDocspecNode.value, currentDocspecNode.name);
|
|
208
|
+
}
|
|
209
|
+
if (isHidden(currentDocspecNode)) {
|
|
210
|
+
for (const docspecMember of (_a = currentDocspecNode.members) !== null && _a !== void 0 ? _a : []) {
|
|
211
|
+
this.walkAndTransform({
|
|
212
|
+
currentDocspecNode: docspecMember,
|
|
213
|
+
moduleName,
|
|
214
|
+
// Skips the hidden member, i.e. its children will be appended to the parent of the hidden member
|
|
215
|
+
parentTypeDoc,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const { typedocType, typedocKind } = this.getTypedocType(currentDocspecNode, parentTypeDoc);
|
|
221
|
+
const { filePathInRepo } = this.getGitHubUrls(currentDocspecNode);
|
|
222
|
+
currentDocspecNode.parsedDocstring = this.parseDocstring(currentDocspecNode);
|
|
223
|
+
const isOverloadedMethod = typedocKind.kindString === 'Method' && isOverload(currentDocspecNode);
|
|
224
|
+
if (isOverloadedMethod) {
|
|
225
|
+
(_b = parentTypeDoc.overloads) !== null && _b !== void 0 ? _b : (parentTypeDoc.overloads = []);
|
|
226
|
+
parentTypeDoc.overloads.push(currentDocspecNode);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
const currentId = this.symbolIdTracker.getNewId();
|
|
230
|
+
// Get the module name of the member, and check if it has a shortcut (reexport from an ancestor module)
|
|
231
|
+
const fullName = `${moduleName}.${currentDocspecNode.name}`;
|
|
232
|
+
if (fullName in this.moduleShortcuts) {
|
|
233
|
+
moduleName = this.moduleShortcuts[fullName].replace(`.${currentDocspecNode.name}`, '');
|
|
234
|
+
}
|
|
235
|
+
currentDocspecNode.name =
|
|
236
|
+
(_e = (_d = (_c = currentDocspecNode.decorations) === null || _c === void 0 ? void 0 : _c.find((d) => d.name === 'docs_name')) === null || _d === void 0 ? void 0 : _d.args.slice(2, -2)) !== null && _e !== void 0 ? _e : currentDocspecNode.name;
|
|
237
|
+
// Create the Typedoc member object
|
|
238
|
+
const currentTypedocNode = Object.assign(Object.assign({}, typedocKind), { children: [], comment: currentDocspecNode.parsedDocstring
|
|
239
|
+
? {
|
|
240
|
+
summary: [
|
|
241
|
+
{
|
|
242
|
+
kind: 'text',
|
|
243
|
+
text: currentDocspecNode.parsedDocstring.text,
|
|
244
|
+
},
|
|
245
|
+
],
|
|
246
|
+
}
|
|
247
|
+
: undefined, decorations: (_f = currentDocspecNode.decorations) === null || _f === void 0 ? void 0 : _f.map(({ name, args }) => ({ args, name })), flags: {}, groups: [], id: currentId, module: moduleName, name: currentDocspecNode.name, parsedDocstring: currentDocspecNode.parsedDocstring, sources: [
|
|
248
|
+
{
|
|
249
|
+
character: 1,
|
|
250
|
+
fileName: filePathInRepo,
|
|
251
|
+
gitRevision: this.gitRevision,
|
|
252
|
+
line: currentDocspecNode.location.lineno,
|
|
253
|
+
},
|
|
254
|
+
], type: typedocType });
|
|
255
|
+
this.symbolIdTracker.addNewReference(currentTypedocNode);
|
|
256
|
+
if (currentTypedocNode.kindString === 'Method') {
|
|
257
|
+
currentTypedocNode.signatures = [
|
|
258
|
+
this.makeMethodSignature(currentDocspecNode, currentDocspecNode.parsedDocstring),
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
if (currentTypedocNode.kindString === 'Class') {
|
|
262
|
+
this.newContext(currentDocspecNode.parsedDocstring);
|
|
263
|
+
}
|
|
264
|
+
for (const docspecMember of (_g = currentDocspecNode.members) !== null && _g !== void 0 ? _g : []) {
|
|
265
|
+
this.walkAndTransform({
|
|
266
|
+
currentDocspecNode: docspecMember,
|
|
267
|
+
moduleName,
|
|
268
|
+
parentTypeDoc: currentTypedocNode,
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
if (currentTypedocNode.kindString === 'Class') {
|
|
272
|
+
this.popContext();
|
|
273
|
+
if (currentDocspecNode.bases && currentDocspecNode.bases.length > 0) {
|
|
274
|
+
for (const base of currentDocspecNode.bases) {
|
|
275
|
+
const canonicalAncestorType = this.pythonTypeResolver.getBaseType(base);
|
|
276
|
+
this.inheritanceGraph.addRelationship(canonicalAncestorType, currentTypedocNode);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
for (const overload of (_h = currentTypedocNode.overloads) !== null && _h !== void 0 ? _h : []) {
|
|
280
|
+
const baseMethod = (_j = currentTypedocNode.children) === null || _j === void 0 ? void 0 : _j.find((child) => child.name === overload.name && child.kindString === 'Method' && child.decorations.every((d) => d.name !== 'overload'));
|
|
281
|
+
if (baseMethod) {
|
|
282
|
+
(_k = baseMethod.signatures) === null || _k === void 0 ? void 0 : _k.push(this.makeMethodSignature(overload, overload.parsedDocstring.text.length > 0 ?
|
|
283
|
+
overload.parsedDocstring :
|
|
284
|
+
baseMethod.parsedDocstring));
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
console.warn(`Method ${overload.name} not found in class ${currentTypedocNode.name} (but overload ${overload.name} exists).`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
currentTypedocNode.overloads = undefined;
|
|
291
|
+
this.inheritanceGraph.registerNode(currentTypedocNode);
|
|
292
|
+
}
|
|
293
|
+
const { groupName, source: groupSource } = getGroupName(currentTypedocNode);
|
|
294
|
+
if (groupName && // If the group comes from a decorator, use it always; otherwise check if the symbol isn't top-level
|
|
295
|
+
(!this.settings.useDocsGroup ||
|
|
296
|
+
groupSource === 'decorator' ||
|
|
297
|
+
parentTypeDoc.kindString !== 'Project')
|
|
298
|
+
&& !isOverloadedMethod) {
|
|
299
|
+
const group = (_l = parentTypeDoc.groups) === null || _l === void 0 ? void 0 : _l.find((g) => g.title === groupName);
|
|
300
|
+
if (group) {
|
|
301
|
+
group.children.push(currentTypedocNode.id);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
(_m = parentTypeDoc.groups) === null || _m === void 0 ? void 0 : _m.push({
|
|
305
|
+
children: [currentTypedocNode.id],
|
|
306
|
+
title: groupName,
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
(_o = parentTypeDoc.children) === null || _o === void 0 ? void 0 : _o.push(currentTypedocNode);
|
|
311
|
+
sortChildren(currentTypedocNode);
|
|
379
312
|
}
|
|
380
|
-
|
|
381
|
-
|
|
313
|
+
// Get the URL of the member in GitHub
|
|
314
|
+
getGitHubUrls(docspecMember) {
|
|
315
|
+
const filePathInRepo = docspecMember.location.filename.replace(REPO_ROOT_PLACEHOLDER, '');
|
|
316
|
+
return { filePathInRepo };
|
|
382
317
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
318
|
+
/**
|
|
319
|
+
* Converts a docstring section to Docusaurus admonition markdown format.
|
|
320
|
+
*/
|
|
321
|
+
sectionToAdmonition(sectionName, content) {
|
|
322
|
+
const admonitionType = DocspecTransformer.SECTION_TO_ADMONITION[sectionName];
|
|
323
|
+
if (!admonitionType) {
|
|
324
|
+
return '';
|
|
325
|
+
}
|
|
326
|
+
const contentText = content
|
|
327
|
+
.map((item) => {
|
|
328
|
+
if (typeof item === 'string') {
|
|
329
|
+
return item;
|
|
330
|
+
}
|
|
331
|
+
if (typeof item === 'object' && item !== null && 'desc' in item) {
|
|
332
|
+
const obj = item;
|
|
333
|
+
return obj.param ? `**${obj.param}**: ${obj.desc}` : obj.desc;
|
|
334
|
+
}
|
|
335
|
+
return '';
|
|
336
|
+
})
|
|
337
|
+
.filter(Boolean)
|
|
338
|
+
.join('\n');
|
|
339
|
+
if (!contentText) {
|
|
340
|
+
return '';
|
|
341
|
+
}
|
|
342
|
+
return `:::${admonitionType} ${sectionName}\n${contentText}\n:::`;
|
|
393
343
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
344
|
+
/**
|
|
345
|
+
* If possible, parses the `.docstring` property of the passed object. If the docstring is a stringified JSON object,
|
|
346
|
+
* it extracts the `args` and `returns` sections and adds them to the returned object.
|
|
347
|
+
*
|
|
348
|
+
* The docstring format is a JSON object with a `content` array that contains interleaved text strings
|
|
349
|
+
* and section objects, preserving the original order from the docstring.
|
|
350
|
+
*/
|
|
351
|
+
parseDocstring(docspecMember) {
|
|
352
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
353
|
+
const docstring = { text: (_b = (_a = docspecMember.docstring) === null || _a === void 0 ? void 0 : _a.content) !== null && _b !== void 0 ? _b : '' };
|
|
354
|
+
try {
|
|
355
|
+
const parsedDocstring = JSON.parse(docstring.text);
|
|
356
|
+
// Build the text output by processing content items in order
|
|
357
|
+
const textParts = [];
|
|
358
|
+
for (const item of (_c = parsedDocstring.content) !== null && _c !== void 0 ? _c : []) {
|
|
359
|
+
if (typeof item === 'string') {
|
|
360
|
+
// Regular text content
|
|
361
|
+
textParts.push(item);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
// Section object
|
|
365
|
+
const sectionName = Object.keys(item)[0];
|
|
366
|
+
const sectionContent = item[sectionName];
|
|
367
|
+
if (sectionName === 'Arguments') {
|
|
368
|
+
// Extract arguments for parameter documentation
|
|
369
|
+
const parsedArguments = sectionContent;
|
|
370
|
+
docstring.args =
|
|
371
|
+
(_d = parsedArguments === null || parsedArguments === void 0 ? void 0 : parsedArguments.reduce((acc, arg) => {
|
|
372
|
+
acc[arg.param] = arg.desc;
|
|
373
|
+
return acc;
|
|
374
|
+
}, {})) !== null && _d !== void 0 ? _d : {};
|
|
375
|
+
}
|
|
376
|
+
else if (sectionName === 'Returns') {
|
|
377
|
+
// Extract return type documentation
|
|
378
|
+
docstring.returns = sectionContent
|
|
379
|
+
.map((returnsItem) => {
|
|
380
|
+
if (typeof returnsItem === 'string') {
|
|
381
|
+
return returnsItem;
|
|
382
|
+
}
|
|
383
|
+
if (typeof returnsItem === 'object' && returnsItem !== null && 'param' in returnsItem && 'desc' in returnsItem) {
|
|
384
|
+
const obj = returnsItem;
|
|
385
|
+
return `${obj.param}: ${obj.desc}`;
|
|
386
|
+
}
|
|
387
|
+
return '';
|
|
388
|
+
})
|
|
389
|
+
.filter(Boolean)
|
|
390
|
+
.join('\n');
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
// Convert other sections to admonitions inline
|
|
394
|
+
const admonition = this.sectionToAdmonition(sectionName, sectionContent);
|
|
395
|
+
if (admonition) {
|
|
396
|
+
textParts.push(admonition);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
docstring.text = textParts.join('\n\n');
|
|
402
|
+
}
|
|
403
|
+
catch (_h) {
|
|
404
|
+
// Do nothing
|
|
405
|
+
}
|
|
406
|
+
if (!docstring.text) {
|
|
407
|
+
docstring.text = (_g = (_f = (_e = this.getContext()) === null || _e === void 0 ? void 0 : _e.args) === null || _f === void 0 ? void 0 : _f[docspecMember.name]) !== null && _g !== void 0 ? _g : '';
|
|
408
|
+
}
|
|
409
|
+
return docstring;
|
|
398
410
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
411
|
+
/**
|
|
412
|
+
* Given the current Docspec object and the parent Typedoc object, returns the Typedoc type and kind of the current object.
|
|
413
|
+
*/
|
|
414
|
+
getTypedocType(docspecMember, parentTypeDoc) {
|
|
415
|
+
var _a, _b, _c;
|
|
416
|
+
let typedocKind = TYPEDOC_KINDS[docspecMember.type];
|
|
417
|
+
if ((_a = docspecMember.bases) === null || _a === void 0 ? void 0 : _a.includes('Enum')) {
|
|
418
|
+
typedocKind = TYPEDOC_KINDS.enum;
|
|
419
|
+
}
|
|
420
|
+
let typedocType = this.pythonTypeResolver.registerType(docspecMember.datatype);
|
|
421
|
+
if ((_b = docspecMember.decorations) === null || _b === void 0 ? void 0 : _b.some((d) => ['property', 'dualproperty'].includes(d.name))) {
|
|
422
|
+
typedocKind = TYPEDOC_KINDS.data;
|
|
423
|
+
typedocType = this.pythonTypeResolver.registerType((_c = docspecMember.return_type) !== null && _c !== void 0 ? _c : docspecMember.datatype);
|
|
424
|
+
}
|
|
425
|
+
if (parentTypeDoc.kindString === 'Enumeration') {
|
|
426
|
+
typedocKind = TYPEDOC_KINDS.enumValue;
|
|
427
|
+
typedocType = {
|
|
428
|
+
type: 'literal',
|
|
429
|
+
value: docspecMember.value,
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
return { typedocKind, typedocType };
|
|
405
433
|
}
|
|
406
|
-
return {
|
|
407
|
-
typedocKind,
|
|
408
|
-
typedocType
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
434
|
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
435
|
+
/**
|
|
436
|
+
* Maps Google-style docstring section names to Docusaurus admonition types.
|
|
437
|
+
* Only sections that semantically match admonition purposes are included.
|
|
438
|
+
* Sections like Raises, Yields, Attributes are technical documentation, not admonitions.
|
|
439
|
+
*/
|
|
440
|
+
DocspecTransformer.SECTION_TO_ADMONITION = {
|
|
441
|
+
Danger: 'danger',
|
|
442
|
+
Info: 'info',
|
|
443
|
+
Note: 'note',
|
|
444
|
+
Tip: 'tip',
|
|
445
|
+
Warning: 'warning',
|
|
446
|
+
};
|
|
447
|
+
//# sourceMappingURL=transformation.js.map
|