@apify/docusaurus-plugin-typedoc-api 4.4.12 → 5.0.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 +80 -0
- package/lib/plugin/python/transformation.d.ts.map +1 -0
- package/lib/plugin/python/transformation.js +350 -392
- 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 +112 -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 +24 -17
- 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/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
package/lib/plugin/data.js
CHANGED
|
@@ -1,469 +1,431 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
function
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
10
|
-
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); }
|
|
11
|
-
const childProcess = require('node:child_process');
|
|
12
|
-
const fs = require('node:fs');
|
|
13
|
-
const path = require('node:path');
|
|
14
|
-
const TypeDoc = require('typedoc');
|
|
15
|
-
const ts = require('typescript');
|
|
16
|
-
const utils = require('@docusaurus/utils');
|
|
17
|
-
const links = require('../utils/links.js');
|
|
18
|
-
const reexports = require('../utils/reexports.js');
|
|
19
|
-
const index = require('./python/index.js');
|
|
20
|
-
const _0_23 = require('./structure/0.23.js');
|
|
21
|
-
const url = require('./url.js');
|
|
22
|
-
const _interopDefault = e => e && e.__esModule ? e : {
|
|
23
|
-
default: e
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
24
9
|
};
|
|
25
|
-
function
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import { spawnSync } from 'node:child_process';
|
|
22
|
+
import fs from 'node:fs';
|
|
23
|
+
import path from 'node:path';
|
|
24
|
+
import * as TypeDoc from 'typedoc';
|
|
25
|
+
import { ReflectionKind } from 'typedoc';
|
|
26
|
+
import ts from 'typescript';
|
|
27
|
+
import { normalizeUrl } from '@docusaurus/utils';
|
|
28
|
+
import { injectGitRevision } from '../utils/links';
|
|
29
|
+
import { injectReexports } from '../utils/reexports';
|
|
30
|
+
import { processPythonDocs } from './python';
|
|
31
|
+
import { migrateToVersion0230 } from './structure/0.23';
|
|
32
|
+
import { getKindSlug, getPackageSlug, joinUrl } from './url';
|
|
46
33
|
function shouldEmit(projectRoot, tsconfigPath) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
return result.projectReferences && result.projectReferences.length > 0 ? 'docs' : 'none';
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
35
|
+
const { config, error } = ts.readConfigFile(tsconfigPath, (name) => fs.readFileSync(name, 'utf8'));
|
|
36
|
+
if (error) {
|
|
37
|
+
throw new Error(`Failed to load ${tsconfigPath}`);
|
|
38
|
+
}
|
|
39
|
+
const result = ts.parseJsonConfigFileContent(config, ts.sys, projectRoot, {}, tsconfigPath);
|
|
40
|
+
if (result.errors.length > 0) {
|
|
41
|
+
throw new Error(`Failed to parse ${tsconfigPath}`);
|
|
42
|
+
}
|
|
43
|
+
return result.projectReferences && result.projectReferences.length > 0 ? 'docs' : 'none';
|
|
59
44
|
}
|
|
60
|
-
|
|
61
45
|
// Persist build state as a global, since the plugin is re-evaluated every hot reload.
|
|
62
46
|
// Because of this, we can't use state in the plugin or module scope.
|
|
63
47
|
if (!global.typedocBuild) {
|
|
64
|
-
|
|
65
|
-
count: 0
|
|
66
|
-
};
|
|
48
|
+
global.typedocBuild = { count: 0 };
|
|
67
49
|
}
|
|
68
50
|
function getCurrentGitRef() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
51
|
+
try {
|
|
52
|
+
const result = spawnSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' });
|
|
53
|
+
if (result.status === 0) {
|
|
54
|
+
return result.stdout.trim();
|
|
55
|
+
}
|
|
56
|
+
console.warn(`[@apify/docusaurus-plugin-typedoc-api]: Unable to get current git SHA:`, result.stderr.trim());
|
|
75
57
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
console.warn(`[@apify/docusaurus-plugin-typedoc-api]: Error while getting current git SHA:`, error);
|
|
79
|
-
}
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
async function generateJson(projectRoot, entryPoints, outFile, options, context) {
|
|
83
|
-
/* eslint-disable sort-keys */
|
|
84
|
-
if (projectRoot && !path__default.default.isAbsolute(projectRoot)) {
|
|
85
|
-
projectRoot = path__default.default.join(context.siteDir, projectRoot);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Running the TypeDoc compiler is pretty slow...
|
|
89
|
-
// We should only load on the 1st build, and use cache for subsequent reloads.
|
|
90
|
-
if (global.typedocBuild.count > 0 && fs__default.default.existsSync(outFile)) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
if (options.pathToCurrentVersionTypedocJSON) {
|
|
94
|
-
fs__default.default.copyFileSync(options.pathToCurrentVersionTypedocJSON, outFile);
|
|
95
|
-
}
|
|
96
|
-
if (Object.keys(options.pythonOptions).length > 0) {
|
|
97
|
-
if (!options.pythonOptions.pythonModulePath || !options.pythonOptions.moduleShortcutsPath) {
|
|
98
|
-
throw new Error('Python options are missing required fields');
|
|
58
|
+
catch (error) {
|
|
59
|
+
console.warn(`[@apify/docusaurus-plugin-typedoc-api]: Error while getting current git SHA:`, error);
|
|
99
60
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
export function generateJson(projectRoot, entryPoints, outFile, options, context) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
/* eslint-disable sort-keys */
|
|
67
|
+
if (projectRoot && !path.isAbsolute(projectRoot)) {
|
|
68
|
+
projectRoot = path.join(context.siteDir, projectRoot);
|
|
69
|
+
}
|
|
70
|
+
// Running the TypeDoc compiler is pretty slow...
|
|
71
|
+
// We should only load on the 1st build, and use cache for subsequent reloads.
|
|
72
|
+
if (global.typedocBuild.count > 0 && fs.existsSync(outFile)) {
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
if (options.pathToCurrentVersionTypedocJSON) {
|
|
76
|
+
fs.copyFileSync(options.pathToCurrentVersionTypedocJSON, outFile);
|
|
77
|
+
}
|
|
78
|
+
if (Object.keys(options.pythonOptions).length > 0) {
|
|
79
|
+
if (!options.pythonOptions.pythonModulePath ||
|
|
80
|
+
!options.pythonOptions.moduleShortcutsPath) {
|
|
81
|
+
throw new Error('Python options are missing required fields');
|
|
82
|
+
}
|
|
83
|
+
processPythonDocs({
|
|
84
|
+
moduleShortcutsPath: options.pythonOptions.moduleShortcutsPath,
|
|
85
|
+
outPath: outFile,
|
|
86
|
+
pythonModulePath: options.pythonOptions.pythonModulePath,
|
|
87
|
+
gitRevision: options.gitRefName,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const tsconfig = path.join(projectRoot, (_a = options.tsconfigName) !== null && _a !== void 0 ? _a : 'tsconfig.json');
|
|
92
|
+
const app = yield TypeDoc.Application.bootstrapWithPlugins(Object.assign(Object.assign({ gitRevision: (_b = getCurrentGitRef()) !== null && _b !== void 0 ? _b : options.gitRefName, includeVersion: true, skipErrorChecking: true,
|
|
93
|
+
// stripYamlFrontmatter: true,
|
|
94
|
+
// Only emit when using project references
|
|
95
|
+
emit: shouldEmit(projectRoot, tsconfig),
|
|
96
|
+
// Only document the public API by default
|
|
97
|
+
excludeExternals: true, excludeInternal: true, excludePrivate: true, excludeProtected: true,
|
|
98
|
+
// Enable verbose logging when debugging
|
|
99
|
+
logLevel: options.debug ? 'Verbose' : 'Info', inlineTags: [
|
|
100
|
+
'@link',
|
|
101
|
+
'@inheritDoc',
|
|
102
|
+
'@label',
|
|
103
|
+
'@linkcode',
|
|
104
|
+
'@linkplain',
|
|
105
|
+
'@apilink',
|
|
106
|
+
'@doclink',
|
|
107
|
+
] }, options.typedocOptions), {
|
|
108
|
+
// Control how config and packages are detected
|
|
109
|
+
tsconfig, entryPoints: entryPoints.map((ep) => path.join(projectRoot, ep)), entryPointStrategy: 'expand', exclude: options.exclude,
|
|
110
|
+
// We use a fake category title so that we can fallback to the parent group
|
|
111
|
+
defaultCategory: '__CATEGORY__' }), [new TypeDoc.TSConfigReader(), new TypeDoc.TypeDocReader()]);
|
|
112
|
+
const project = yield app.convert();
|
|
113
|
+
if (project) {
|
|
114
|
+
yield app.generateJson(project, outFile);
|
|
115
|
+
global.typedocBuild.count += 1;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (options.reexports && options.reexports.length > 0) {
|
|
119
|
+
yield injectReexports(outFile, options.reexports);
|
|
120
|
+
}
|
|
121
|
+
const gitRefName = getCurrentGitRef();
|
|
122
|
+
if (gitRefName) {
|
|
123
|
+
injectGitRevision(outFile, gitRefName);
|
|
124
|
+
}
|
|
125
|
+
return true;
|
|
105
126
|
});
|
|
106
|
-
} else {
|
|
107
|
-
const tsconfig = path__default.default.join(projectRoot, options.tsconfigName ?? 'tsconfig.json');
|
|
108
|
-
const app = await TypeDoc__namespace.Application.bootstrapWithPlugins(_objectSpread(_objectSpread({
|
|
109
|
-
gitRevision: getCurrentGitRef() ?? options.gitRefName,
|
|
110
|
-
includeVersion: true,
|
|
111
|
-
skipErrorChecking: true,
|
|
112
|
-
// stripYamlFrontmatter: true,
|
|
113
|
-
// Only emit when using project references
|
|
114
|
-
emit: shouldEmit(projectRoot, tsconfig),
|
|
115
|
-
// Only document the public API by default
|
|
116
|
-
excludeExternals: true,
|
|
117
|
-
excludeInternal: true,
|
|
118
|
-
excludePrivate: true,
|
|
119
|
-
excludeProtected: true,
|
|
120
|
-
// Enable verbose logging when debugging
|
|
121
|
-
logLevel: options.debug ? 'Verbose' : 'Info',
|
|
122
|
-
inlineTags: ['@link', '@inheritDoc', '@label', '@linkcode', '@linkplain', '@apilink', '@doclink']
|
|
123
|
-
}, options.typedocOptions), {}, {
|
|
124
|
-
// Control how config and packages are detected
|
|
125
|
-
tsconfig,
|
|
126
|
-
entryPoints: entryPoints.map(ep => path__default.default.join(projectRoot, ep)),
|
|
127
|
-
entryPointStrategy: 'expand',
|
|
128
|
-
exclude: options.exclude,
|
|
129
|
-
// We use a fake category title so that we can fallback to the parent group
|
|
130
|
-
defaultCategory: '__CATEGORY__'
|
|
131
|
-
}), [new TypeDoc__namespace.TSConfigReader(), new TypeDoc__namespace.TypeDocReader()]);
|
|
132
|
-
const project = await app.convert();
|
|
133
|
-
if (project) {
|
|
134
|
-
await app.generateJson(project, outFile);
|
|
135
|
-
global.typedocBuild.count += 1;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
if (options.reexports && options.reexports.length > 0) {
|
|
139
|
-
await reexports.injectReexports(outFile, options.reexports);
|
|
140
|
-
}
|
|
141
|
-
const gitRefName = getCurrentGitRef();
|
|
142
|
-
if (gitRefName) {
|
|
143
|
-
links.injectGitRevision(outFile, gitRefName);
|
|
144
|
-
}
|
|
145
|
-
return true;
|
|
146
127
|
}
|
|
147
|
-
function createReflectionMap(items = []) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
128
|
+
export function createReflectionMap(items = []) {
|
|
129
|
+
const map = {};
|
|
130
|
+
items.forEach((item) => {
|
|
131
|
+
var _a, _b;
|
|
132
|
+
// Add @reference categories to reflection.
|
|
133
|
+
const referenceCategories = {};
|
|
134
|
+
for (const tag of (_b = (_a = item.comment) === null || _a === void 0 ? void 0 : _a.blockTags) !== null && _b !== void 0 ? _b : []) {
|
|
135
|
+
if (tag.tag === '@reference' && tag.content.length >= 2 && tag.content[0].kind === 'text') {
|
|
136
|
+
const categoryName = tag.content[0].text.trim();
|
|
137
|
+
const ref = tag.content.find((t) => t.tag === '@link');
|
|
138
|
+
if (ref && typeof ref.target === 'number') {
|
|
139
|
+
if (!(categoryName in referenceCategories)) {
|
|
140
|
+
referenceCategories[categoryName] = { title: categoryName, children: [] };
|
|
141
|
+
}
|
|
142
|
+
if (!referenceCategories[categoryName].children.includes(ref.target)) {
|
|
143
|
+
referenceCategories[categoryName].children.push(ref.target);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
166
147
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
// Update categories with reference categories.
|
|
171
|
-
if (!item.categories) {
|
|
172
|
-
item.categories = [];
|
|
173
|
-
}
|
|
174
|
-
for (const category of Object.values(referenceCategories)) {
|
|
175
|
-
if (category.children.length > 0) {
|
|
176
|
-
const index = item.categories.findIndex(c => c.title === category.title);
|
|
177
|
-
if (index === -1) {
|
|
178
|
-
item.categories.push(category);
|
|
148
|
+
// Update categories with reference categories.
|
|
149
|
+
if (!item.categories) {
|
|
150
|
+
item.categories = [];
|
|
179
151
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
152
|
+
for (const category of Object.values(referenceCategories)) {
|
|
153
|
+
if (category.children.length > 0) {
|
|
154
|
+
const index = item.categories.findIndex((c) => c.title === category.title);
|
|
155
|
+
if (index === -1) {
|
|
156
|
+
item.categories.push(category);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Add item.
|
|
161
|
+
map[item.id] = item;
|
|
162
|
+
});
|
|
163
|
+
return map;
|
|
187
164
|
}
|
|
188
|
-
function loadPackageJsonAndDocs(initialDir, pkgFileName = 'package.json', readmeFileName = 'README.md', changelogFileName = 'CHANGELOG.md') {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
165
|
+
export function loadPackageJsonAndDocs(initialDir, pkgFileName = 'package.json', readmeFileName = 'README.md', changelogFileName = 'CHANGELOG.md') {
|
|
166
|
+
let currentDir = initialDir;
|
|
167
|
+
let found = true;
|
|
168
|
+
while (!fs.existsSync(path.join(currentDir, pkgFileName))) {
|
|
169
|
+
if (currentDir === path.dirname(currentDir)) {
|
|
170
|
+
found = false;
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
currentDir = path.dirname(currentDir);
|
|
175
|
+
}
|
|
197
176
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
177
|
+
if (!found) {
|
|
178
|
+
// TODO: load the actual package information from pyproject.toml or similar
|
|
179
|
+
return {
|
|
180
|
+
packageJson: {
|
|
181
|
+
name: 'crawlee',
|
|
182
|
+
version: '1.0.0',
|
|
183
|
+
},
|
|
184
|
+
readmePath: '',
|
|
185
|
+
changelogPath: '',
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
const readmePath = path.join(currentDir, readmeFileName);
|
|
189
|
+
const changelogPath = path.join(currentDir, changelogFileName);
|
|
201
190
|
return {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
},
|
|
206
|
-
readmePath: '',
|
|
207
|
-
changelogPath: ''
|
|
191
|
+
packageJson: JSON.parse(fs.readFileSync(path.join(currentDir, pkgFileName), 'utf8')),
|
|
192
|
+
readmePath: fs.existsSync(readmePath) ? readmePath : '',
|
|
193
|
+
changelogPath: fs.existsSync(changelogPath) ? changelogPath : '',
|
|
208
194
|
};
|
|
209
|
-
}
|
|
210
|
-
const readmePath = path__default.default.join(currentDir, readmeFileName);
|
|
211
|
-
const changelogPath = path__default.default.join(currentDir, changelogFileName);
|
|
212
|
-
return {
|
|
213
|
-
packageJson: JSON.parse(fs__default.default.readFileSync(path__default.default.join(currentDir, pkgFileName), 'utf8')),
|
|
214
|
-
readmePath: fs__default.default.existsSync(readmePath) ? readmePath : '',
|
|
215
|
-
changelogPath: fs__default.default.existsSync(changelogPath) ? changelogPath : ''
|
|
216
|
-
};
|
|
217
195
|
}
|
|
218
|
-
function addMetadataToReflections(project, packageSlug, urlPrefix, options) {
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
})
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
// @ts-expect-error Not sure why this fails
|
|
240
|
-
return _objectSpread(_objectSpread({}, project), {}, {
|
|
241
|
-
permalink: utils.normalizeUrl([permalink])
|
|
242
|
-
});
|
|
196
|
+
export function addMetadataToReflections(project, packageSlug, urlPrefix, options) {
|
|
197
|
+
const permalink = `/${joinUrl(urlPrefix, packageSlug)}`;
|
|
198
|
+
if (project.children) {
|
|
199
|
+
project.children = project.children.map((child) => {
|
|
200
|
+
migrateToVersion0230(child);
|
|
201
|
+
const kindSlugPart = getKindSlug(child);
|
|
202
|
+
const childSlug = kindSlugPart ? `/${kindSlugPart}/${child.name}` : `#${child.name}`;
|
|
203
|
+
const childPermalink = permalink + childSlug;
|
|
204
|
+
// We need to go another level deeper and only use fragments
|
|
205
|
+
if ((child.kind === ReflectionKind.Namespace || options.python) && child.children) {
|
|
206
|
+
child.children = child.children.map((grandChild) => (Object.assign(Object.assign({}, grandChild), { permalink: normalizeUrl([`${childPermalink}#${grandChild.name}`]) })));
|
|
207
|
+
}
|
|
208
|
+
return Object.assign(Object.assign({}, child), { permalink: normalizeUrl([childPermalink]) });
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// @ts-expect-error Not sure why this fails
|
|
212
|
+
return Object.assign(Object.assign({}, project), { permalink: normalizeUrl([permalink]) });
|
|
243
213
|
}
|
|
244
214
|
function mergeReflections(base, next) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
215
|
+
if (Array.isArray(base.children) && Array.isArray(next.children)) {
|
|
216
|
+
base.children.push(...next.children);
|
|
217
|
+
}
|
|
218
|
+
if (Array.isArray(base.groups) && Array.isArray(next.groups)) {
|
|
219
|
+
next.groups.forEach((group) => {
|
|
220
|
+
var _a, _b, _c, _d;
|
|
221
|
+
const baseGroup = (_a = base.groups) === null || _a === void 0 ? void 0 : _a.find((g) => g.title === group.title);
|
|
222
|
+
if (baseGroup) {
|
|
223
|
+
(_b = baseGroup.children) === null || _b === void 0 ? void 0 : _b.push(...((_c = group.children) !== null && _c !== void 0 ? _c : []));
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
(_d = base.groups) === null || _d === void 0 ? void 0 : _d.push(group);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
// We can remove refs since were merging all reflections into one
|
|
230
|
+
base.groups = base.groups.filter((group) => group.title !== 'References');
|
|
231
|
+
}
|
|
262
232
|
}
|
|
263
233
|
function sortReflectionGroups(reflections) {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
234
|
+
reflections.forEach((reflection) => {
|
|
235
|
+
var _a, _b;
|
|
236
|
+
const map = createReflectionMap(reflection.children);
|
|
237
|
+
const sort = (a, b) => (map[a].name < map[b].name ? -1 : 1);
|
|
238
|
+
(_a = reflection.categories) === null || _a === void 0 ? void 0 : _a.forEach((category) => {
|
|
239
|
+
var _a;
|
|
240
|
+
(_a = category.children) === null || _a === void 0 ? void 0 : _a.sort(sort);
|
|
241
|
+
});
|
|
242
|
+
(_b = reflection.groups) === null || _b === void 0 ? void 0 : _b.forEach((group) => {
|
|
243
|
+
var _a, _b;
|
|
244
|
+
(_a = group.children) === null || _a === void 0 ? void 0 : _a.sort(sort);
|
|
245
|
+
(_b = group.categories) === null || _b === void 0 ? void 0 : _b.forEach((category) => {
|
|
246
|
+
var _a;
|
|
247
|
+
(_a = category.children) === null || _a === void 0 ? void 0 : _a.sort(sort);
|
|
248
|
+
});
|
|
249
|
+
});
|
|
275
250
|
});
|
|
276
|
-
});
|
|
277
251
|
}
|
|
278
|
-
function sourceFileMatchesEntryPoint(sourceFile, entryPoint, {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
252
|
+
function sourceFileMatchesEntryPoint(sourceFile, entryPoint, { deep, single }) {
|
|
253
|
+
// Single package
|
|
254
|
+
if (single) {
|
|
255
|
+
return (
|
|
256
|
+
// src/index.ts === src/index.ts
|
|
257
|
+
(!deep && sourceFile === entryPoint) ||
|
|
258
|
+
// index.ts === src/index.ts
|
|
259
|
+
(!deep && sourceFile === path.basename(entryPoint)) ||
|
|
260
|
+
// some/deep/file.ts === ...
|
|
261
|
+
deep);
|
|
262
|
+
}
|
|
263
|
+
// Multiple packages
|
|
284
264
|
return (
|
|
285
|
-
// src/index.ts === src/index.ts
|
|
286
|
-
!deep && sourceFile === entryPoint ||
|
|
287
|
-
// index.ts === src/index.ts
|
|
288
|
-
!deep && sourceFile === path__default.default.basename(entryPoint) ||
|
|
289
|
-
// some/deep/file.ts === ...
|
|
290
|
-
deep
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Multiple packages
|
|
295
|
-
return (
|
|
296
265
|
// packages/foo/src/index.ts === packages/foo/src/index.ts
|
|
297
266
|
// foo/src/index.ts ~ packages/foo/src/index.ts
|
|
298
|
-
!deep && (sourceFile === entryPoint || entryPoint.endsWith(sourceFile)) ||
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
);
|
|
267
|
+
(!deep && (sourceFile === entryPoint || entryPoint.endsWith(sourceFile))) ||
|
|
268
|
+
// packages/foo/src/some/deep/file.ts === packages/foo/src/
|
|
269
|
+
(deep && sourceFile.startsWith(entryPoint)));
|
|
302
270
|
}
|
|
303
271
|
function modContainsEntryPoint(mod, entry, meta) {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
272
|
+
var _a, _b, _c, _d, _e;
|
|
273
|
+
const relModSources = (_a = mod.sources) !== null && _a !== void 0 ? _a : [];
|
|
274
|
+
const relModSourceFile = (_c = (_b = relModSources.find((sf) => !!sf.fileName)) === null || _b === void 0 ? void 0 : _b.fileName) !== null && _c !== void 0 ? _c : '';
|
|
275
|
+
const relEntryPoint = joinUrl(meta.packagePath, entry.path);
|
|
276
|
+
// Monorepos of 1 package don't have sources, so use the child sources.
|
|
277
|
+
// They also don't use full paths like "package/src/index.ts" and simply use "index.ts",
|
|
278
|
+
// so account for those entry points also.
|
|
279
|
+
if (!relModSourceFile) {
|
|
280
|
+
const absEntryPoint = path.normalize(path.join((_d = meta.packageRoot) !== null && _d !== void 0 ? _d : '', (_e = entry.path) !== null && _e !== void 0 ? _e : ''));
|
|
281
|
+
const relEntryPointName = path.basename(relEntryPoint);
|
|
282
|
+
const entryPointInSourceFiles = !!meta.allSourceFiles[absEntryPoint] ||
|
|
283
|
+
!!meta.allSourceFiles[relEntryPoint] ||
|
|
284
|
+
(relEntryPointName.startsWith('index.') && !!meta.allSourceFiles[relEntryPointName]);
|
|
285
|
+
if (entryPointInSourceFiles) {
|
|
286
|
+
return sourceFileMatchesEntryPoint(relEntryPoint, relEntryPoint, {
|
|
287
|
+
deep: meta.isUsingDeepImports,
|
|
288
|
+
single: meta.isSinglePackage,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
320
291
|
}
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
});
|
|
292
|
+
return sourceFileMatchesEntryPoint(relModSourceFile, relEntryPoint, {
|
|
293
|
+
deep: meta.isUsingDeepImports,
|
|
294
|
+
single: meta.isSinglePackage,
|
|
295
|
+
});
|
|
326
296
|
}
|
|
327
297
|
function extractReflectionModules(project, isSinglePackage) {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
298
|
+
var _a;
|
|
299
|
+
const modules = [];
|
|
300
|
+
const inheritChildren = () => {
|
|
301
|
+
var _a;
|
|
302
|
+
(_a = project.children) === null || _a === void 0 ? void 0 : _a.forEach((child) => {
|
|
303
|
+
if (child.kind === ReflectionKind.Module) {
|
|
304
|
+
modules.push(child);
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
// Single packages are extremely difficult, as the TypeDoc structure is
|
|
309
|
+
// different for every kind of package entry point pattern
|
|
310
|
+
if (isSinglePackage) {
|
|
311
|
+
const hasNoModules = (_a = project.children) === null || _a === void 0 ? void 0 : _a.every((child) => child.kind !== ReflectionKind.Module);
|
|
312
|
+
if (hasNoModules) {
|
|
313
|
+
// No "module" children:
|
|
314
|
+
// - Polyrepos
|
|
315
|
+
// - Monorepos with 1 package
|
|
316
|
+
modules.push(project);
|
|
317
|
+
}
|
|
318
|
+
else {
|
|
319
|
+
// Has "module" children:
|
|
320
|
+
// - Polyrepos with deep imports
|
|
321
|
+
// - Polyrepos with multi-imports
|
|
322
|
+
// - Monorepos
|
|
323
|
+
inheritChildren();
|
|
324
|
+
}
|
|
325
|
+
// Multiple packages are extremely simple, as every package is a module reflection
|
|
326
|
+
// as a child on the top-level project reflection
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
inheritChildren();
|
|
352
330
|
}
|
|
353
|
-
|
|
354
|
-
// Multiple packages are extremely simple, as every package is a module reflection
|
|
355
|
-
// as a child on the top-level project reflection
|
|
356
|
-
} else {
|
|
357
|
-
inheritChildren();
|
|
358
|
-
}
|
|
359
|
-
return modules;
|
|
331
|
+
return modules;
|
|
360
332
|
}
|
|
361
333
|
function buildSourceFileNameMap(project, modChildren) {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
334
|
+
const map = {};
|
|
335
|
+
const cwd = process.cwd();
|
|
336
|
+
if (project.symbolIdMap) {
|
|
337
|
+
Object.values(project.symbolIdMap).forEach((symbol) => {
|
|
338
|
+
// absolute
|
|
339
|
+
map[path.normalize(path.join(cwd, symbol.sourceFileName))] = true;
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
modChildren.forEach((child) => {
|
|
343
|
+
var _a;
|
|
344
|
+
(_a = child.sources) === null || _a === void 0 ? void 0 : _a.forEach((sf) => {
|
|
345
|
+
// relative
|
|
346
|
+
map[sf.fileName] = true;
|
|
347
|
+
});
|
|
374
348
|
});
|
|
375
|
-
|
|
376
|
-
return map;
|
|
349
|
+
return map;
|
|
377
350
|
}
|
|
378
|
-
function flattenAndGroupPackages(packageConfigs, project, urlPrefix, options, context, versioned = false) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
})
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
// Sort packages by name
|
|
453
|
-
return Object.values(packages).sort((a, b) => a.packageName.localeCompare(b.packageName));
|
|
351
|
+
export function flattenAndGroupPackages(packageConfigs, project, urlPrefix, options, context, versioned = false) {
|
|
352
|
+
const isSinglePackage = packageConfigs.length === 1;
|
|
353
|
+
const modules = extractReflectionModules(project, isSinglePackage);
|
|
354
|
+
// Loop through every TypeDoc module and group based on package and entry point
|
|
355
|
+
const packages = {};
|
|
356
|
+
const packagesWithDeepImports = [];
|
|
357
|
+
modules.forEach((mod) => {
|
|
358
|
+
var _a;
|
|
359
|
+
const allSourceFiles = buildSourceFileNameMap(project, (_a = mod.children) !== null && _a !== void 0 ? _a : []);
|
|
360
|
+
packageConfigs.some((cfg) => Object.entries(cfg.entryPoints).some(([importPath, entry]) => {
|
|
361
|
+
const isUsingDeepImports = !entry.path.match(/\.tsx?$/);
|
|
362
|
+
let { packageRoot } = cfg;
|
|
363
|
+
if (packageRoot && !path.isAbsolute(packageRoot)) {
|
|
364
|
+
packageRoot = path.join(context.siteDir, packageRoot);
|
|
365
|
+
}
|
|
366
|
+
if (!modContainsEntryPoint(mod, entry, {
|
|
367
|
+
allSourceFiles,
|
|
368
|
+
isSinglePackage,
|
|
369
|
+
isUsingDeepImports,
|
|
370
|
+
packagePath: cfg.packagePath,
|
|
371
|
+
packageRoot,
|
|
372
|
+
})) {
|
|
373
|
+
return false;
|
|
374
|
+
}
|
|
375
|
+
// We have a matching entry point, so store the record
|
|
376
|
+
if (!packages[cfg.packagePath]) {
|
|
377
|
+
const { packageJson, readmePath, changelogPath } = loadPackageJsonAndDocs(path.join(options.projectRoot, cfg.packagePath), options.packageJsonName, options.readmeName, options.changelogName);
|
|
378
|
+
packages[cfg.packagePath] = {
|
|
379
|
+
entryPoints: [],
|
|
380
|
+
packageName: (versioned && cfg.packageName) || packageJson.name,
|
|
381
|
+
packageVersion: (versioned && cfg.packageVersion) || packageJson.version,
|
|
382
|
+
readmePath,
|
|
383
|
+
changelogPath,
|
|
384
|
+
};
|
|
385
|
+
cfg.packageName = packages[cfg.packagePath].packageName;
|
|
386
|
+
cfg.packageVersion = packages[cfg.packagePath].packageVersion;
|
|
387
|
+
}
|
|
388
|
+
// Add metadata to package and children reflections
|
|
389
|
+
const urlSlug = getPackageSlug(cfg, importPath, isSinglePackage);
|
|
390
|
+
const reflection = addMetadataToReflections(mod, urlSlug, urlPrefix, options);
|
|
391
|
+
const existingEntry = packages[cfg.packagePath].entryPoints.find((ep) => ep.urlSlug === urlSlug);
|
|
392
|
+
if (existingEntry) {
|
|
393
|
+
if (isUsingDeepImports) {
|
|
394
|
+
mergeReflections(existingEntry.reflection, reflection);
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
// eslint-disable-next-line no-console
|
|
398
|
+
console.error(`Entry point ${urlSlug} already defined. How did you get here?`);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
else {
|
|
402
|
+
packages[cfg.packagePath].entryPoints.push({
|
|
403
|
+
index: importPath === 'index',
|
|
404
|
+
label: entry.label,
|
|
405
|
+
reflection,
|
|
406
|
+
urlSlug,
|
|
407
|
+
});
|
|
408
|
+
if (isUsingDeepImports) {
|
|
409
|
+
packagesWithDeepImports.push(reflection);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
// Update the reflection name since its useless
|
|
413
|
+
reflection.name =
|
|
414
|
+
importPath === 'index'
|
|
415
|
+
? packages[cfg.packagePath].packageName
|
|
416
|
+
: joinUrl(packages[cfg.packagePath].packageName, importPath);
|
|
417
|
+
return true;
|
|
418
|
+
}));
|
|
419
|
+
});
|
|
420
|
+
// Since we merged multiple reflections together, we'll need to sort groups manually
|
|
421
|
+
sortReflectionGroups(packagesWithDeepImports);
|
|
422
|
+
// Sort packages by name
|
|
423
|
+
return Object.values(packages).sort((a, b) => a.packageName.localeCompare(b.packageName));
|
|
454
424
|
}
|
|
455
|
-
function formatPackagesWithoutHostInfo(packages) {
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
return pkg;
|
|
461
|
-
});
|
|
425
|
+
export function formatPackagesWithoutHostInfo(packages) {
|
|
426
|
+
return packages.map((_a) => {
|
|
427
|
+
var { changelogPath, readmePath } = _a, pkg = __rest(_a, ["changelogPath", "readmePath"]);
|
|
428
|
+
return pkg;
|
|
429
|
+
});
|
|
462
430
|
}
|
|
463
|
-
|
|
464
|
-
exports.createReflectionMap = createReflectionMap;
|
|
465
|
-
exports.flattenAndGroupPackages = flattenAndGroupPackages;
|
|
466
|
-
exports.formatPackagesWithoutHostInfo = formatPackagesWithoutHostInfo;
|
|
467
|
-
exports.generateJson = generateJson;
|
|
468
|
-
exports.loadPackageJsonAndDocs = loadPackageJsonAndDocs;
|
|
469
|
-
//# sourceMappingURL=data.js.map
|
|
431
|
+
//# sourceMappingURL=data.js.map
|