@docusaurus/plugin-content-docs 2.0.0-beta.15d451942 → 2.0.0-beta.16
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/lib/categoryGeneratedIndex.d.ts +12 -0
- package/lib/categoryGeneratedIndex.js +39 -0
- package/lib/cli.d.ts +2 -2
- package/lib/cli.js +40 -52
- package/lib/client/docsClientUtils.d.ts +3 -25
- package/lib/client/docsClientUtils.js +27 -33
- package/lib/{theme/hooks/useDocs.d.ts → client/index.d.ts} +1 -2
- package/lib/client/index.js +75 -0
- package/lib/docFrontMatter.d.ts +1 -14
- package/lib/docFrontMatter.js +13 -6
- package/lib/docs.d.ts +40 -4
- package/lib/docs.js +170 -54
- package/lib/globalData.d.ts +5 -1
- package/lib/globalData.js +35 -2
- package/lib/index.d.ts +4 -3
- package/lib/index.js +124 -136
- package/lib/lastUpdate.js +16 -29
- package/lib/markdown/index.d.ts +3 -6
- package/lib/markdown/index.js +3 -3
- package/lib/markdown/linkify.d.ts +1 -1
- package/lib/markdown/linkify.js +3 -3
- package/lib/numberPrefix.d.ts +1 -1
- package/lib/numberPrefix.js +7 -6
- package/lib/options.d.ts +3 -3
- package/lib/options.js +52 -17
- package/lib/props.d.ts +7 -2
- package/lib/props.js +71 -14
- package/lib/routes.d.ts +28 -0
- package/lib/routes.js +110 -0
- package/lib/server-export.d.ts +8 -0
- package/lib/server-export.js +23 -0
- package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +1 -6
- package/lib/sidebars/generator.js +190 -0
- package/lib/sidebars/index.d.ts +13 -0
- package/lib/sidebars/index.js +88 -0
- package/lib/sidebars/normalization.d.ts +13 -0
- package/lib/sidebars/normalization.js +55 -0
- package/lib/sidebars/postProcessor.d.ts +8 -0
- package/lib/sidebars/postProcessor.js +72 -0
- package/lib/sidebars/processor.d.ts +8 -0
- package/lib/sidebars/processor.js +79 -0
- package/lib/sidebars/types.d.ts +166 -0
- package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js → lib/sidebars/types.js} +2 -10
- package/lib/sidebars/utils.d.ts +43 -0
- package/lib/sidebars/utils.js +265 -0
- package/lib/sidebars/validation.d.ts +9 -0
- package/lib/sidebars/validation.js +137 -0
- package/lib/slug.d.ts +6 -4
- package/lib/slug.js +29 -18
- package/{src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js → lib/tags.d.ts} +2 -8
- package/lib/tags.js +21 -0
- package/lib/translations.d.ts +2 -2
- package/lib/translations.js +87 -44
- package/lib/types.d.ts +55 -128
- package/lib/versions.d.ts +29 -4
- package/lib/versions.js +131 -89
- package/package.json +30 -26
- package/src/categoryGeneratedIndex.ts +59 -0
- package/src/cli.ts +48 -62
- package/src/client/docsClientUtils.ts +36 -71
- package/src/{theme/hooks/useDocs.ts → client/index.ts} +15 -10
- package/{types.d.ts → src/deps.d.ts} +0 -0
- package/src/docFrontMatter.ts +17 -22
- package/src/docs.ts +229 -45
- package/src/globalData.ts +53 -2
- package/src/index.ts +168 -177
- package/src/lastUpdate.ts +14 -33
- package/src/markdown/index.ts +9 -13
- package/src/markdown/linkify.ts +2 -2
- package/src/numberPrefix.ts +11 -8
- package/src/options.ts +59 -29
- package/src/plugin-content-docs.d.ts +256 -40
- package/src/props.ts +105 -21
- package/src/routes.ts +185 -0
- package/src/server-export.ts +24 -0
- package/src/sidebars/README.md +9 -0
- package/src/sidebars/generator.ts +263 -0
- package/src/sidebars/index.ts +113 -0
- package/src/sidebars/normalization.ts +85 -0
- package/src/sidebars/postProcessor.ts +94 -0
- package/src/sidebars/processor.ts +126 -0
- package/src/sidebars/types.ts +273 -0
- package/src/sidebars/utils.ts +392 -0
- package/src/sidebars/validation.ts +173 -0
- package/src/slug.ts +40 -22
- package/src/tags.ts +19 -0
- package/src/translations.ts +121 -62
- package/src/types.ts +62 -183
- package/src/versions.ts +202 -107
- package/lib/.tsbuildinfo +0 -4717
- package/lib/sidebarItemsGenerator.js +0 -211
- package/lib/sidebars.d.ts +0 -42
- package/lib/sidebars.js +0 -309
- package/lib/theme/hooks/useDocs.js +0 -72
- package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
- package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
- package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
- package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
- package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
- package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
- package/src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
- package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
- package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
- package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
- package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
- package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -67
- package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
- package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -52
- package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
- package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/simple-site/docusaurus.config.js +0 -14
- package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
- package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js +0 -14
- package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
- package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
- package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
- package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
- package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
- package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
- package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
- package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
- package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
- package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -90
- package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1907
- package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
- package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -487
- package/src/__tests__/cli.test.ts +0 -333
- package/src/__tests__/docFrontMatter.test.ts +0 -204
- package/src/__tests__/docs.test.ts +0 -875
- package/src/__tests__/index.test.ts +0 -1831
- package/src/__tests__/lastUpdate.test.ts +0 -68
- package/src/__tests__/numberPrefix.test.ts +0 -199
- package/src/__tests__/options.test.ts +0 -232
- package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
- package/src/__tests__/sidebars.test.ts +0 -638
- package/src/__tests__/slug.test.ts +0 -109
- package/src/__tests__/translations.test.ts +0 -159
- package/src/__tests__/versions.test.ts +0 -718
- package/src/client/__tests__/docsClientUtils.test.ts +0 -372
- package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
- package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
- package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
- package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
- package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
- package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
- package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
- package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
- package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
- package/src/markdown/__tests__/linkify.test.ts +0 -190
- package/src/sidebarItemsGenerator.ts +0 -307
- package/src/sidebars.ts +0 -489
- package/tsconfig.json +0 -9
package/src/options.ts
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import type {PluginOptions} from '@docusaurus/plugin-content-docs';
|
|
8
9
|
import {
|
|
9
10
|
Joi,
|
|
10
11
|
RemarkPluginsSchema,
|
|
@@ -12,10 +13,15 @@ import {
|
|
|
12
13
|
AdmonitionsSchema,
|
|
13
14
|
URISchema,
|
|
14
15
|
} from '@docusaurus/utils-validation';
|
|
15
|
-
import {
|
|
16
|
-
|
|
16
|
+
import {GlobExcludeDefault} from '@docusaurus/utils';
|
|
17
|
+
|
|
18
|
+
import type {
|
|
19
|
+
OptionValidationContext,
|
|
20
|
+
ValidationResult,
|
|
21
|
+
} from '@docusaurus/types';
|
|
22
|
+
import logger from '@docusaurus/logger';
|
|
17
23
|
import admonitions from 'remark-admonitions';
|
|
18
|
-
import {DefaultSidebarItemsGenerator} from './
|
|
24
|
+
import {DefaultSidebarItemsGenerator} from './sidebars/generator';
|
|
19
25
|
import {
|
|
20
26
|
DefaultNumberPrefixParser,
|
|
21
27
|
DisabledNumberPrefixParser,
|
|
@@ -24,12 +30,16 @@ import {
|
|
|
24
30
|
export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
25
31
|
path: 'docs', // Path to data on filesystem, relative to site dir.
|
|
26
32
|
routeBasePath: 'docs', // URL Route.
|
|
27
|
-
|
|
33
|
+
tagsBasePath: 'tags', // URL Tags Route.
|
|
28
34
|
include: ['**/*.{md,mdx}'], // Extensions to include.
|
|
35
|
+
exclude: GlobExcludeDefault,
|
|
29
36
|
sidebarItemsGenerator: DefaultSidebarItemsGenerator,
|
|
30
37
|
numberPrefixParser: DefaultNumberPrefixParser,
|
|
31
38
|
docLayoutComponent: '@theme/DocPage',
|
|
32
39
|
docItemComponent: '@theme/DocItem',
|
|
40
|
+
docTagDocListComponent: '@theme/DocTagDocListPage',
|
|
41
|
+
docTagsListComponent: '@theme/DocTagsListPage',
|
|
42
|
+
docCategoryGeneratedIndexComponent: '@theme/DocCategoryGeneratedIndexPage',
|
|
33
43
|
remarkPlugins: [],
|
|
34
44
|
rehypePlugins: [],
|
|
35
45
|
beforeDefaultRemarkPlugins: [],
|
|
@@ -37,18 +47,23 @@ export const DEFAULT_OPTIONS: Omit<PluginOptions, 'id' | 'sidebarPath'> = {
|
|
|
37
47
|
showLastUpdateTime: false,
|
|
38
48
|
showLastUpdateAuthor: false,
|
|
39
49
|
admonitions: {},
|
|
40
|
-
excludeNextVersionDocs: false,
|
|
41
50
|
includeCurrentVersion: true,
|
|
42
51
|
disableVersioning: false,
|
|
43
52
|
lastVersion: undefined,
|
|
44
53
|
versions: {},
|
|
45
54
|
editCurrentVersion: false,
|
|
46
55
|
editLocalizedFiles: false,
|
|
56
|
+
sidebarCollapsible: true,
|
|
57
|
+
sidebarCollapsed: true,
|
|
58
|
+
breadcrumbs: true,
|
|
47
59
|
};
|
|
48
60
|
|
|
49
61
|
const VersionOptionsSchema = Joi.object({
|
|
50
62
|
path: Joi.string().allow('').optional(),
|
|
51
63
|
label: Joi.string().optional(),
|
|
64
|
+
banner: Joi.string().equal('none', 'unreleased', 'unmaintained').optional(),
|
|
65
|
+
badge: Joi.boolean().optional(),
|
|
66
|
+
className: Joi.string().optional(),
|
|
52
67
|
});
|
|
53
68
|
|
|
54
69
|
const VersionsOptionsSchema = Joi.object()
|
|
@@ -64,8 +79,14 @@ export const OptionsSchema = Joi.object({
|
|
|
64
79
|
// '' not allowed, see https://github.com/facebook/docusaurus/issues/3374
|
|
65
80
|
// .allow('') ""
|
|
66
81
|
.default(DEFAULT_OPTIONS.routeBasePath),
|
|
67
|
-
|
|
82
|
+
tagsBasePath: Joi.string().default(DEFAULT_OPTIONS.tagsBasePath),
|
|
83
|
+
homePageId: Joi.any().forbidden().messages({
|
|
84
|
+
'any.unknown':
|
|
85
|
+
'The docs plugin option homePageId is not supported anymore. To make a doc the "home", please add "slug: /" in its front matter. See: https://docusaurus.io/docs/next/docs-introduction#home-page-docs',
|
|
86
|
+
}),
|
|
87
|
+
|
|
68
88
|
include: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.include),
|
|
89
|
+
exclude: Joi.array().items(Joi.string()).default(DEFAULT_OPTIONS.exclude),
|
|
69
90
|
sidebarPath: Joi.alternatives().try(
|
|
70
91
|
Joi.boolean().invalid(true),
|
|
71
92
|
Joi.string(),
|
|
@@ -73,6 +94,8 @@ export const OptionsSchema = Joi.object({
|
|
|
73
94
|
sidebarItemsGenerator: Joi.function().default(
|
|
74
95
|
() => DEFAULT_OPTIONS.sidebarItemsGenerator,
|
|
75
96
|
),
|
|
97
|
+
sidebarCollapsible: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsible),
|
|
98
|
+
sidebarCollapsed: Joi.boolean().default(DEFAULT_OPTIONS.sidebarCollapsed),
|
|
76
99
|
numberPrefixParser: Joi.alternatives()
|
|
77
100
|
.try(
|
|
78
101
|
Joi.function(),
|
|
@@ -86,6 +109,15 @@ export const OptionsSchema = Joi.object({
|
|
|
86
109
|
.default(() => DEFAULT_OPTIONS.numberPrefixParser),
|
|
87
110
|
docLayoutComponent: Joi.string().default(DEFAULT_OPTIONS.docLayoutComponent),
|
|
88
111
|
docItemComponent: Joi.string().default(DEFAULT_OPTIONS.docItemComponent),
|
|
112
|
+
docTagsListComponent: Joi.string().default(
|
|
113
|
+
DEFAULT_OPTIONS.docTagsListComponent,
|
|
114
|
+
),
|
|
115
|
+
docTagDocListComponent: Joi.string().default(
|
|
116
|
+
DEFAULT_OPTIONS.docTagDocListComponent,
|
|
117
|
+
),
|
|
118
|
+
docCategoryGeneratedIndexComponent: Joi.string().default(
|
|
119
|
+
DEFAULT_OPTIONS.docCategoryGeneratedIndexComponent,
|
|
120
|
+
),
|
|
89
121
|
remarkPlugins: RemarkPluginsSchema.default(DEFAULT_OPTIONS.remarkPlugins),
|
|
90
122
|
rehypePlugins: RehypePluginsSchema.default(DEFAULT_OPTIONS.rehypePlugins),
|
|
91
123
|
beforeDefaultRemarkPlugins: RemarkPluginsSchema.default(
|
|
@@ -101,9 +133,6 @@ export const OptionsSchema = Joi.object({
|
|
|
101
133
|
showLastUpdateAuthor: Joi.bool().default(
|
|
102
134
|
DEFAULT_OPTIONS.showLastUpdateAuthor,
|
|
103
135
|
),
|
|
104
|
-
excludeNextVersionDocs: Joi.bool().default(
|
|
105
|
-
DEFAULT_OPTIONS.excludeNextVersionDocs,
|
|
106
|
-
),
|
|
107
136
|
includeCurrentVersion: Joi.bool().default(
|
|
108
137
|
DEFAULT_OPTIONS.includeCurrentVersion,
|
|
109
138
|
),
|
|
@@ -111,31 +140,32 @@ export const OptionsSchema = Joi.object({
|
|
|
111
140
|
disableVersioning: Joi.bool().default(DEFAULT_OPTIONS.disableVersioning),
|
|
112
141
|
lastVersion: Joi.string().optional(),
|
|
113
142
|
versions: VersionsOptionsSchema,
|
|
143
|
+
breadcrumbs: Joi.bool().default(DEFAULT_OPTIONS.breadcrumbs),
|
|
114
144
|
});
|
|
115
145
|
|
|
116
146
|
export function validateOptions({
|
|
117
147
|
validate,
|
|
118
|
-
options,
|
|
148
|
+
options: userOptions,
|
|
119
149
|
}: OptionValidationContext<PluginOptions>): ValidationResult<PluginOptions> {
|
|
120
|
-
|
|
121
|
-
// "slug: /" is better because the home doc can be different across versions
|
|
122
|
-
if (options.homePageId) {
|
|
123
|
-
console.log(
|
|
124
|
-
chalk.red(
|
|
125
|
-
`The docs plugin option homePageId=${options.homePageId} is deprecated. To make a doc the "home", prefer frontmatter: "slug: /"`,
|
|
126
|
-
),
|
|
127
|
-
);
|
|
128
|
-
}
|
|
150
|
+
let options = userOptions;
|
|
129
151
|
|
|
130
|
-
if (
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
152
|
+
if (options.sidebarCollapsible === false) {
|
|
153
|
+
// When sidebarCollapsible=false and sidebarCollapsed=undefined, we don't
|
|
154
|
+
// want to have the inconsistency warning. We let options.sidebarCollapsible
|
|
155
|
+
// become the default value for options.sidebarCollapsed
|
|
156
|
+
if (typeof options.sidebarCollapsed === 'undefined') {
|
|
157
|
+
options = {
|
|
158
|
+
...options,
|
|
159
|
+
sidebarCollapsed: false,
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (options.sidebarCollapsed) {
|
|
163
|
+
logger.warn`The docs plugin config is inconsistent. It does not make sense to use code=${'sidebarCollapsible: false'} and code=${'sidebarCollapsed: true'} at the same time. code=${'sidebarCollapsed: true'} will be ignored.`;
|
|
164
|
+
options = {
|
|
165
|
+
...options,
|
|
166
|
+
sidebarCollapsed: false,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
139
169
|
}
|
|
140
170
|
|
|
141
171
|
const normalizedOptions = validate(OptionsSchema, options);
|
|
@@ -5,53 +5,172 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
declare module '@docusaurus/plugin-content-docs' {
|
|
9
|
+
import type {RemarkAndRehypePluginOptions} from '@docusaurus/mdx-loader';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
export interface Assets {
|
|
12
|
+
image?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type NumberPrefixParser = (filename: string) => {
|
|
16
|
+
filename: string;
|
|
17
|
+
numberPrefix?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type CategoryIndexMatcherParam = {
|
|
21
|
+
fileName: string;
|
|
22
|
+
directories: string[];
|
|
23
|
+
extension: string;
|
|
24
|
+
};
|
|
25
|
+
export type CategoryIndexMatcher = (
|
|
26
|
+
param: CategoryIndexMatcherParam,
|
|
27
|
+
) => boolean;
|
|
28
|
+
|
|
29
|
+
export type EditUrlFunction = (editUrlParams: {
|
|
30
|
+
version: string;
|
|
31
|
+
versionDocsDirPath: string;
|
|
32
|
+
docPath: string;
|
|
33
|
+
permalink: string;
|
|
34
|
+
locale: string;
|
|
35
|
+
}) => string | undefined;
|
|
36
|
+
|
|
37
|
+
export type MetadataOptions = {
|
|
38
|
+
routeBasePath: string;
|
|
39
|
+
editUrl?: string | EditUrlFunction;
|
|
40
|
+
editCurrentVersion: boolean;
|
|
41
|
+
editLocalizedFiles: boolean;
|
|
42
|
+
showLastUpdateTime?: boolean;
|
|
43
|
+
showLastUpdateAuthor?: boolean;
|
|
44
|
+
numberPrefixParser: NumberPrefixParser;
|
|
45
|
+
breadcrumbs: boolean;
|
|
13
46
|
};
|
|
14
47
|
|
|
48
|
+
export type PathOptions = {
|
|
49
|
+
path: string;
|
|
50
|
+
sidebarPath?: string | false | undefined;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// TODO support custom version banner?
|
|
54
|
+
// {type: "error", content: "html content"}
|
|
55
|
+
export type VersionBanner = 'unreleased' | 'unmaintained';
|
|
56
|
+
export type VersionOptions = {
|
|
57
|
+
path?: string;
|
|
58
|
+
label?: string;
|
|
59
|
+
banner?: 'none' | VersionBanner;
|
|
60
|
+
badge?: boolean;
|
|
61
|
+
className?: string;
|
|
62
|
+
};
|
|
63
|
+
export type VersionsOptions = {
|
|
64
|
+
lastVersion?: string;
|
|
65
|
+
versions: Record<string, VersionOptions>;
|
|
66
|
+
onlyIncludeVersions?: string[];
|
|
67
|
+
};
|
|
68
|
+
export type SidebarOptions = {
|
|
69
|
+
sidebarCollapsible: boolean;
|
|
70
|
+
sidebarCollapsed: boolean;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type PluginOptions = MetadataOptions &
|
|
74
|
+
PathOptions &
|
|
75
|
+
VersionsOptions &
|
|
76
|
+
RemarkAndRehypePluginOptions &
|
|
77
|
+
SidebarOptions & {
|
|
78
|
+
id: string;
|
|
79
|
+
include: string[];
|
|
80
|
+
exclude: string[];
|
|
81
|
+
docLayoutComponent: string;
|
|
82
|
+
docItemComponent: string;
|
|
83
|
+
docTagDocListComponent: string;
|
|
84
|
+
docTagsListComponent: string;
|
|
85
|
+
docCategoryGeneratedIndexComponent: string;
|
|
86
|
+
admonitions: Record<string, unknown>;
|
|
87
|
+
disableVersioning: boolean;
|
|
88
|
+
includeCurrentVersion: boolean;
|
|
89
|
+
sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
|
|
90
|
+
tagsBasePath: string;
|
|
91
|
+
};
|
|
92
|
+
export type Options = Partial<PluginOptions>;
|
|
93
|
+
export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
|
|
94
|
+
|
|
95
|
+
export type PropNavigationLink = {
|
|
96
|
+
readonly title: string;
|
|
97
|
+
readonly permalink: string;
|
|
98
|
+
};
|
|
99
|
+
export type PropNavigation = {
|
|
100
|
+
readonly previous?: PropNavigationLink;
|
|
101
|
+
readonly next?: PropNavigationLink;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export type PropVersionDoc = import('./sidebars/types').PropVersionDoc;
|
|
105
|
+
export type PropVersionDocs = import('./sidebars/types').PropVersionDocs;
|
|
106
|
+
|
|
15
107
|
export type PropVersionMetadata = {
|
|
16
108
|
pluginId: string;
|
|
17
109
|
version: string;
|
|
18
110
|
label: string;
|
|
111
|
+
banner: VersionBanner | null;
|
|
112
|
+
badge: boolean;
|
|
113
|
+
className: string;
|
|
19
114
|
isLast: boolean;
|
|
20
115
|
docsSidebars: PropSidebars;
|
|
21
|
-
|
|
116
|
+
docs: PropVersionDocs;
|
|
22
117
|
};
|
|
23
118
|
|
|
24
|
-
type
|
|
25
|
-
|
|
119
|
+
export type PropCategoryGeneratedIndex = {
|
|
120
|
+
title: string;
|
|
121
|
+
description?: string;
|
|
122
|
+
image?: string;
|
|
123
|
+
keywords?: string | readonly string[];
|
|
124
|
+
slug: string;
|
|
125
|
+
permalink: string;
|
|
126
|
+
navigation: PropNavigation;
|
|
26
127
|
};
|
|
27
128
|
|
|
28
|
-
export type PropSidebarItemLink =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
129
|
+
export type PropSidebarItemLink =
|
|
130
|
+
import('./sidebars/types').PropSidebarItemLink;
|
|
131
|
+
export type PropSidebarItemCategory =
|
|
132
|
+
import('./sidebars/types').PropSidebarItemCategory;
|
|
133
|
+
export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
|
|
134
|
+
export type PropSidebarBreadcrumbsItem =
|
|
135
|
+
import('./sidebars/types').PropSidebarBreadcrumbsItem;
|
|
136
|
+
export type PropSidebar = import('./sidebars/types').PropSidebar;
|
|
137
|
+
export type PropSidebars = import('./sidebars/types').PropSidebars;
|
|
33
138
|
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
139
|
+
export type PropTagDocListDoc = {
|
|
140
|
+
id: string;
|
|
141
|
+
title: string;
|
|
142
|
+
description: string;
|
|
143
|
+
permalink: string;
|
|
144
|
+
};
|
|
145
|
+
export type PropTagDocList = {
|
|
146
|
+
allTagsPath: string;
|
|
147
|
+
name: string; // normalized name/label of the tag
|
|
148
|
+
permalink: string; // pathname of the tag
|
|
149
|
+
docs: PropTagDocListDoc[];
|
|
39
150
|
};
|
|
40
151
|
|
|
41
|
-
export type
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
152
|
+
export type PropTagsListPage = {
|
|
153
|
+
tags: {
|
|
154
|
+
name: string;
|
|
155
|
+
permalink: string;
|
|
156
|
+
count: number;
|
|
157
|
+
}[];
|
|
45
158
|
};
|
|
46
159
|
}
|
|
47
160
|
|
|
48
161
|
declare module '@theme/DocItem' {
|
|
49
162
|
import type {TOCItem} from '@docusaurus/types';
|
|
163
|
+
import type {
|
|
164
|
+
PropNavigationLink,
|
|
165
|
+
PropVersionMetadata,
|
|
166
|
+
Assets,
|
|
167
|
+
} from '@docusaurus/plugin-content-docs';
|
|
50
168
|
|
|
51
169
|
export type DocumentRoute = {
|
|
52
170
|
readonly component: () => JSX.Element;
|
|
53
171
|
readonly exact: boolean;
|
|
54
172
|
readonly path: string;
|
|
173
|
+
readonly sidebar?: string;
|
|
55
174
|
};
|
|
56
175
|
|
|
57
176
|
export type FrontMatter = {
|
|
@@ -61,6 +180,8 @@ declare module '@theme/DocItem' {
|
|
|
61
180
|
readonly keywords?: readonly string[];
|
|
62
181
|
readonly hide_title?: boolean;
|
|
63
182
|
readonly hide_table_of_contents?: boolean;
|
|
183
|
+
readonly toc_min_heading_level?: number;
|
|
184
|
+
readonly toc_max_heading_level?: number;
|
|
64
185
|
};
|
|
65
186
|
|
|
66
187
|
export type Metadata = {
|
|
@@ -72,29 +193,67 @@ declare module '@theme/DocItem' {
|
|
|
72
193
|
readonly formattedLastUpdatedAt?: string;
|
|
73
194
|
readonly lastUpdatedBy?: string;
|
|
74
195
|
readonly version?: string;
|
|
75
|
-
readonly previous?:
|
|
76
|
-
readonly next?:
|
|
196
|
+
readonly previous?: PropNavigationLink;
|
|
197
|
+
readonly next?: PropNavigationLink;
|
|
198
|
+
readonly tags: readonly {
|
|
199
|
+
readonly label: string;
|
|
200
|
+
readonly permalink: string;
|
|
201
|
+
}[];
|
|
77
202
|
};
|
|
78
203
|
|
|
79
|
-
export
|
|
204
|
+
export interface Props {
|
|
80
205
|
readonly route: DocumentRoute;
|
|
206
|
+
readonly versionMetadata: PropVersionMetadata;
|
|
81
207
|
readonly content: {
|
|
82
208
|
readonly frontMatter: FrontMatter;
|
|
83
209
|
readonly metadata: Metadata;
|
|
84
210
|
readonly toc: readonly TOCItem[];
|
|
211
|
+
readonly contentTitle: string | undefined;
|
|
212
|
+
readonly assets: Assets;
|
|
85
213
|
(): JSX.Element;
|
|
86
214
|
};
|
|
87
|
-
}
|
|
215
|
+
}
|
|
88
216
|
|
|
89
|
-
|
|
90
|
-
|
|
217
|
+
export default function DocItem(props: Props): JSX.Element;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
declare module '@theme/DocCategoryGeneratedIndexPage' {
|
|
221
|
+
import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
|
|
222
|
+
|
|
223
|
+
export interface Props {
|
|
224
|
+
readonly categoryGeneratedIndex: PropCategoryGeneratedIndex;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export default function DocCategoryGeneratedIndexPage(
|
|
228
|
+
props: Props,
|
|
229
|
+
): JSX.Element;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
declare module '@theme/DocTagsListPage' {
|
|
233
|
+
import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
|
|
234
|
+
|
|
235
|
+
export interface Props extends PropTagsListPage {}
|
|
236
|
+
export default function DocTagsListPage(props: Props): JSX.Element;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
declare module '@theme/DocTagDocListPage' {
|
|
240
|
+
import type {PropTagDocList} from '@docusaurus/plugin-content-docs';
|
|
241
|
+
|
|
242
|
+
export interface Props {
|
|
243
|
+
readonly tag: PropTagDocList;
|
|
244
|
+
}
|
|
245
|
+
export default function DocTagDocListPage(props: Props): JSX.Element;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
declare module '@theme/DocBreadcrumbs' {
|
|
249
|
+
export default function DocBreadcrumbs(): JSX.Element;
|
|
91
250
|
}
|
|
92
251
|
|
|
93
252
|
declare module '@theme/DocPage' {
|
|
94
|
-
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs
|
|
253
|
+
import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
|
|
95
254
|
import type {DocumentRoute} from '@theme/DocItem';
|
|
96
255
|
|
|
97
|
-
export
|
|
256
|
+
export interface Props {
|
|
98
257
|
readonly location: {readonly pathname: string};
|
|
99
258
|
readonly versionMetadata: PropVersionMetadata;
|
|
100
259
|
readonly route: {
|
|
@@ -102,20 +261,77 @@ declare module '@theme/DocPage' {
|
|
|
102
261
|
readonly component: () => JSX.Element;
|
|
103
262
|
readonly routes: DocumentRoute[];
|
|
104
263
|
};
|
|
105
|
-
}
|
|
264
|
+
}
|
|
106
265
|
|
|
107
|
-
|
|
108
|
-
export default DocPage;
|
|
266
|
+
export default function DocPage(props: Props): JSX.Element;
|
|
109
267
|
}
|
|
110
268
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
269
|
+
// TODO until TS supports exports field... hope it's in 4.6
|
|
270
|
+
declare module '@docusaurus/plugin-content-docs/client' {
|
|
271
|
+
export type ActivePlugin = {
|
|
272
|
+
pluginId: string;
|
|
273
|
+
pluginData: GlobalPluginData;
|
|
274
|
+
};
|
|
275
|
+
export type ActiveDocContext = {
|
|
276
|
+
activeVersion?: GlobalVersion;
|
|
277
|
+
activeDoc?: GlobalDoc;
|
|
278
|
+
alternateDocVersions: Record<string, GlobalDoc>;
|
|
279
|
+
};
|
|
280
|
+
export type GlobalDoc = {
|
|
281
|
+
id: string;
|
|
282
|
+
path: string;
|
|
283
|
+
sidebar: string | undefined;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export type GlobalVersion = {
|
|
287
|
+
name: string;
|
|
288
|
+
label: string;
|
|
289
|
+
isLast: boolean;
|
|
290
|
+
path: string;
|
|
291
|
+
mainDocId: string; // home doc (if docs homepage configured), or first doc
|
|
292
|
+
docs: GlobalDoc[];
|
|
293
|
+
sidebars?: Record<string, GlobalSidebar>;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
export type GlobalSidebarLink = {
|
|
297
|
+
label: string;
|
|
298
|
+
path: string;
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
export type GlobalSidebar = {
|
|
302
|
+
link?: GlobalSidebarLink;
|
|
303
|
+
// ... we may add other things here later
|
|
304
|
+
};
|
|
305
|
+
export type GlobalPluginData = {
|
|
306
|
+
path: string;
|
|
307
|
+
versions: GlobalVersion[];
|
|
308
|
+
breadcrumbs: boolean;
|
|
309
|
+
};
|
|
310
|
+
export type DocVersionSuggestions = {
|
|
311
|
+
// suggest the latest version
|
|
312
|
+
latestVersionSuggestion: GlobalVersion;
|
|
313
|
+
// suggest the same doc, in latest version (if exist)
|
|
314
|
+
latestDocSuggestion?: GlobalDoc;
|
|
117
315
|
};
|
|
316
|
+
export type GetActivePluginOptions = {failfast?: boolean}; // use fail-fast option if you know for sure one plugin instance is active
|
|
118
317
|
|
|
119
|
-
const
|
|
120
|
-
export
|
|
318
|
+
export const useAllDocsData: () => Record<string, GlobalPluginData>;
|
|
319
|
+
export const useDocsData: (pluginId?: string) => GlobalPluginData;
|
|
320
|
+
export const useActivePlugin: (
|
|
321
|
+
options?: GetActivePluginOptions,
|
|
322
|
+
) => ActivePlugin | undefined;
|
|
323
|
+
export const useActivePluginAndVersion: (
|
|
324
|
+
options?: GetActivePluginOptions,
|
|
325
|
+
) =>
|
|
326
|
+
| {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
|
|
327
|
+
| undefined;
|
|
328
|
+
export const useVersions: (pluginId?: string) => GlobalVersion[];
|
|
329
|
+
export const useLatestVersion: (pluginId?: string) => GlobalVersion;
|
|
330
|
+
export const useActiveVersion: (
|
|
331
|
+
pluginId?: string,
|
|
332
|
+
) => GlobalVersion | undefined;
|
|
333
|
+
export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
|
|
334
|
+
export const useDocVersionSuggestions: (
|
|
335
|
+
pluginId?: string,
|
|
336
|
+
) => DocVersionSuggestions;
|
|
121
337
|
}
|