@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
package/lib/index.js
CHANGED
|
@@ -1,374 +1,362 @@
|
|
|
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 fs = require('node:fs');
|
|
9
|
-
const path = require('node:path');
|
|
10
|
-
const server = require('@docusaurus/plugin-content-docs/server');
|
|
11
|
-
const utils = require('@docusaurus/utils');
|
|
12
|
-
const data = require('./plugin/data.js');
|
|
13
|
-
const sidebar = require('./plugin/sidebar.js');
|
|
14
|
-
const version = require('./plugin/version.js');
|
|
15
|
-
const _interopDefault = e => e && e.__esModule ? e : {
|
|
16
|
-
default: e
|
|
17
|
-
};
|
|
18
|
-
const fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
19
|
-
const path__default = /*#__PURE__*/_interopDefault(path);
|
|
20
|
-
|
|
21
1
|
/* eslint-disable no-console, sort-keys */
|
|
22
|
-
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import { CURRENT_VERSION_NAME } from '@docusaurus/plugin-content-docs/server';
|
|
14
|
+
import { DEFAULT_PLUGIN_ID, normalizeUrl } from '@docusaurus/utils';
|
|
15
|
+
import { flattenAndGroupPackages, formatPackagesWithoutHostInfo, generateJson, loadPackageJsonAndDocs, } from './plugin/data';
|
|
16
|
+
import { extractSidebar } from './plugin/sidebar';
|
|
17
|
+
import { getVersionedDocsDirPath, readVersionsMetadata } from './plugin/version';
|
|
23
18
|
const PLUGIN_NAME = 'docusaurus-plugin-typedoc-api';
|
|
24
19
|
const DEFAULT_OPTIONS = {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
20
|
+
banner: '',
|
|
21
|
+
breadcrumbs: true,
|
|
22
|
+
changelogName: 'CHANGELOG.md',
|
|
23
|
+
changelogs: false,
|
|
24
|
+
debug: false,
|
|
25
|
+
disableVersioning: false,
|
|
26
|
+
exclude: [],
|
|
27
|
+
gitRefName: 'master',
|
|
28
|
+
id: DEFAULT_PLUGIN_ID,
|
|
29
|
+
includeCurrentVersion: true,
|
|
30
|
+
lastVersion: '',
|
|
31
|
+
minimal: false,
|
|
32
|
+
onlyIncludeVersions: [],
|
|
33
|
+
packageJsonName: 'package.json',
|
|
34
|
+
packages: [],
|
|
35
|
+
pathToCurrentVersionTypedocJSON: '',
|
|
36
|
+
projectRoot: '.',
|
|
37
|
+
sortPackages: (a, d) => a.packageName.localeCompare(d.packageName),
|
|
38
|
+
sortSidebar: (a, d) => a.localeCompare(d),
|
|
39
|
+
readmeName: 'README.md',
|
|
40
|
+
readmes: false,
|
|
41
|
+
removeScopes: [],
|
|
42
|
+
routeBasePath: 'api',
|
|
43
|
+
tsconfigName: 'tsconfig.json',
|
|
44
|
+
typedocOptions: {},
|
|
45
|
+
remarkPlugins: [],
|
|
46
|
+
rehypePlugins: [],
|
|
47
|
+
versions: {},
|
|
48
|
+
python: false,
|
|
49
|
+
pythonOptions: {},
|
|
50
|
+
reexports: [],
|
|
56
51
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function typedocApiPlugin(context, pluginOptions) {
|
|
65
|
-
const options = _objectSpread(_objectSpread({}, DEFAULT_OPTIONS), pluginOptions);
|
|
66
|
-
const banner = options.banner,
|
|
67
|
-
breadcrumbs = options.breadcrumbs,
|
|
68
|
-
changelogs = options.changelogs,
|
|
69
|
-
pluginId = options.id,
|
|
70
|
-
gitRefName = options.gitRefName,
|
|
71
|
-
minimal = options.minimal,
|
|
72
|
-
readmes = options.readmes,
|
|
73
|
-
removeScopes = options.removeScopes;
|
|
74
|
-
let projectRoot = options.projectRoot;
|
|
75
|
-
if (options.pythonOptions && Object.keys(options.pythonOptions).length > 0) {
|
|
76
|
-
options.python = true;
|
|
77
|
-
}
|
|
78
|
-
const isDefaultPluginId = pluginId === utils.DEFAULT_PLUGIN_ID;
|
|
79
|
-
const versionsMetadata = version.readVersionsMetadata(context, options);
|
|
80
|
-
const versionsDocsDir = version.getVersionedDocsDirPath(context.siteDir, pluginId);
|
|
81
|
-
|
|
82
|
-
// Determine entry points from configs
|
|
83
|
-
const entryPoints = [];
|
|
84
|
-
const packageConfigs = options.packages.map(pkgItem => {
|
|
85
|
-
const pkgConfig = typeof pkgItem === 'string' ? {
|
|
86
|
-
path: pkgItem
|
|
87
|
-
} : pkgItem;
|
|
88
|
-
const entries = {};
|
|
89
|
-
if (!pkgConfig.entry || typeof pkgConfig.entry === 'string') {
|
|
90
|
-
entries.index = {
|
|
91
|
-
label: 'Index',
|
|
92
|
-
path: pkgConfig.entry ? String(pkgConfig.entry) : 'src/index.ts'
|
|
93
|
-
};
|
|
94
|
-
} else {
|
|
95
|
-
Object.entries(pkgConfig.entry).forEach(([importPath, entryConfig]) => {
|
|
96
|
-
entries[importPath] = typeof entryConfig === 'string' ? {
|
|
97
|
-
label: 'Index',
|
|
98
|
-
path: entryConfig
|
|
99
|
-
} : entryConfig;
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
Object.values(entries).forEach(entryConfig => {
|
|
103
|
-
entryPoints.push(path__default.default.join(pkgConfig.path, entryConfig.path));
|
|
52
|
+
function importFile(file) {
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const data = yield fs.promises.readFile(file, 'utf8');
|
|
55
|
+
if (file.endsWith('.json')) {
|
|
56
|
+
return JSON.parse(data);
|
|
57
|
+
}
|
|
58
|
+
return data;
|
|
104
59
|
});
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
60
|
+
}
|
|
61
|
+
export default function typedocApiPlugin(context, pluginOptions) {
|
|
62
|
+
const options = Object.assign(Object.assign({}, DEFAULT_OPTIONS), pluginOptions);
|
|
63
|
+
const { banner, breadcrumbs, changelogs, id: pluginId, gitRefName, minimal, readmes, removeScopes, } = options;
|
|
64
|
+
let { projectRoot } = options;
|
|
65
|
+
if (options.pythonOptions && Object.keys(options.pythonOptions).length > 0) {
|
|
66
|
+
options.python = true;
|
|
110
67
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const commandDescription = isDefaultPluginId ? 'Tag a new API version' : `Tag a new API version (${pluginId})`;
|
|
126
|
-
cli.command(command).arguments('<version>').description(commandDescription).action(async version => {
|
|
127
|
-
const outDir = path__default.default.join(versionsDocsDir, `version-${version}`);
|
|
128
|
-
const prefix = isDefaultPluginId ? 'api' : pluginId;
|
|
129
|
-
console.log(`[${prefix}]:`, 'Generating docs...');
|
|
130
|
-
if (path__default.default.isAbsolute(projectRoot)) {
|
|
131
|
-
console.debug(`[${PLUGIN_NAME}]:`, `projectRoot should be a relative path, not an absolute path.
|
|
132
|
-
Overwriting with relative path from siteDir (${context.siteDir}).`);
|
|
133
|
-
projectRoot = path__default.default.relative(context.siteDir, projectRoot);
|
|
134
|
-
}
|
|
135
|
-
await data.generateJson(projectRoot, entryPoints, path__default.default.join(outDir, 'api-typedoc.json'), options, context);
|
|
136
|
-
console.log(`[${prefix}]:`, 'Persisting packages...');
|
|
137
|
-
|
|
138
|
-
// Load info from `package.json`s
|
|
139
|
-
packageConfigs.forEach(cfg => {
|
|
140
|
-
const _data$loadPackageJson = data.loadPackageJsonAndDocs(path__default.default.join(options.projectRoot, cfg.packagePath), options.packageJsonName, options.readmeName, options.changelogName),
|
|
141
|
-
packageJson = _data$loadPackageJson.packageJson;
|
|
142
|
-
cfg.packageName = packageJson.name;
|
|
143
|
-
cfg.packageVersion = packageJson.version;
|
|
144
|
-
});
|
|
145
|
-
await fs__default.default.promises.writeFile(path__default.default.join(outDir, 'api-packages.json'), JSON.stringify(packageConfigs), 'utf8');
|
|
146
|
-
console.log(`[${prefix}]:`, `version ${version} created!`);
|
|
147
|
-
});
|
|
148
|
-
},
|
|
149
|
-
async loadContent() {
|
|
150
|
-
const versionsMetadataList = await versionsMetadata;
|
|
151
|
-
return {
|
|
152
|
-
loadedVersions: await Promise.all(versionsMetadataList.map(async metadata => {
|
|
153
|
-
let packages = [];
|
|
154
|
-
|
|
155
|
-
// Current data needs to be generated on demand
|
|
156
|
-
if (metadata.versionName === server.CURRENT_VERSION_NAME) {
|
|
157
|
-
const outFile = path__default.default.join(context.generatedFilesDir, `api-typedoc-${pluginId}.json`);
|
|
158
|
-
if (!fs__default.default.existsSync(context.generatedFilesDir)) {
|
|
159
|
-
fs__default.default.mkdirSync(context.generatedFilesDir, {
|
|
160
|
-
recursive: true
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
await data.generateJson(projectRoot, entryPoints, outFile, options, context);
|
|
164
|
-
packages = data.flattenAndGroupPackages(packageConfigs, await importFile(outFile), metadata.versionPath, options, context);
|
|
165
|
-
|
|
166
|
-
// Versioned data is stored in the file system
|
|
167
|
-
} else {
|
|
168
|
-
const outDir = path__default.default.join(versionsDocsDir, `version-${metadata.versionName}`);
|
|
169
|
-
packages = data.flattenAndGroupPackages(await importFile(path__default.default.join(outDir, 'api-packages.json')), await importFile(path__default.default.join(outDir, 'api-typedoc.json')), metadata.versionPath, options, context, true);
|
|
170
|
-
}
|
|
171
|
-
packages.sort((a, d) => options.sortPackages(a, d));
|
|
172
|
-
|
|
173
|
-
// Generate sidebars (this runs before the main sidebar is loaded)
|
|
174
|
-
const sidebars = sidebar.extractSidebar(packages, removeScopes, changelogs, options.sortSidebar);
|
|
175
|
-
await fs__default.default.promises.writeFile(path__default.default.join(context.generatedFilesDir, `api-sidebar-${pluginId}-${metadata.versionName}.js`), `module.exports = ${JSON.stringify(sidebars, null, 2)};`);
|
|
176
|
-
await fs__default.default.promises.writeFile(path__default.default.join(context.generatedFilesDir, `api-sidebar-${pluginId}-${metadata.versionName}.d.ts`), `import type { SidebarConfig } from '@docusaurus/plugin-content-docs';\nexport = Array<SidebarConfig>;`);
|
|
177
|
-
return _objectSpread(_objectSpread({}, metadata), {}, {
|
|
178
|
-
packages,
|
|
179
|
-
sidebars
|
|
180
|
-
});
|
|
181
|
-
}))
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
async contentLoaded({
|
|
185
|
-
content,
|
|
186
|
-
actions
|
|
187
|
-
}) {
|
|
188
|
-
if (!content) {
|
|
189
|
-
return;
|
|
190
|
-
}
|
|
191
|
-
actions.setGlobalData({
|
|
192
|
-
isPython: !!(options.python || Object.keys(options.pythonOptions).length > 0)
|
|
193
|
-
});
|
|
194
|
-
const docs = {};
|
|
195
|
-
|
|
196
|
-
// Create an index of versions for quick lookups.
|
|
197
|
-
// This is hacky, but it works, so shrug.
|
|
198
|
-
content.loadedVersions.forEach(loadedVersion => {
|
|
199
|
-
if (loadedVersion.versionName !== server.CURRENT_VERSION_NAME) {
|
|
200
|
-
docs[loadedVersion.versionName] = {
|
|
201
|
-
id: loadedVersion.versionPath,
|
|
202
|
-
title: loadedVersion.versionLabel,
|
|
203
|
-
description: loadedVersion.versionLabel
|
|
204
|
-
};
|
|
68
|
+
const isDefaultPluginId = pluginId === DEFAULT_PLUGIN_ID;
|
|
69
|
+
const versionsMetadata = readVersionsMetadata(context, options);
|
|
70
|
+
const versionsDocsDir = getVersionedDocsDirPath(context.siteDir, pluginId);
|
|
71
|
+
// Determine entry points from configs
|
|
72
|
+
const entryPoints = [];
|
|
73
|
+
const packageConfigs = options.packages.map((pkgItem) => {
|
|
74
|
+
var _a;
|
|
75
|
+
const pkgConfig = typeof pkgItem === 'string' ? { path: pkgItem } : pkgItem;
|
|
76
|
+
const entries = {};
|
|
77
|
+
if (!pkgConfig.entry || typeof pkgConfig.entry === 'string') {
|
|
78
|
+
entries.index = {
|
|
79
|
+
label: 'Index',
|
|
80
|
+
path: pkgConfig.entry ? String(pkgConfig.entry) : 'src/index.ts',
|
|
81
|
+
};
|
|
205
82
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
className: loadedVersion.versionClassName,
|
|
217
|
-
docs,
|
|
218
|
-
docsSidebars: {
|
|
219
|
-
api: loadedVersion.sidebars
|
|
220
|
-
},
|
|
221
|
-
isLast: loadedVersion.isLast,
|
|
222
|
-
label: loadedVersion.versionLabel,
|
|
223
|
-
noIndex: false,
|
|
224
|
-
pluginId,
|
|
225
|
-
version: loadedVersion.versionName
|
|
226
|
-
}));
|
|
227
|
-
const packagesData = await actions.createData(`packages-${version}.json`, JSON.stringify(data.formatPackagesWithoutHostInfo(loadedVersion.packages)));
|
|
228
|
-
const optionsData = await actions.createData('options.json', JSON.stringify({
|
|
229
|
-
banner,
|
|
230
|
-
breadcrumbs,
|
|
231
|
-
gitRefName,
|
|
232
|
-
minimal,
|
|
233
|
-
pluginId,
|
|
234
|
-
scopes: removeScopes
|
|
235
|
-
}));
|
|
236
|
-
function createRoute(info, modules) {
|
|
237
|
-
return {
|
|
238
|
-
path: info.permalink,
|
|
239
|
-
exact: true,
|
|
240
|
-
component: path__default.default.join(__dirname, `./components/ApiItem.${process.env.TYPEDOC_PLUGIN_DEV ? 'tsx' : 'js'}`),
|
|
241
|
-
modules,
|
|
242
|
-
sidebar: 'api',
|
|
243
|
-
// Map the ID here instead of creating a JSON data file,
|
|
244
|
-
// otherwise this will create thousands of files!
|
|
245
|
-
id: info.id
|
|
246
|
-
};
|
|
83
|
+
else {
|
|
84
|
+
Object.entries(pkgConfig.entry).forEach(([importPath, entryConfig]) => {
|
|
85
|
+
entries[importPath] =
|
|
86
|
+
typeof entryConfig === 'string'
|
|
87
|
+
? {
|
|
88
|
+
label: 'Index',
|
|
89
|
+
path: entryConfig,
|
|
90
|
+
}
|
|
91
|
+
: entryConfig;
|
|
92
|
+
});
|
|
247
93
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
pkg.entryPoints.forEach(entry => {
|
|
251
|
-
const children = entry.reflection.children?.filter(child => !child.permalink?.includes('#')) ?? [];
|
|
252
|
-
|
|
253
|
-
// Map a route for every declaration in the package (the exported APIs)
|
|
254
|
-
const subRoutes = children.map(child => createRoute(child));
|
|
255
|
-
|
|
256
|
-
// Map a top-level package route, otherwise `DocRoot` shows a page not found
|
|
257
|
-
subRoutes.push(createRoute(entry.reflection, entry.index && readmes && pkg.readmePath ? {
|
|
258
|
-
readme: pkg.readmePath
|
|
259
|
-
} : undefined));
|
|
260
|
-
if (entry.index && changelogs && pkg.changelogPath) {
|
|
261
|
-
subRoutes.push({
|
|
262
|
-
path: utils.normalizeUrl([entry.reflection.permalink, 'changelog']),
|
|
263
|
-
exact: true,
|
|
264
|
-
component: path__default.default.join(__dirname, './components/ApiChangelog.js'),
|
|
265
|
-
modules: {
|
|
266
|
-
changelog: pkg.changelogPath
|
|
267
|
-
},
|
|
268
|
-
sidebar: 'api'
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
routes.push(...subRoutes);
|
|
272
|
-
});
|
|
94
|
+
Object.values(entries).forEach((entryConfig) => {
|
|
95
|
+
entryPoints.push(path.join(pkgConfig.path, entryConfig.path));
|
|
273
96
|
});
|
|
274
|
-
const
|
|
275
|
-
if (
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
path: indexPermalink,
|
|
280
|
-
exact: true,
|
|
281
|
-
component: path__default.default.join(__dirname, './components/ApiIndex.js'),
|
|
282
|
-
modules: {
|
|
283
|
-
options: optionsData,
|
|
284
|
-
packages: packagesData,
|
|
285
|
-
versionMetadata
|
|
286
|
-
},
|
|
287
|
-
sidebar: 'api'
|
|
288
|
-
});
|
|
97
|
+
const { siteDir } = context;
|
|
98
|
+
if (projectRoot && path.isAbsolute(projectRoot)) {
|
|
99
|
+
console.warn(`[${PLUGIN_NAME}]:`, `projectRoot is an absolute path. This could cause issues with reproducibility
|
|
100
|
+
under different environments. Internally, this will be stored as a relative path from (${siteDir}).`);
|
|
101
|
+
projectRoot = path.relative(siteDir, projectRoot);
|
|
289
102
|
}
|
|
290
|
-
|
|
291
|
-
// Wrap in the `DocVersionRoot` component:
|
|
292
|
-
// https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-content-docs/src/routes.ts#L192
|
|
293
103
|
return {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
routes,
|
|
302
|
-
modules: {
|
|
303
|
-
options: optionsData,
|
|
304
|
-
packages: packagesData
|
|
305
|
-
}
|
|
306
|
-
}],
|
|
307
|
-
modules: {
|
|
308
|
-
version: versionMetadata
|
|
309
|
-
},
|
|
310
|
-
priority: loadedVersion.routePriority
|
|
104
|
+
entryPoints: entries,
|
|
105
|
+
packageRoot: path.normalize(path.join(projectRoot, pkgConfig.path || '.')),
|
|
106
|
+
packagePath: pkgConfig.path || '.',
|
|
107
|
+
packageSlug: (_a = pkgConfig.slug) !== null && _a !== void 0 ? _a : path.basename(pkgConfig.path),
|
|
108
|
+
// Load later on
|
|
109
|
+
packageName: '',
|
|
110
|
+
packageVersion: '',
|
|
311
111
|
};
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
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
|
-
|
|
112
|
+
});
|
|
113
|
+
return {
|
|
114
|
+
name: PLUGIN_NAME,
|
|
115
|
+
extendCli(cli) {
|
|
116
|
+
const command = isDefaultPluginId ? 'api:version' : `api:version:${pluginId}`;
|
|
117
|
+
const commandDescription = isDefaultPluginId
|
|
118
|
+
? 'Tag a new API version'
|
|
119
|
+
: `Tag a new API version (${pluginId})`;
|
|
120
|
+
cli
|
|
121
|
+
.command(command)
|
|
122
|
+
.arguments('<version>')
|
|
123
|
+
.description(commandDescription)
|
|
124
|
+
.action((version) => __awaiter(this, void 0, void 0, function* () {
|
|
125
|
+
const outDir = path.join(versionsDocsDir, `version-${version}`);
|
|
126
|
+
const prefix = isDefaultPluginId ? 'api' : pluginId;
|
|
127
|
+
console.log(`[${prefix}]:`, 'Generating docs...');
|
|
128
|
+
if (path.isAbsolute(projectRoot)) {
|
|
129
|
+
console.debug(`[${PLUGIN_NAME}]:`, `projectRoot should be a relative path, not an absolute path.
|
|
130
|
+
Overwriting with relative path from siteDir (${context.siteDir}).`);
|
|
131
|
+
projectRoot = path.relative(context.siteDir, projectRoot);
|
|
132
|
+
}
|
|
133
|
+
yield generateJson(projectRoot, entryPoints, path.join(outDir, 'api-typedoc.json'), options, context);
|
|
134
|
+
console.log(`[${prefix}]:`, 'Persisting packages...');
|
|
135
|
+
// Load info from `package.json`s
|
|
136
|
+
packageConfigs.forEach((cfg) => {
|
|
137
|
+
const { packageJson } = loadPackageJsonAndDocs(path.join(options.projectRoot, cfg.packagePath), options.packageJsonName, options.readmeName, options.changelogName);
|
|
138
|
+
cfg.packageName = packageJson.name;
|
|
139
|
+
cfg.packageVersion = packageJson.version;
|
|
140
|
+
});
|
|
141
|
+
yield fs.promises.writeFile(path.join(outDir, 'api-packages.json'), JSON.stringify(packageConfigs), 'utf8');
|
|
142
|
+
console.log(`[${prefix}]:`, `version ${version} created!`);
|
|
143
|
+
}));
|
|
144
|
+
},
|
|
145
|
+
loadContent() {
|
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
const versionsMetadataList = yield versionsMetadata;
|
|
148
|
+
return {
|
|
149
|
+
loadedVersions: yield Promise.all(versionsMetadataList.map((metadata) => __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
let packages = [];
|
|
151
|
+
// Current data needs to be generated on demand
|
|
152
|
+
if (metadata.versionName === CURRENT_VERSION_NAME) {
|
|
153
|
+
const outFile = path.join(context.generatedFilesDir, `api-typedoc-${pluginId}.json`);
|
|
154
|
+
if (!fs.existsSync(context.generatedFilesDir)) {
|
|
155
|
+
fs.mkdirSync(context.generatedFilesDir, { recursive: true });
|
|
156
|
+
}
|
|
157
|
+
yield generateJson(projectRoot, entryPoints, outFile, options, context);
|
|
158
|
+
packages = flattenAndGroupPackages(packageConfigs, yield importFile(outFile), metadata.versionPath, options, context);
|
|
159
|
+
// Versioned data is stored in the file system
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
const outDir = path.join(versionsDocsDir, `version-${metadata.versionName}`);
|
|
163
|
+
packages = flattenAndGroupPackages(yield importFile(path.join(outDir, 'api-packages.json')), yield importFile(path.join(outDir, 'api-typedoc.json')), metadata.versionPath, options, context, true);
|
|
164
|
+
}
|
|
165
|
+
packages.sort((a, d) => options.sortPackages(a, d));
|
|
166
|
+
// Generate sidebars (this runs before the main sidebar is loaded)
|
|
167
|
+
const sidebars = extractSidebar(packages, removeScopes, changelogs, options.sortSidebar);
|
|
168
|
+
yield fs.promises.writeFile(path.join(context.generatedFilesDir, `api-sidebar-${pluginId}-${metadata.versionName}.js`), `module.exports = ${JSON.stringify(sidebars, null, 2)};`);
|
|
169
|
+
yield fs.promises.writeFile(path.join(context.generatedFilesDir, `api-sidebar-${pluginId}-${metadata.versionName}.d.ts`), `import type { SidebarConfig } from '@docusaurus/plugin-content-docs';\nexport = Array<SidebarConfig>;`);
|
|
170
|
+
return Object.assign(Object.assign({}, metadata), { packages,
|
|
171
|
+
sidebars });
|
|
172
|
+
}))),
|
|
173
|
+
};
|
|
174
|
+
});
|
|
175
|
+
},
|
|
176
|
+
contentLoaded(_a) {
|
|
177
|
+
return __awaiter(this, arguments, void 0, function* ({ content, actions }) {
|
|
178
|
+
var _b;
|
|
179
|
+
if (!content) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
actions.setGlobalData({
|
|
183
|
+
isPython: !!(options.python || (Object.keys(options.pythonOptions).length > 0)),
|
|
184
|
+
});
|
|
185
|
+
const docs = {};
|
|
186
|
+
// Create an index of versions for quick lookups.
|
|
187
|
+
// This is hacky, but it works, so shrug.
|
|
188
|
+
content.loadedVersions.forEach((loadedVersion) => {
|
|
189
|
+
if (loadedVersion.versionName !== CURRENT_VERSION_NAME) {
|
|
190
|
+
docs[loadedVersion.versionName] = {
|
|
191
|
+
id: loadedVersion.versionPath,
|
|
192
|
+
title: loadedVersion.versionLabel,
|
|
193
|
+
description: loadedVersion.versionLabel,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
const rootRoutes = yield Promise.all(content.loadedVersions.map((loadedVersion) => __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
const version = loadedVersion.versionName;
|
|
199
|
+
// Define version metadata for all pages. We need to use the same structure as
|
|
200
|
+
// "docs" so that we can utilize the same React components.
|
|
201
|
+
// https://github.com/facebook/docusaurus/blob/master/packages/docusaurus-plugin-content-docs/src/index.ts#L337
|
|
202
|
+
const versionMetadata = yield actions.createData(`version-${version}.json`, JSON.stringify({
|
|
203
|
+
badge: loadedVersion.versionBadge,
|
|
204
|
+
banner: loadedVersion.versionBanner,
|
|
205
|
+
className: loadedVersion.versionClassName,
|
|
206
|
+
docs,
|
|
207
|
+
docsSidebars: { api: loadedVersion.sidebars },
|
|
208
|
+
isLast: loadedVersion.isLast,
|
|
209
|
+
label: loadedVersion.versionLabel,
|
|
210
|
+
noIndex: false,
|
|
211
|
+
pluginId,
|
|
212
|
+
version: loadedVersion.versionName,
|
|
213
|
+
}));
|
|
214
|
+
const packagesData = yield actions.createData(`packages-${version}.json`, JSON.stringify(formatPackagesWithoutHostInfo(loadedVersion.packages)));
|
|
215
|
+
const optionsData = yield actions.createData('options.json', JSON.stringify({
|
|
216
|
+
banner,
|
|
217
|
+
breadcrumbs,
|
|
218
|
+
gitRefName,
|
|
219
|
+
minimal,
|
|
220
|
+
pluginId,
|
|
221
|
+
scopes: removeScopes,
|
|
222
|
+
}));
|
|
223
|
+
function createRoute(info, modules) {
|
|
224
|
+
return {
|
|
225
|
+
path: info.permalink,
|
|
226
|
+
exact: true,
|
|
227
|
+
component: path.join(__dirname, `./components/ApiItem.${process.env.TYPEDOC_PLUGIN_DEV ? 'tsx' : 'js'}`),
|
|
228
|
+
modules,
|
|
229
|
+
sidebar: 'api',
|
|
230
|
+
// Map the ID here instead of creating a JSON data file,
|
|
231
|
+
// otherwise this will create thousands of files!
|
|
232
|
+
id: info.id,
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
const routes = [];
|
|
236
|
+
loadedVersion.packages.forEach((pkg) => {
|
|
237
|
+
pkg.entryPoints.forEach((entry) => {
|
|
238
|
+
var _a, _b;
|
|
239
|
+
const children = (_b = (_a = entry.reflection.children) === null || _a === void 0 ? void 0 : _a.filter((child) => { var _a; return !((_a = child.permalink) === null || _a === void 0 ? void 0 : _a.includes('#')); })) !== null && _b !== void 0 ? _b : [];
|
|
240
|
+
// Map a route for every declaration in the package (the exported APIs)
|
|
241
|
+
const subRoutes = children.map((child) => createRoute(child));
|
|
242
|
+
// Map a top-level package route, otherwise `DocRoot` shows a page not found
|
|
243
|
+
subRoutes.push(createRoute(entry.reflection, entry.index && readmes && pkg.readmePath ? { readme: pkg.readmePath } : undefined));
|
|
244
|
+
if (entry.index && changelogs && pkg.changelogPath) {
|
|
245
|
+
subRoutes.push({
|
|
246
|
+
path: normalizeUrl([entry.reflection.permalink, 'changelog']),
|
|
247
|
+
exact: true,
|
|
248
|
+
component: path.join(__dirname, './components/ApiChangelog.js'),
|
|
249
|
+
modules: { changelog: pkg.changelogPath },
|
|
250
|
+
sidebar: 'api',
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
routes.push(...subRoutes);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
const indexPermalink = normalizeUrl([loadedVersion.versionPath]);
|
|
257
|
+
if (loadedVersion.packages.length > 1) {
|
|
258
|
+
// Only write out the ApiIndex only when we have multiple packages
|
|
259
|
+
// otherwise we will have 2 top-level entries in the route entries
|
|
260
|
+
routes.push({
|
|
261
|
+
path: indexPermalink,
|
|
262
|
+
exact: true,
|
|
263
|
+
component: path.join(__dirname, './components/ApiIndex.js'),
|
|
264
|
+
modules: {
|
|
265
|
+
options: optionsData,
|
|
266
|
+
packages: packagesData,
|
|
267
|
+
versionMetadata,
|
|
268
|
+
},
|
|
269
|
+
sidebar: 'api',
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
// Wrap in the `DocVersionRoot` component:
|
|
273
|
+
// https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-content-docs/src/routes.ts#L192
|
|
274
|
+
return {
|
|
275
|
+
path: indexPermalink,
|
|
276
|
+
exact: false,
|
|
277
|
+
component: '@theme/DocVersionRoot',
|
|
278
|
+
routes: [
|
|
279
|
+
{
|
|
280
|
+
path: indexPermalink,
|
|
281
|
+
exact: false,
|
|
282
|
+
component: path.join(__dirname, `./components/ApiPage.${process.env.TYPEDOC_PLUGIN_DEV ? 'tsx' : 'js'}`),
|
|
283
|
+
routes,
|
|
284
|
+
modules: {
|
|
285
|
+
options: optionsData,
|
|
286
|
+
packages: packagesData,
|
|
287
|
+
},
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
modules: {
|
|
291
|
+
version: versionMetadata,
|
|
292
|
+
},
|
|
293
|
+
priority: loadedVersion.routePriority,
|
|
294
|
+
};
|
|
295
|
+
})));
|
|
296
|
+
// Wrap in the `DocsRoot` component:
|
|
297
|
+
// https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-plugin-content-docs/src/routes.ts#L232
|
|
298
|
+
actions.addRoute({
|
|
299
|
+
path: normalizeUrl([context.baseUrl, (_b = options.routeBasePath) !== null && _b !== void 0 ? _b : 'api']),
|
|
300
|
+
exact: false,
|
|
301
|
+
component: '@theme/DocsRoot',
|
|
302
|
+
routes: rootRoutes,
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
},
|
|
306
|
+
getPathsToWatch() {
|
|
307
|
+
return process.env.TYPEDOC_PLUGIN_DEV ? [__dirname] : [];
|
|
308
|
+
},
|
|
309
|
+
configureWebpack(config, isServer, utils) {
|
|
310
|
+
if (!readmes && !changelogs) {
|
|
311
|
+
return {};
|
|
312
|
+
}
|
|
313
|
+
// Whitelist the folders that this webpack rule applies to, otherwise we collide with the native
|
|
314
|
+
// docs/blog plugins. We need to include the specific files only, as in polyrepo mode, the `cfg.packagePath`
|
|
315
|
+
// can be project root (where the regular docs are too).
|
|
316
|
+
const include = packageConfigs.flatMap((cfg) => {
|
|
317
|
+
const list = [];
|
|
318
|
+
if (readmes) {
|
|
319
|
+
list.push(path.join(options.projectRoot, cfg.packagePath, options.readmeName));
|
|
320
|
+
}
|
|
321
|
+
if (changelogs) {
|
|
322
|
+
list.push(path.join(options.projectRoot, cfg.packagePath, options.changelogName));
|
|
323
|
+
}
|
|
324
|
+
return list;
|
|
325
|
+
});
|
|
326
|
+
return {
|
|
327
|
+
module: {
|
|
328
|
+
rules: [
|
|
329
|
+
{
|
|
330
|
+
test: /\.mdx?$/,
|
|
331
|
+
include,
|
|
332
|
+
use: [
|
|
333
|
+
utils.getJSLoader({ isServer }),
|
|
334
|
+
{
|
|
335
|
+
loader: require.resolve('@docusaurus/mdx-loader'),
|
|
336
|
+
options: {
|
|
337
|
+
admonitions: true,
|
|
338
|
+
remarkPlugins: options.remarkPlugins,
|
|
339
|
+
rehypePlugins: options.rehypePlugins,
|
|
340
|
+
siteDir: context.siteDir,
|
|
341
|
+
staticDirs: [
|
|
342
|
+
...context.siteConfig.staticDirectories,
|
|
343
|
+
path.join(context.siteDir, 'static'),
|
|
344
|
+
],
|
|
345
|
+
// Since this isn't a doc/blog page, we can get
|
|
346
|
+
// away with it being a partial!
|
|
347
|
+
isMDXPartial: () => true,
|
|
348
|
+
markdownConfig: context.siteConfig.markdown,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
loader: path.resolve(__dirname, './markdownLoader.js'),
|
|
353
|
+
},
|
|
354
|
+
],
|
|
355
|
+
},
|
|
356
|
+
],
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
},
|
|
360
|
+
};
|
|
372
361
|
}
|
|
373
|
-
|
|
374
|
-
//# sourceMappingURL=index.js.map
|
|
362
|
+
//# sourceMappingURL=index.js.map
|