@azerion/bunosaurus-plugin-content-docs 0.0.0-stage → 4.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.
Files changed (119) hide show
  1. package/README.md +6 -2
  2. package/lib/categoryGeneratedIndex.d.ts +12 -0
  3. package/lib/categoryGeneratedIndex.js +36 -0
  4. package/lib/cli.d.ts +13 -0
  5. package/lib/cli.js +124 -0
  6. package/lib/client/doc.d.ts +29 -0
  7. package/lib/client/doc.js +47 -0
  8. package/lib/client/docSidebarItemsExpandedState.d.ts +30 -0
  9. package/lib/client/docSidebarItemsExpandedState.js +27 -0
  10. package/lib/client/docsClientUtils.d.ts +15 -0
  11. package/lib/client/docsClientUtils.js +86 -0
  12. package/lib/client/docsPreferredVersion.d.ts +29 -0
  13. package/lib/client/docsPreferredVersion.js +124 -0
  14. package/lib/client/docsSearch.d.ts +19 -0
  15. package/lib/client/docsSearch.js +39 -0
  16. package/lib/client/docsSidebar.d.ts +25 -0
  17. package/lib/client/docsSidebar.js +29 -0
  18. package/lib/client/docsUtils.d.ts +112 -0
  19. package/lib/client/docsUtils.js +299 -0
  20. package/lib/client/docsVersion.d.ts +19 -0
  21. package/lib/client/docsVersion.js +25 -0
  22. package/lib/client/index.d.ts +91 -0
  23. package/lib/client/index.js +83 -0
  24. package/lib/client/structuredDataUtils.d.ts +11 -0
  25. package/lib/client/structuredDataUtils.js +35 -0
  26. package/lib/constants.d.ts +14 -0
  27. package/lib/constants.js +17 -0
  28. package/lib/contentHelpers.d.ts +12 -0
  29. package/lib/contentHelpers.js +31 -0
  30. package/lib/docs.d.ts +48 -0
  31. package/lib/docs.js +252 -0
  32. package/lib/frontMatter.d.ts +10 -0
  33. package/lib/frontMatter.js +46 -0
  34. package/lib/globalData.d.ts +9 -0
  35. package/lib/globalData.js +59 -0
  36. package/lib/index.d.ts +10 -0
  37. package/lib/index.js +198 -0
  38. package/lib/numberPrefix.d.ts +11 -0
  39. package/lib/numberPrefix.js +50 -0
  40. package/lib/options.d.ts +10 -0
  41. package/lib/options.js +138 -0
  42. package/lib/props.d.ts +21 -0
  43. package/lib/props.js +156 -0
  44. package/lib/routes.d.ts +22 -0
  45. package/lib/routes.js +184 -0
  46. package/lib/server-export.d.ts +9 -0
  47. package/lib/server-export.js +25 -0
  48. package/lib/sidebars/generator.d.ts +10 -0
  49. package/lib/sidebars/generator.js +217 -0
  50. package/lib/sidebars/index.d.ts +13 -0
  51. package/lib/sidebars/index.js +99 -0
  52. package/lib/sidebars/normalization.d.ts +13 -0
  53. package/lib/sidebars/normalization.js +58 -0
  54. package/lib/sidebars/postProcessor.d.ts +11 -0
  55. package/lib/sidebars/postProcessor.js +82 -0
  56. package/lib/sidebars/processor.d.ts +10 -0
  57. package/lib/sidebars/processor.js +77 -0
  58. package/lib/sidebars/types.d.ts +192 -0
  59. package/lib/sidebars/types.js +8 -0
  60. package/lib/sidebars/utils.d.ts +69 -0
  61. package/lib/sidebars/utils.js +327 -0
  62. package/lib/sidebars/validation.d.ts +11 -0
  63. package/lib/sidebars/validation.js +152 -0
  64. package/lib/slug.d.ts +15 -0
  65. package/lib/slug.js +51 -0
  66. package/lib/translations.d.ts +10 -0
  67. package/lib/translations.js +243 -0
  68. package/lib/types.d.ts +27 -0
  69. package/lib/types.js +8 -0
  70. package/lib/versions/files.d.ts +54 -0
  71. package/lib/versions/files.js +152 -0
  72. package/lib/versions/loadVersion.d.ts +17 -0
  73. package/lib/versions/loadVersion.js +126 -0
  74. package/lib/versions/validation.d.ts +17 -0
  75. package/lib/versions/validation.js +70 -0
  76. package/lib/versions/version.d.ts +40 -0
  77. package/lib/versions/version.js +189 -0
  78. package/package.json +70 -4
  79. package/src/categoryGeneratedIndex.ts +60 -0
  80. package/src/cli.ts +180 -0
  81. package/src/client/doc.tsx +71 -0
  82. package/src/client/docSidebarItemsExpandedState.tsx +55 -0
  83. package/src/client/docsClientUtils.ts +140 -0
  84. package/src/client/docsPreferredVersion.tsx +245 -0
  85. package/src/client/docsSearch.test.ts +15 -0
  86. package/src/client/docsSearch.ts +57 -0
  87. package/src/client/docsSidebar.tsx +50 -0
  88. package/src/client/docsUtils.tsx +442 -0
  89. package/src/client/docsVersion.tsx +36 -0
  90. package/src/client/index.ts +211 -0
  91. package/src/client/structuredDataUtils.ts +54 -0
  92. package/src/constants.ts +15 -0
  93. package/src/contentHelpers.ts +34 -0
  94. package/src/docs.ts +402 -0
  95. package/src/frontMatter.ts +57 -0
  96. package/src/globalData.ts +79 -0
  97. package/src/index.ts +289 -0
  98. package/src/numberPrefix.ts +62 -0
  99. package/src/options.ts +185 -0
  100. package/src/plugin-content-docs.d.ts +667 -0
  101. package/src/props.ts +223 -0
  102. package/src/routes.ts +263 -0
  103. package/src/server-export.ts +26 -0
  104. package/src/sidebars/README.md +10 -0
  105. package/src/sidebars/generator.ts +307 -0
  106. package/src/sidebars/index.ts +130 -0
  107. package/src/sidebars/normalization.ts +91 -0
  108. package/src/sidebars/postProcessor.ts +115 -0
  109. package/src/sidebars/processor.ts +122 -0
  110. package/src/sidebars/types.ts +293 -0
  111. package/src/sidebars/utils.ts +529 -0
  112. package/src/sidebars/validation.ts +189 -0
  113. package/src/slug.ts +79 -0
  114. package/src/translations.ts +365 -0
  115. package/src/types.ts +34 -0
  116. package/src/versions/files.ts +240 -0
  117. package/src/versions/loadVersion.ts +185 -0
  118. package/src/versions/validation.ts +115 -0
  119. package/src/versions/version.ts +300 -0
package/src/props.ts ADDED
@@ -0,0 +1,223 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import _ from 'lodash';
9
+ import {createDocsByIdIndex} from './docs';
10
+ import type {VersionTag, VersionTags} from './types';
11
+ import type {
12
+ SidebarItemDoc,
13
+ SidebarItem,
14
+ SidebarItemCategory,
15
+ SidebarItemCategoryLink,
16
+ } from './sidebars/types';
17
+ import type {
18
+ PropSidebars,
19
+ PropVersionMetadata,
20
+ PropSidebarItem,
21
+ PropSidebarItemCategory,
22
+ PropTagDocList,
23
+ PropTagDocListDoc,
24
+ PropTagsListPage,
25
+ PropSidebarItemLink,
26
+ PropVersionDocs,
27
+ DocMetadata,
28
+ LoadedVersion,
29
+ } from '@docusaurus/plugin-content-docs';
30
+
31
+ export function toSidebarDocItemLinkProp({
32
+ item,
33
+ doc,
34
+ }: {
35
+ item: SidebarItemDoc;
36
+ doc: Pick<
37
+ DocMetadata,
38
+ 'id' | 'title' | 'permalink' | 'unlisted' | 'frontMatter'
39
+ >;
40
+ }): PropSidebarItemLink {
41
+ const {id, title, permalink, frontMatter, unlisted} = doc;
42
+ return {
43
+ type: 'link',
44
+ ...(item.key && {key: item.key}),
45
+ href: permalink,
46
+ // Front Matter data takes precedence over sidebars.json
47
+ label: frontMatter.sidebar_label ?? item.label ?? title,
48
+ className: frontMatter.sidebar_class_name ?? item.className,
49
+ customProps: frontMatter.sidebar_custom_props ?? item.customProps,
50
+ docId: id,
51
+ unlisted,
52
+ };
53
+ }
54
+
55
+ export function toSidebarsProp(
56
+ loadedVersion: Pick<LoadedVersion, 'docs' | 'sidebars'>,
57
+ ): PropSidebars {
58
+ const docsById = createDocsByIdIndex(loadedVersion.docs);
59
+
60
+ function getDocById(docId: string): DocMetadata {
61
+ const docMetadata = docsById[docId];
62
+ if (!docMetadata) {
63
+ throw new Error(
64
+ `Invalid sidebars file. The document with id "${docId}" was used in the sidebar, but no document with this id could be found.
65
+ Available document ids are:
66
+ - ${Object.keys(docsById).sort().join('\n- ')}`,
67
+ );
68
+ }
69
+ return docMetadata;
70
+ }
71
+
72
+ const convertDocLink = (item: SidebarItemDoc): PropSidebarItemLink => {
73
+ const doc = getDocById(item.id);
74
+ return toSidebarDocItemLinkProp({item, doc});
75
+ };
76
+
77
+ function getCategoryLinkHref(
78
+ link: SidebarItemCategoryLink | undefined,
79
+ ): string | undefined {
80
+ switch (link?.type) {
81
+ case 'doc':
82
+ return getDocById(link.id).permalink;
83
+ case 'generated-index':
84
+ return link.permalink;
85
+ default:
86
+ return undefined;
87
+ }
88
+ }
89
+
90
+ function getCategoryLinkUnlisted(
91
+ link: SidebarItemCategoryLink | undefined,
92
+ ): boolean {
93
+ if (link?.type === 'doc') {
94
+ return getDocById(link.id).unlisted;
95
+ }
96
+ return false;
97
+ }
98
+
99
+ function getCategoryLinkCustomProps(
100
+ link: SidebarItemCategoryLink | undefined,
101
+ ) {
102
+ switch (link?.type) {
103
+ case 'doc':
104
+ return getDocById(link.id).frontMatter.sidebar_custom_props;
105
+ default:
106
+ return undefined;
107
+ }
108
+ }
109
+
110
+ function convertCategory(item: SidebarItemCategory): PropSidebarItemCategory {
111
+ const {link, ...rest} = item;
112
+ const href = getCategoryLinkHref(link);
113
+ const linkUnlisted = getCategoryLinkUnlisted(link);
114
+ const customProps = item.customProps ?? getCategoryLinkCustomProps(link);
115
+
116
+ return {
117
+ ...rest,
118
+ items: item.items.map(normalizeItem),
119
+ ...(href && {href}),
120
+ ...(linkUnlisted && {linkUnlisted}),
121
+ ...(customProps && {customProps}),
122
+ };
123
+ }
124
+
125
+ function normalizeItem(item: SidebarItem): PropSidebarItem {
126
+ switch (item.type) {
127
+ case 'category':
128
+ return convertCategory(item);
129
+ case 'ref':
130
+ case 'doc':
131
+ return convertDocLink(item);
132
+ case 'link':
133
+ default:
134
+ return item;
135
+ }
136
+ }
137
+
138
+ // Transform the sidebar so that all sidebar item will be in the
139
+ // form of 'link' or 'category' only.
140
+ // This is what will be passed as props to the UI component.
141
+ return _.mapValues(loadedVersion.sidebars, (items) =>
142
+ items.map(normalizeItem),
143
+ );
144
+ }
145
+
146
+ function toVersionDocsProp(loadedVersion: LoadedVersion): PropVersionDocs {
147
+ return Object.fromEntries(
148
+ loadedVersion.docs.map((doc) => [
149
+ doc.id,
150
+ {
151
+ id: doc.id,
152
+ title: doc.title,
153
+ description: doc.description,
154
+ sidebar: doc.sidebar,
155
+ },
156
+ ]),
157
+ );
158
+ }
159
+
160
+ export function toVersionMetadataProp(
161
+ pluginId: string,
162
+ loadedVersion: LoadedVersion,
163
+ ): PropVersionMetadata {
164
+ return {
165
+ pluginId,
166
+ version: loadedVersion.versionName,
167
+ label: loadedVersion.label,
168
+ banner: loadedVersion.banner,
169
+ badge: loadedVersion.badge,
170
+ noIndex: loadedVersion.noIndex,
171
+ className: loadedVersion.className,
172
+ isLast: loadedVersion.isLast,
173
+ docsSidebars: toSidebarsProp(loadedVersion),
174
+ docs: toVersionDocsProp(loadedVersion),
175
+ };
176
+ }
177
+
178
+ export function toTagDocListProp({
179
+ allTagsPath,
180
+ tag,
181
+ docs,
182
+ }: {
183
+ allTagsPath: string;
184
+ tag: VersionTag;
185
+ docs: DocMetadata[];
186
+ }): PropTagDocList {
187
+ function toDocListProp(): PropTagDocListDoc[] {
188
+ const list = _.compact(
189
+ tag.docIds.map((id) => docs.find((doc) => doc.id === id)),
190
+ );
191
+ // Sort docs by title
192
+ list.sort((doc1, doc2) => doc1.title.localeCompare(doc2.title));
193
+ return list.map((doc) => ({
194
+ id: doc.id,
195
+ title: doc.title,
196
+ description: doc.description,
197
+ permalink: doc.permalink,
198
+ }));
199
+ }
200
+
201
+ return {
202
+ label: tag.label,
203
+ permalink: tag.permalink,
204
+ description: tag.description,
205
+ allTagsPath,
206
+ count: tag.docIds.length,
207
+ items: toDocListProp(),
208
+ unlisted: tag.unlisted,
209
+ };
210
+ }
211
+
212
+ export function toTagsListTagsProp(
213
+ versionTags: VersionTags,
214
+ ): PropTagsListPage['tags'] {
215
+ return Object.values(versionTags)
216
+ .filter((tagValue) => !tagValue.unlisted)
217
+ .map((tagValue) => ({
218
+ label: tagValue.label,
219
+ permalink: tagValue.permalink,
220
+ description: tagValue.description,
221
+ count: tagValue.docIds.length,
222
+ }));
223
+ }
package/src/routes.ts ADDED
@@ -0,0 +1,263 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import _ from 'lodash';
9
+ import logger from '@docusaurus/logger';
10
+ import {
11
+ docuHash,
12
+ normalizeUrl,
13
+ aliasedSitePathToRelativePath,
14
+ groupTaggedItems,
15
+ getTagVisibility,
16
+ } from '@docusaurus/utils';
17
+ import {
18
+ toTagDocListProp,
19
+ toTagsListTagsProp,
20
+ toVersionMetadataProp,
21
+ } from './props';
22
+ import type {
23
+ PluginContentLoadedActions,
24
+ RouteConfig,
25
+ RouteMetadata,
26
+ } from '@docusaurus/types';
27
+ import type {FullVersion, VersionTag, VersionTags} from './types';
28
+ import type {
29
+ CategoryGeneratedIndexMetadata,
30
+ DocMetadata,
31
+ PluginOptions,
32
+ } from '@docusaurus/plugin-content-docs';
33
+
34
+ function createDocRouteMetadata(docMeta: DocMetadata): RouteMetadata {
35
+ return {
36
+ sourceFilePath: aliasedSitePathToRelativePath(docMeta.source),
37
+ lastUpdatedAt: docMeta.lastUpdatedAt,
38
+ };
39
+ }
40
+
41
+ async function buildVersionCategoryGeneratedIndexRoutes({
42
+ version,
43
+ options,
44
+ }: BuildVersionRoutesParam): Promise<RouteConfig[]> {
45
+ async function buildCategoryGeneratedIndexRoute(
46
+ categoryGeneratedIndex: CategoryGeneratedIndexMetadata,
47
+ ): Promise<RouteConfig> {
48
+ return {
49
+ path: categoryGeneratedIndex.permalink,
50
+ component: options.docCategoryGeneratedIndexComponent,
51
+ exact: true,
52
+ props: {
53
+ categoryGeneratedIndex,
54
+ },
55
+ // Same as doc, this sidebar route attribute permits to associate this
56
+ // subpage to the given sidebar
57
+ ...(categoryGeneratedIndex.sidebar && {
58
+ sidebar: categoryGeneratedIndex.sidebar,
59
+ }),
60
+ };
61
+ }
62
+
63
+ return Promise.all(
64
+ version.categoryGeneratedIndices.map(buildCategoryGeneratedIndexRoute),
65
+ );
66
+ }
67
+
68
+ async function buildVersionDocRoutes({
69
+ version,
70
+ actions,
71
+ options,
72
+ }: BuildVersionRoutesParam): Promise<RouteConfig[]> {
73
+ return Promise.all(
74
+ version.docs.map(async (doc) => {
75
+ await actions.createData(
76
+ // Note that this created data path must be in sync with
77
+ // metadataPath provided to mdx-loader.
78
+ `${docuHash(doc.source)}.json`,
79
+ doc,
80
+ );
81
+
82
+ const docRoute: RouteConfig = {
83
+ path: doc.permalink,
84
+ component: options.docItemComponent,
85
+ exact: true,
86
+ modules: {
87
+ content: doc.source,
88
+ },
89
+ metadata: createDocRouteMetadata(doc),
90
+ // Because the parent (DocRoot) comp need to access it easily
91
+ // This permits to render the sidebar once without unmount/remount when
92
+ // navigating (and preserve sidebar state)
93
+ ...(doc.sidebar && {
94
+ sidebar: doc.sidebar,
95
+ }),
96
+ };
97
+
98
+ return docRoute;
99
+ }),
100
+ );
101
+ }
102
+
103
+ async function buildVersionSidebarRoute(param: BuildVersionRoutesParam) {
104
+ const [docRoutes, categoryGeneratedIndexRoutes] = await Promise.all([
105
+ buildVersionDocRoutes(param),
106
+ buildVersionCategoryGeneratedIndexRoutes(param),
107
+ ]);
108
+ const subRoutes = [...docRoutes, ...categoryGeneratedIndexRoutes];
109
+ return {
110
+ path: param.version.path,
111
+ exact: false,
112
+ component: param.options.docRootComponent,
113
+ routes: subRoutes,
114
+ };
115
+ }
116
+ function getVersionTags(docs: DocMetadata[]): VersionTags {
117
+ const groups = groupTaggedItems(docs, (doc) => doc.tags);
118
+ return _.mapValues(groups, ({tag, items: tagDocs}) => {
119
+ const tagVisibility = getTagVisibility({
120
+ items: tagDocs,
121
+ isUnlisted: (item) => item.unlisted,
122
+ });
123
+ return {
124
+ inline: tag.inline,
125
+ label: tag.label,
126
+ permalink: tag.permalink,
127
+ description: tag.description,
128
+ docIds: tagVisibility.listedItems.map((item) => item.id),
129
+ unlisted: tagVisibility.unlisted,
130
+ };
131
+ });
132
+ }
133
+
134
+ async function buildVersionTagsRoutes(
135
+ param: BuildVersionRoutesParam,
136
+ ): Promise<RouteConfig[]> {
137
+ const {version, options} = param;
138
+ const versionTags = getVersionTags(version.docs);
139
+
140
+ async function buildTagsListRoute(): Promise<RouteConfig | null> {
141
+ const tags = toTagsListTagsProp(versionTags);
142
+ // Don't create a tags list page if there's no tag
143
+ if (tags.length === 0) {
144
+ return null;
145
+ }
146
+ return {
147
+ path: version.tagsPath,
148
+ exact: true,
149
+ component: options.docTagsListComponent,
150
+ props: {
151
+ tags,
152
+ },
153
+ };
154
+ }
155
+
156
+ async function buildTagDocListRoute(tag: VersionTag): Promise<RouteConfig> {
157
+ return {
158
+ path: tag.permalink,
159
+ component: options.docTagDocListComponent,
160
+ exact: true,
161
+ props: {
162
+ tag: toTagDocListProp({
163
+ allTagsPath: version.tagsPath,
164
+ tag,
165
+ docs: version.docs,
166
+ }),
167
+ },
168
+ };
169
+ }
170
+
171
+ const [tagsListRoute, allTagsDocListRoutes] = await Promise.all([
172
+ buildTagsListRoute(),
173
+ Promise.all(Object.values(versionTags).map(buildTagDocListRoute)),
174
+ ]);
175
+
176
+ return _.compact([tagsListRoute, ...allTagsDocListRoutes]);
177
+ }
178
+
179
+ type BuildVersionRoutesParam = Omit<BuildAllRoutesParam, 'versions'> & {
180
+ version: FullVersion;
181
+ };
182
+
183
+ async function buildVersionRoutes(
184
+ param: BuildVersionRoutesParam,
185
+ ): Promise<RouteConfig> {
186
+ const {version, options} = param;
187
+
188
+ async function buildVersionSubRoutes() {
189
+ const [sidebarRoute, tagsRoutes] = await Promise.all([
190
+ buildVersionSidebarRoute(param),
191
+ buildVersionTagsRoutes(param),
192
+ ]);
193
+
194
+ return [sidebarRoute, ...tagsRoutes];
195
+ }
196
+
197
+ async function doBuildVersionRoutes(): Promise<RouteConfig> {
198
+ return {
199
+ path: version.path,
200
+ exact: false,
201
+ component: options.docVersionRootComponent,
202
+ routes: await buildVersionSubRoutes(),
203
+ props: {
204
+ // TODO Docusaurus v4 breaking change?
205
+ // expose version metadata as route context instead of props
206
+ version: toVersionMetadataProp(options.id, version),
207
+ },
208
+ priority: version.routePriority,
209
+ };
210
+ }
211
+
212
+ try {
213
+ return await doBuildVersionRoutes();
214
+ } catch (err) {
215
+ logger.error`Can't create version routes for version name=${version.versionName}`;
216
+ throw err;
217
+ }
218
+ }
219
+
220
+ type BuildAllRoutesParam = Omit<CreateAllRoutesParam, 'actions'> & {
221
+ actions: Omit<PluginContentLoadedActions, 'addRoute' | 'setGlobalData'>;
222
+ };
223
+
224
+ // TODO we want this buildAllRoutes function to be easily testable
225
+ // Ideally, we should avoid side effects here (ie not injecting actions)
226
+ export async function buildAllRoutes(
227
+ param: BuildAllRoutesParam,
228
+ ): Promise<RouteConfig[]> {
229
+ const subRoutes = await Promise.all(
230
+ param.versions.map((version) =>
231
+ buildVersionRoutes({
232
+ ...param,
233
+ version,
234
+ }),
235
+ ),
236
+ );
237
+
238
+ // all docs routes are wrapped under a single parent route, this ensures
239
+ // the theme layout never unmounts/remounts when navigating between versions
240
+ return [
241
+ {
242
+ path: normalizeUrl([param.baseUrl, param.options.routeBasePath]),
243
+ exact: false,
244
+ component: param.options.docsRootComponent,
245
+ routes: subRoutes,
246
+ },
247
+ ];
248
+ }
249
+
250
+ type CreateAllRoutesParam = {
251
+ baseUrl: string;
252
+ versions: FullVersion[];
253
+ options: PluginOptions;
254
+ actions: PluginContentLoadedActions;
255
+ aliasedSource: (str: string) => string;
256
+ };
257
+
258
+ export async function createAllRoutes(
259
+ param: CreateAllRoutesParam,
260
+ ): Promise<void> {
261
+ const routes = await buildAllRoutes(param);
262
+ routes.forEach(param.actions.addRoute);
263
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ // APIs available to Node.js
9
+ // Those are undocumented but used by some third-party plugins
10
+ // For this reason it's preferable to avoid doing breaking changes
11
+ // See also https://github.com/facebook/docusaurus/pull/6477
12
+
13
+ export {
14
+ CURRENT_VERSION_NAME,
15
+ VERSIONED_DOCS_DIR,
16
+ VERSIONED_SIDEBARS_DIR,
17
+ VERSIONS_JSON_FILE,
18
+ } from './constants';
19
+
20
+ export {
21
+ filterVersions,
22
+ getDefaultVersionBanner,
23
+ getVersionBadge,
24
+ getVersionBanner,
25
+ } from './versions/version';
26
+ export {readVersionNames} from './versions/files';
@@ -0,0 +1,10 @@
1
+ # Sidebars
2
+
3
+ This part is very complicated and hard to navigate. Sidebars are loaded through the following steps:
4
+
5
+ 1. **Loading**. The sidebars file is read. Returns `SidebarsConfig`.
6
+ 2. **Normalization**. The shorthands are expanded. This step is very lenient about the sidebars' shapes. Returns `NormalizedSidebars`.
7
+ 3. **Validation**. The normalized sidebars are validated. This step happens after normalization, because the normalized sidebars are easier to validate, and allows us to repeatedly validate & generate in the future.
8
+ 4. **Generation**. This step is done through the "processor" (naming is hard). The `autogenerated` items are unwrapped. In the future, steps 3 and 4 may be repeatedly done until all autogenerated items are unwrapped. Returns `ProcessedSidebars`.
9
+ - **Important**: this step should only care about unwrapping autogenerated items, not filtering them, writing additional metadata, applying defaults, etc.—everything will be handled in the post-processor. Important because the generator is exposed to the end-user and we want it to be easy to be reasoned about.
10
+ 5. **Post-processing**. Defaults are applied (collapsed states), category links are resolved, empty categories are flattened. Returns `Sidebars`.