@docusaurus/plugin-content-docs 2.0.0-beta.1ec2c95e3 → 2.0.0-beta.21

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 (229) hide show
  1. package/lib/categoryGeneratedIndex.d.ts +12 -0
  2. package/lib/categoryGeneratedIndex.js +37 -0
  3. package/lib/cli.d.ts +3 -2
  4. package/lib/cli.js +58 -72
  5. package/lib/client/docsClientUtils.d.ts +9 -28
  6. package/lib/client/docsClientUtils.js +34 -43
  7. package/lib/client/index.d.ts +22 -0
  8. package/lib/client/index.js +59 -0
  9. package/lib/constants.d.ts +4 -0
  10. package/lib/constants.js +4 -1
  11. package/lib/docs.d.ts +32 -3
  12. package/lib/docs.js +164 -63
  13. package/{src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docusaurus.config.js → lib/frontMatter.d.ts} +4 -8
  14. package/lib/{docFrontMatter.js → frontMatter.js} +12 -3
  15. package/lib/globalData.d.ts +3 -3
  16. package/lib/globalData.js +35 -6
  17. package/lib/index.d.ts +3 -3
  18. package/lib/index.js +123 -149
  19. package/lib/lastUpdate.d.ts +4 -6
  20. package/lib/lastUpdate.js +22 -26
  21. package/lib/markdown/index.d.ts +3 -6
  22. package/lib/markdown/index.js +3 -3
  23. package/lib/markdown/linkify.d.ts +1 -1
  24. package/lib/markdown/linkify.js +6 -3
  25. package/lib/numberPrefix.d.ts +1 -1
  26. package/lib/numberPrefix.js +16 -21
  27. package/lib/options.d.ts +3 -5
  28. package/lib/options.js +54 -13
  29. package/lib/props.d.ts +7 -2
  30. package/lib/props.js +70 -14
  31. package/lib/routes.d.ts +29 -0
  32. package/lib/routes.js +96 -0
  33. package/lib/server-export.d.ts +9 -0
  34. package/lib/server-export.js +22 -0
  35. package/lib/{sidebarItemsGenerator.d.ts → sidebars/generator.d.ts} +1 -6
  36. package/lib/sidebars/generator.js +209 -0
  37. package/lib/sidebars/index.d.ts +13 -0
  38. package/lib/sidebars/index.js +92 -0
  39. package/lib/sidebars/normalization.d.ts +13 -0
  40. package/lib/sidebars/normalization.js +55 -0
  41. package/lib/sidebars/postProcessor.d.ts +11 -0
  42. package/lib/sidebars/postProcessor.js +81 -0
  43. package/lib/sidebars/processor.d.ts +10 -0
  44. package/lib/sidebars/processor.js +79 -0
  45. package/lib/sidebars/types.d.ts +178 -0
  46. package/lib/{docFrontMatter.d.ts → sidebars/types.js} +2 -2
  47. package/lib/sidebars/utils.d.ts +54 -0
  48. package/lib/sidebars/utils.js +255 -0
  49. package/lib/sidebars/validation.d.ts +11 -0
  50. package/lib/sidebars/validation.js +142 -0
  51. package/lib/slug.d.ts +5 -4
  52. package/lib/slug.js +28 -18
  53. package/{src/__tests__/__fixtures__/sidebars/sidebars-first-level-not-category.js → lib/tags.d.ts} +3 -14
  54. package/lib/tags.js +21 -0
  55. package/lib/translations.d.ts +3 -3
  56. package/lib/translations.js +83 -93
  57. package/lib/types.d.ts +13 -184
  58. package/lib/versions/files.d.ts +51 -0
  59. package/lib/versions/files.js +143 -0
  60. package/lib/versions/index.d.ts +36 -0
  61. package/lib/versions/index.js +155 -0
  62. package/lib/versions/validation.d.ts +17 -0
  63. package/lib/versions/validation.js +71 -0
  64. package/package.json +34 -29
  65. package/src/categoryGeneratedIndex.ts +60 -0
  66. package/src/cli.ts +85 -114
  67. package/src/client/docsClientUtils.ts +44 -71
  68. package/src/client/index.ts +106 -0
  69. package/src/constants.ts +4 -2
  70. package/{types.d.ts → src/deps.d.ts} +1 -1
  71. package/src/docs.ts +228 -65
  72. package/src/{docFrontMatter.ts → frontMatter.ts} +20 -10
  73. package/src/globalData.ts +57 -7
  74. package/src/index.ts +179 -216
  75. package/src/lastUpdate.ts +26 -37
  76. package/src/markdown/index.ts +10 -16
  77. package/src/markdown/linkify.ts +7 -4
  78. package/src/numberPrefix.ts +19 -26
  79. package/src/options.ts +59 -18
  80. package/src/plugin-content-docs.d.ts +642 -89
  81. package/src/props.ts +103 -21
  82. package/src/routes.ts +159 -0
  83. package/src/server-export.ts +22 -0
  84. package/src/sidebars/README.md +10 -0
  85. package/src/sidebars/generator.ts +292 -0
  86. package/src/sidebars/index.ts +118 -0
  87. package/src/sidebars/normalization.ts +85 -0
  88. package/src/sidebars/postProcessor.ts +112 -0
  89. package/src/sidebars/processor.ts +123 -0
  90. package/src/sidebars/types.ts +275 -0
  91. package/src/sidebars/utils.ts +390 -0
  92. package/src/sidebars/validation.ts +178 -0
  93. package/src/slug.ts +41 -22
  94. package/src/tags.ts +20 -0
  95. package/src/translations.ts +129 -123
  96. package/src/types.ts +18 -249
  97. package/src/versions/files.ts +220 -0
  98. package/src/versions/index.ts +247 -0
  99. package/src/versions/validation.ts +115 -0
  100. package/lib/.tsbuildinfo +0 -1
  101. package/lib/sidebarItemsGenerator.js +0 -211
  102. package/lib/sidebars.d.ts +0 -43
  103. package/lib/sidebars.js +0 -320
  104. package/lib/theme/hooks/useDocs.d.ts +0 -20
  105. package/lib/theme/hooks/useDocs.js +0 -75
  106. package/lib/versions.d.ts +0 -16
  107. package/lib/versions.js +0 -319
  108. package/src/__tests__/__fixtures__/bad-id-site/docs/invalid-id.md +0 -5
  109. package/src/__tests__/__fixtures__/bad-slug-on-doc-home-site/docs/docWithSlug.md +0 -5
  110. package/src/__tests__/__fixtures__/empty-site/docusaurus.config.js +0 -16
  111. package/src/__tests__/__fixtures__/empty-site/sidebars.json +0 -1
  112. package/src/__tests__/__fixtures__/sidebars/sidebars-category-shorthand.js +0 -34
  113. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-items.json +0 -11
  114. package/src/__tests__/__fixtures__/sidebars/sidebars-category-wrong-label.json +0 -11
  115. package/src/__tests__/__fixtures__/sidebars/sidebars-category.js +0 -44
  116. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed-first-level.json +0 -20
  117. package/src/__tests__/__fixtures__/sidebars/sidebars-collapsed.json +0 -21
  118. package/src/__tests__/__fixtures__/sidebars/sidebars-doc-id-not-string.json +0 -10
  119. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-href.json +0 -11
  120. package/src/__tests__/__fixtures__/sidebars/sidebars-link-wrong-label.json +0 -11
  121. package/src/__tests__/__fixtures__/sidebars/sidebars-link.json +0 -11
  122. package/src/__tests__/__fixtures__/sidebars/sidebars-unknown-type.json +0 -14
  123. package/src/__tests__/__fixtures__/sidebars/sidebars-wrong-field.json +0 -20
  124. package/src/__tests__/__fixtures__/sidebars/sidebars.json +0 -20
  125. package/src/__tests__/__fixtures__/simple-site/docs/foo/bar.md +0 -69
  126. package/src/__tests__/__fixtures__/simple-site/docs/foo/baz.md +0 -70
  127. package/src/__tests__/__fixtures__/simple-site/docs/headingAsTitle.md +0 -1
  128. package/src/__tests__/__fixtures__/simple-site/docs/hello.md +0 -53
  129. package/src/__tests__/__fixtures__/simple-site/docs/ipsum.md +0 -5
  130. package/src/__tests__/__fixtures__/simple-site/docs/lorem.md +0 -6
  131. package/src/__tests__/__fixtures__/simple-site/docs/rootAbsoluteSlug.md +0 -5
  132. package/src/__tests__/__fixtures__/simple-site/docs/rootRelativeSlug.md +0 -5
  133. package/src/__tests__/__fixtures__/simple-site/docs/rootResolvedSlug.md +0 -5
  134. package/src/__tests__/__fixtures__/simple-site/docs/rootTryToEscapeSlug.md +0 -5
  135. package/src/__tests__/__fixtures__/simple-site/docs/slugs/absoluteSlug.md +0 -5
  136. package/src/__tests__/__fixtures__/simple-site/docs/slugs/relativeSlug.md +0 -5
  137. package/src/__tests__/__fixtures__/simple-site/docs/slugs/resolvedSlug.md +0 -5
  138. package/src/__tests__/__fixtures__/simple-site/docs/slugs/tryToEscapeSlug.md +0 -5
  139. package/src/__tests__/__fixtures__/simple-site/docusaurus.config.js +0 -14
  140. package/src/__tests__/__fixtures__/simple-site/sidebars.json +0 -23
  141. package/src/__tests__/__fixtures__/simple-site/wrong-sidebars.json +0 -7
  142. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/0-getting-started.md +0 -3
  143. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/1-installation.md +0 -3
  144. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/00_api-overview.md +0 -3
  145. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/0 --- Client API.md +0 -1
  146. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/01_Core APIs/1 --- Server API.md +0 -1
  147. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/0. Plugin API.md +0 -1
  148. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/1. Theme API.md +0 -1
  149. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/02_Extension APIs/_category_.yml +0 -1
  150. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/03_api-end.md +0 -3
  151. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/3-API/_category_.json +0 -3
  152. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/0-guide2.5.md +0 -8
  153. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/02-guide2.md +0 -7
  154. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/_category_.json +0 -3
  155. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/a-guide4.md +0 -7
  156. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/b-guide5.md +0 -7
  157. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/guide3.md +0 -8
  158. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/docs/Guides/z-guide1.md +0 -8
  159. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars.js +0 -23
  160. package/src/__tests__/__fixtures__/site-with-autogenerated-sidebar/partialAutogeneratedSidebars2.js +0 -16
  161. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-1.md +0 -7
  162. package/src/__tests__/__fixtures__/site-with-doc-label/docs/hello-2.md +0 -8
  163. package/src/__tests__/__fixtures__/site-with-doc-label/docusaurus.config.js +0 -14
  164. package/src/__tests__/__fixtures__/site-with-doc-label/sidebars.json +0 -14
  165. package/src/__tests__/__fixtures__/versioned-site/community/team.md +0 -1
  166. package/src/__tests__/__fixtures__/versioned-site/community_sidebars.json +0 -3
  167. package/src/__tests__/__fixtures__/versioned-site/community_versioned_docs/version-1.0.0/team.md +0 -1
  168. package/src/__tests__/__fixtures__/versioned-site/community_versioned_sidebars/version-1.0.0-sidebars.json +0 -3
  169. package/src/__tests__/__fixtures__/versioned-site/community_versions.json +0 -1
  170. package/src/__tests__/__fixtures__/versioned-site/docs/foo/bar.md +0 -4
  171. package/src/__tests__/__fixtures__/versioned-site/docs/hello.md +0 -1
  172. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/absoluteSlug.md +0 -5
  173. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/relativeSlug.md +0 -5
  174. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/resolvedSlug.md +0 -5
  175. package/src/__tests__/__fixtures__/versioned-site/docs/slugs/tryToEscapeSlug.md +0 -5
  176. package/src/__tests__/__fixtures__/versioned-site/docusaurus.config.js +0 -18
  177. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  178. package/src/__tests__/__fixtures__/versioned-site/i18n/en/docusaurus-plugin-content-docs-community/current/team.md +0 -5
  179. package/src/__tests__/__fixtures__/versioned-site/i18n/fr/docusaurus-plugin-content-docs/version-1.0.0/hello.md +0 -1
  180. package/src/__tests__/__fixtures__/versioned-site/sidebars.json +0 -10
  181. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/bar.md +0 -4
  182. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/foo/baz.md +0 -1
  183. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.0/hello.md +0 -1
  184. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/foo/bar.md +0 -1
  185. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-1.0.1/hello.md +0 -1
  186. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootAbsoluteSlug.md +0 -5
  187. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootRelativeSlug.md +0 -5
  188. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootResolvedSlug.md +0 -5
  189. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/rootTryToEscapeSlug.md +0 -5
  190. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/absoluteSlug.md +0 -5
  191. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/relativeSlug.md +0 -5
  192. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/resolvedSlug.md +0 -5
  193. package/src/__tests__/__fixtures__/versioned-site/versioned_docs/version-withSlugs/slugs/tryToEscapeSlug.md +0 -5
  194. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.0-sidebars.json +0 -11
  195. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-1.0.1-sidebars.json +0 -10
  196. package/src/__tests__/__fixtures__/versioned-site/versioned_sidebars/version-withSlugs-sidebars.json +0 -5
  197. package/src/__tests__/__fixtures__/versioned-site/versions.json +0 -5
  198. package/src/__tests__/__snapshots__/cli.test.ts.snap +0 -90
  199. package/src/__tests__/__snapshots__/index.test.ts.snap +0 -1916
  200. package/src/__tests__/__snapshots__/sidebars.test.ts.snap +0 -218
  201. package/src/__tests__/__snapshots__/translations.test.ts.snap +0 -487
  202. package/src/__tests__/cli.test.ts +0 -333
  203. package/src/__tests__/docFrontMatter.test.ts +0 -244
  204. package/src/__tests__/docs.test.ts +0 -878
  205. package/src/__tests__/index.test.ts +0 -1871
  206. package/src/__tests__/lastUpdate.test.ts +0 -69
  207. package/src/__tests__/numberPrefix.test.ts +0 -199
  208. package/src/__tests__/options.test.ts +0 -231
  209. package/src/__tests__/sidebarItemsGenerator.test.ts +0 -336
  210. package/src/__tests__/sidebars.test.ts +0 -639
  211. package/src/__tests__/slug.test.ts +0 -109
  212. package/src/__tests__/translations.test.ts +0 -159
  213. package/src/__tests__/versions.test.ts +0 -741
  214. package/src/client/__tests__/docsClientUtils.test.ts +0 -371
  215. package/src/markdown/__tests__/__fixtures__/docs/doc-localized.md +0 -1
  216. package/src/markdown/__tests__/__fixtures__/docs/doc1.md +0 -13
  217. package/src/markdown/__tests__/__fixtures__/docs/doc2.md +0 -12
  218. package/src/markdown/__tests__/__fixtures__/docs/doc4.md +0 -19
  219. package/src/markdown/__tests__/__fixtures__/docs/doc5.md +0 -6
  220. package/src/markdown/__tests__/__fixtures__/docs/subdir/doc3.md +0 -3
  221. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/doc2.md +0 -7
  222. package/src/markdown/__tests__/__fixtures__/versioned_docs/version-1.0.0/subdir/doc1.md +0 -3
  223. package/src/markdown/__tests__/__snapshots__/linkify.test.ts.snap +0 -82
  224. package/src/markdown/__tests__/linkify.test.ts +0 -190
  225. package/src/sidebarItemsGenerator.ts +0 -307
  226. package/src/sidebars.ts +0 -522
  227. package/src/theme/hooks/useDocs.ts +0 -103
  228. package/src/versions.ts +0 -572
  229. package/tsconfig.json +0 -9
@@ -5,138 +5,691 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- /* eslint-disable camelcase */
8
+ /// <reference types="@docusaurus/module-type-aliases" />
9
9
 
10
- declare module '@docusaurus/plugin-content-docs-types' {
11
- import type {VersionBanner} from './types';
10
+ declare module '@docusaurus/plugin-content-docs' {
11
+ import type {MDXOptions} from '@docusaurus/mdx-loader';
12
+ import type {
13
+ ContentPaths,
14
+ FrontMatterTag,
15
+ TagsListItem,
16
+ TagModule,
17
+ Tag,
18
+ } from '@docusaurus/utils';
19
+ import type {Plugin, LoadContext} from '@docusaurus/types';
20
+ import type {Overwrite, Required} from 'utility-types';
12
21
 
13
- export type PermalinkToSidebar = {
14
- [permalink: string]: string;
22
+ export type Assets = {
23
+ image?: string;
15
24
  };
16
25
 
17
- export type PropVersionMetadata = {
18
- pluginId: string;
26
+ /**
27
+ * Custom callback for parsing number prefixes from file/folder names.
28
+ */
29
+ export type NumberPrefixParser = (filename: string) => {
30
+ /** File name without number prefix, without any other modification. */
31
+ filename: string;
32
+ /** The number prefix. Can be float, integer, negative, or anything. */
33
+ numberPrefix?: number;
34
+ };
35
+
36
+ export type CategoryIndexMatcher = (param: {
37
+ /** The file name, without extension */
38
+ fileName: string;
39
+ /**
40
+ * The list of directories, from lowest level to highest.
41
+ * If there's no dir name, directories is ['.']
42
+ */
43
+ directories: string[];
44
+ /** The extension, with a leading dot */
45
+ extension: string;
46
+ }) => boolean;
47
+
48
+ export type EditUrlFunction = (editUrlParams: {
49
+ /** Name of the version. */
19
50
  version: string;
51
+ /**
52
+ * Path of the version's root content path, relative to the site directory.
53
+ * Usually the same as `options.path` but can be localized or versioned.
54
+ */
55
+ versionDocsDirPath: string;
56
+ /** Path of the doc file, relative to `versionDocsDirPath`. */
57
+ docPath: string;
58
+ /** @see {@link DocMetadata.permalink} */
59
+ permalink: string;
60
+ /** Locale name. */
61
+ locale: string;
62
+ }) => string | undefined;
63
+
64
+ export type MetadataOptions = {
65
+ /**
66
+ * URL route for the docs section of your site. **DO NOT** include a
67
+ * trailing slash. Use `/` for shipping docs without base path.
68
+ */
69
+ routeBasePath: string;
70
+ /**
71
+ * Base URL to edit your site. The final URL is computed by `editUrl +
72
+ * relativeDocPath`. Using a function allows more nuanced control for each
73
+ * file. Omitting this variable entirely will disable edit links.
74
+ */
75
+ editUrl?: string | EditUrlFunction;
76
+ /**
77
+ * The edit URL will always target the current version doc instead of older
78
+ * versions. Ignored when `editUrl` is a function.
79
+ */
80
+ editCurrentVersion: boolean;
81
+ /**
82
+ * The edit URL will target the localized file, instead of the original
83
+ * unlocalized file. Ignored when `editUrl` is a function.
84
+ */
85
+ editLocalizedFiles: boolean;
86
+ /** Whether to display the last date the doc was updated. */
87
+ showLastUpdateTime?: boolean;
88
+ /** Whether to display the author who last updated the doc. */
89
+ showLastUpdateAuthor?: boolean;
90
+ /**
91
+ * Custom parsing logic to extract number prefixes from file names. Use
92
+ * `false` to disable this behavior and leave the docs untouched, and `true`
93
+ * to use the default parser.
94
+ *
95
+ * @param filename One segment of the path, without any slashes.
96
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
97
+ */
98
+ numberPrefixParser: NumberPrefixParser;
99
+ /** Enable or disable the breadcrumbs on doc pages. */
100
+ breadcrumbs: boolean;
101
+ };
102
+
103
+ export type PathOptions = {
104
+ /**
105
+ * Path to the docs content directory on the file system, relative to site
106
+ * directory.
107
+ */
108
+ path: string;
109
+ /**
110
+ * Path to sidebar configuration. Use `false` to disable sidebars, or
111
+ * `undefined` to create a fully autogenerated sidebar.
112
+ */
113
+ sidebarPath?: string | false | undefined;
114
+ };
115
+
116
+ // TODO support custom version banner?
117
+ // {type: "error", content: "html content"}
118
+ export type VersionBanner = 'unreleased' | 'unmaintained';
119
+ export type VersionsOptions = {
120
+ /**
121
+ * The version navigated to in priority and displayed by default for docs
122
+ * navbar items.
123
+ *
124
+ * @see https://docusaurus.io/docs/versioning#terminology
125
+ */
126
+ lastVersion?: string;
127
+ /** Only include a subset of all available versions. */
128
+ onlyIncludeVersions?: string[];
129
+ /**
130
+ * Explicitly disable versioning even when multiple versions exist. This
131
+ * will make the site only include the current version. Will error if
132
+ * `includeCurrentVersion: false` and `disableVersioning: true`.
133
+ */
134
+ disableVersioning: boolean;
135
+ /** Include the current version of your docs. */
136
+ includeCurrentVersion: boolean;
137
+ /** Independent customization of each version's properties. */
138
+ versions: {
139
+ [versionName: string]: {
140
+ /**
141
+ * The base path of the version, will be appended to `baseUrl` +
142
+ * `routeBasePath`.
143
+ */
144
+ path?: string;
145
+ /** The label of the version to be used in badges, dropdowns, etc. */
146
+ label?: string;
147
+ /** The banner to show at the top of a doc of that version. */
148
+ banner?: 'none' | VersionBanner;
149
+ /** Show a badge with the version label at the top of each doc. */
150
+ badge?: boolean;
151
+ /** Add a custom class name to the <html> element of each doc. */
152
+ className?: string;
153
+ };
154
+ };
155
+ };
156
+ export type SidebarOptions = {
157
+ /**
158
+ * Whether sidebar categories are collapsible by default.
159
+ *
160
+ * @see https://docusaurus.io/docs/sidebar#collapsible-categories
161
+ */
162
+ sidebarCollapsible: boolean;
163
+ /**
164
+ * Whether sidebar categories are collapsed by default.
165
+ *
166
+ * @see https://docusaurus.io/docs/sidebar#expanded-categories-by-default
167
+ */
168
+ sidebarCollapsed: boolean;
169
+ };
170
+
171
+ export type PluginOptions = MetadataOptions &
172
+ PathOptions &
173
+ VersionsOptions &
174
+ MDXOptions &
175
+ SidebarOptions & {
176
+ /** Plugin ID. */
177
+ id: string;
178
+ /**
179
+ * Array of glob patterns matching Markdown files to be built, relative to
180
+ * the content path.
181
+ */
182
+ include: string[];
183
+ /**
184
+ * Array of glob patterns matching Markdown files to be excluded. Serves
185
+ * as refinement based on the `include` option.
186
+ */
187
+ exclude: string[];
188
+ /**
189
+ * Root layout component of each doc page. Provides the version data
190
+ * context, and is not unmounted when switching docs.
191
+ */
192
+ docLayoutComponent: string;
193
+ /** Main doc container, with TOC, pagination, etc. */
194
+ docItemComponent: string;
195
+ /** Root component of the "docs containing tag X" page. */
196
+ docTagDocListComponent: string;
197
+ /** Root component of the tags list page */
198
+ docTagsListComponent: string;
199
+ /** Root component of the generated category index page. */
200
+ docCategoryGeneratedIndexComponent: string;
201
+ admonitions: {[key: string]: unknown};
202
+ sidebarItemsGenerator: import('./sidebars/types').SidebarItemsGeneratorOption;
203
+ /**
204
+ * URL route for the tags section of your doc version. Will be appended to
205
+ * `routeBasePath`. **DO NOT** include a trailing slash.
206
+ */
207
+ tagsBasePath: string;
208
+ };
209
+ export type Options = Partial<
210
+ Overwrite<
211
+ PluginOptions,
212
+ {
213
+ /**
214
+ * Custom parsing logic to extract number prefixes from file names. Use
215
+ * `false` to disable this behavior and leave the docs untouched, and
216
+ * `true` to use the default parser.
217
+ *
218
+ * @param filename One segment of the path, without any slashes.
219
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
220
+ */
221
+ numberPrefixParser: PluginOptions['numberPrefixParser'] | boolean;
222
+ }
223
+ >
224
+ >;
225
+ export type SidebarsConfig = import('./sidebars/types').SidebarsConfig;
226
+
227
+ export type VersionMetadata = ContentPaths & {
228
+ /** A name like `1.0.0`. Acquired from `versions.json`. */
229
+ versionName: string;
230
+ /** Like `Version 1.0.0`. Can be configured through `versions.label`. */
20
231
  label: string;
21
- banner: VersionBanner;
232
+ /**
233
+ * Version's base path in the form of `/<baseUrl>/<routeBasePath>/1.0.0`.
234
+ * Can be configured through `versions.path`.
235
+ */
236
+ path: string;
237
+ /** Tags base path in the form of `<versionPath>/tags`. */
238
+ tagsPath: string;
239
+ /**
240
+ * The base URL to which the doc file path will be appended. Will be
241
+ * `undefined` if `editUrl` is `undefined` or a function.
242
+ */
243
+ editUrl?: string | undefined;
244
+ /**
245
+ * The base URL to which the localized doc file path will be appended. Will
246
+ * be `undefined` if `editUrl` is `undefined` or a function.
247
+ */
248
+ editUrlLocalized?: string | undefined;
249
+ /**
250
+ * "unmaintained" is the version before latest; "unreleased" is the version
251
+ * after latest. `null` is the latest version without a banner. Can be
252
+ * configured with `versions.banner`: `banner: "none"` will be transformed
253
+ * to `null` here.
254
+ */
255
+ banner: VersionBanner | null;
256
+ /** Show a badge with the version label at the top of each doc. */
257
+ badge: boolean;
258
+ /** Add a custom class name to the <html> element of each doc. */
259
+ className: string;
260
+ /**
261
+ * Whether this version is the "last" version. Can be configured with
262
+ * `lastVersion` option.
263
+ */
22
264
  isLast: boolean;
23
- docsSidebars: PropSidebars;
24
- permalinkToSidebar: PermalinkToSidebar;
265
+ /**
266
+ * Like `versioned_sidebars/1.0.0.json`. Versioned sidebars file may be
267
+ * nonexistent since we don't create empty files.
268
+ */
269
+ sidebarFilePath: string | false | undefined;
270
+ /**
271
+ * Will be -1 for the latest docs, and `undefined` for everything else.
272
+ * Because `/docs/foo` should always be after `/docs/<versionName>/foo`.
273
+ */
274
+ routePriority: number | undefined;
25
275
  };
26
276
 
27
- type PropsSidebarItemBase = {
28
- customProps?: Record<string, unknown>;
277
+ export type DocFrontMatter = {
278
+ /**
279
+ * The last part of the doc ID (will be refactored in the future to be the
280
+ * full ID instead)
281
+ * @see {@link DocMetadata.id}
282
+ */
283
+ id?: string;
284
+ /**
285
+ * Will override the default title collected from h1 heading.
286
+ * @see {@link DocMetadata.title}
287
+ */
288
+ title?: string;
289
+ /**
290
+ * Front matter tags, unnormalized.
291
+ * @see {@link DocMetadata.tags}
292
+ */
293
+ tags?: FrontMatterTag[];
294
+ /**
295
+ * If there isn't a Markdown h1 heading (which, if there is, we don't
296
+ * remove), this front matter will cause the front matter title to not be
297
+ * displayed in the doc page.
298
+ */
299
+ hide_title?: boolean;
300
+ /** Hide the TOC on the right. */
301
+ hide_table_of_contents?: boolean;
302
+ /** Used in the head meta. */
303
+ keywords?: string[];
304
+ /** Used in the head meta. Should use `assets.image` in priority. */
305
+ image?: string;
306
+ /**
307
+ * Will override the default excerpt.
308
+ * @see {@link DocMetadata.description}
309
+ */
310
+ description?: string;
311
+ /**
312
+ * Custom slug appended after /<baseUrl>/<routeBasePath>/<versionPath>
313
+ * @see {@link DocMetadata.slug}
314
+ */
315
+ slug?: string;
316
+ /** Customizes the sidebar label for this doc. Will default to its title. */
317
+ sidebar_label?: string;
318
+ /**
319
+ * Controls the position of a doc inside the generated sidebar slice when
320
+ * using autogenerated sidebar items.
321
+ *
322
+ * @see https://docusaurus.io/docs/sidebar#autogenerated-sidebar-metadata
323
+ */
324
+ sidebar_position?: number;
325
+ /**
326
+ * Gives the corresponding sidebar label a special class name when using
327
+ * autogenerated sidebars.
328
+ */
329
+ sidebar_class_name?: string;
330
+ /**
331
+ * Will be propagated to the final sidebars data structure. Useful if you
332
+ * have swizzled sidebar-related code or simply querying doc data through
333
+ * sidebars.
334
+ */
335
+ sidebar_custom_props?: {[key: string]: unknown};
336
+ /**
337
+ * Changes the sidebar association of the current doc. Use `null` to make
338
+ * the current doc not associated to any sidebar.
339
+ */
340
+ displayed_sidebar?: string | null;
341
+ /**
342
+ * Customizes the pagination label for this doc. Will default to the sidebar
343
+ * label.
344
+ */
345
+ pagination_label?: string;
346
+ /** Overrides the default URL computed for this doc. */
347
+ custom_edit_url?: string | null;
348
+ /**
349
+ * Whether number prefix parsing is disabled on this doc.
350
+ * @see https://docusaurus.io/docs/sidebar#using-number-prefixes
351
+ */
352
+ parse_number_prefixes?: boolean;
353
+ /**
354
+ * Minimum TOC heading level. Must be between 2 and 6 and lower or equal to
355
+ * the max value.
356
+ */
357
+ toc_min_heading_level?: number;
358
+ /** Maximum TOC heading level. Must be between 2 and 6. */
359
+ toc_max_heading_level?: number;
360
+ /**
361
+ * The ID of the documentation you want the "Next" pagination to link to.
362
+ * Use `null` to disable showing "Next" for this page.
363
+ * @see {@link DocMetadata.next}
364
+ */
365
+ pagination_next?: string | null;
366
+ /**
367
+ * The ID of the documentation you want the "Previous" pagination to link
368
+ * to. Use `null` to disable showing "Previous" for this page.
369
+ * @see {@link DocMetadata.prev}
370
+ */
371
+ pagination_prev?: string | null;
372
+ /** Should this doc be excluded from production builds? */
373
+ draft?: boolean;
29
374
  };
30
375
 
31
- export type PropSidebarItemLink = PropsSidebarItemBase & {
32
- type: 'link';
33
- href: string;
34
- label: string;
376
+ export type LastUpdateData = {
377
+ /** A timestamp in **seconds**, directly acquired from `git log`. */
378
+ lastUpdatedAt?: number;
379
+ /** `lastUpdatedAt` formatted as a date according to the current locale. */
380
+ formattedLastUpdatedAt?: string;
381
+ /** The author's name directly acquired from `git log`. */
382
+ lastUpdatedBy?: string;
35
383
  };
36
384
 
37
- export type PropSidebarItemCategory = PropsSidebarItemBase & {
38
- type: 'category';
39
- label: string;
40
- items: PropSidebarItem[];
41
- collapsed?: boolean;
385
+ export type DocMetadataBase = LastUpdateData & {
386
+ // TODO
387
+ /**
388
+ * Legacy versioned ID. Will be refactored in the future to be unversioned.
389
+ */
390
+ id: string;
391
+ // TODO
392
+ /**
393
+ * Unversioned ID. Should be preferred everywhere over `id` until the latter
394
+ * is refactored.
395
+ */
396
+ unversionedId: string;
397
+ /** The name of the version this doc belongs to. */
398
+ version: string;
399
+ /**
400
+ * Used to generate the page h1 heading, tab title, and pagination title.
401
+ */
402
+ title: string;
403
+ /**
404
+ * Description used in the meta. Could be an empty string (empty content)
405
+ */
406
+ description: string;
407
+ /** Path to the Markdown source, with `@site` alias. */
408
+ source: string;
409
+ /**
410
+ * Posix path relative to the content path. Can be `"."`.
411
+ * e.g. "folder/subfolder/subsubfolder"
412
+ */
413
+ sourceDirName: string;
414
+ /** `permalink` without base URL or version path. */
415
+ slug: string;
416
+ /** Full URL to this doc, with base URL and version path. */
417
+ permalink: string;
418
+ /**
419
+ * Draft docs will be excluded for production environment.
420
+ */
421
+ draft: boolean;
422
+ /**
423
+ * Position in an autogenerated sidebar slice, acquired through front matter
424
+ * or number prefix.
425
+ */
426
+ sidebarPosition?: number;
427
+ /**
428
+ * Acquired from the options; can be customized with front matter.
429
+ * `custom_edit_url` will always lead to it being null, but you should treat
430
+ * `undefined` and `null` as equivalent.
431
+ */
432
+ editUrl?: string | null;
433
+ /** Tags, normalized. */
434
+ tags: Tag[];
435
+ /** Front matter, as-is. */
436
+ frontMatter: DocFrontMatter & {[key: string]: unknown};
437
+ };
438
+
439
+ export type DocMetadata = DocMetadataBase &
440
+ PropNavigation & {
441
+ /** Name of the sidebar this doc is associated with. */
442
+ sidebar?: string;
443
+ };
444
+
445
+ export type CategoryGeneratedIndexMetadata = Required<
446
+ Omit<
447
+ import('./sidebars/types').SidebarItemCategoryLinkGeneratedIndex,
448
+ 'type'
449
+ >,
450
+ 'title'
451
+ > & {
452
+ navigation: PropNavigation;
453
+ /**
454
+ * Name of the sidebar this doc is associated with. Unlike
455
+ * `DocMetadata.sidebar`, this will always be defined, because a generated
456
+ * index can only be generated from a category.
457
+ */
458
+ sidebar: string;
459
+ };
460
+
461
+ export type PropNavigationLink = {
462
+ readonly title: string;
463
+ readonly permalink: string;
464
+ };
465
+ export type PropNavigation = {
466
+ /**
467
+ * Used in pagination. Content is just a subset of another doc's metadata.
468
+ */
469
+ readonly previous?: PropNavigationLink;
470
+ /**
471
+ * Used in pagination. Content is just a subset of another doc's metadata.
472
+ */
473
+ readonly next?: PropNavigationLink;
42
474
  };
43
475
 
44
- export type PropSidebarItem = PropSidebarItemLink | PropSidebarItemCategory;
476
+ export type PropVersionDoc = Pick<
477
+ DocMetadata,
478
+ 'id' | 'title' | 'description' | 'sidebar'
479
+ >;
45
480
 
46
- export type PropSidebars = {
47
- [sidebarId: string]: PropSidebarItem[];
481
+ export type PropVersionDocs = {
482
+ [docId: string]: PropVersionDoc;
48
483
  };
49
484
 
50
- export type {
51
- GlobalVersion as GlobalDataVersion,
52
- GlobalDoc as GlobalDataDoc,
53
- } from './types';
485
+ export type PropVersionMetadata = Pick<
486
+ VersionMetadata,
487
+ 'label' | 'banner' | 'badge' | 'className' | 'isLast'
488
+ > & {
489
+ /** ID of the docs plugin this version belongs to. */
490
+ pluginId: string;
491
+ /** Name of this version. */
492
+ version: string;
493
+ /** Sidebars contained in this version. */
494
+ docsSidebars: PropSidebars;
495
+ /** Docs contained in this version. */
496
+ docs: PropVersionDocs;
497
+ };
498
+
499
+ export type PropCategoryGeneratedIndex = Omit<
500
+ CategoryGeneratedIndexMetadata,
501
+ 'sidebar'
502
+ >;
503
+
504
+ export type PropSidebarItemLink =
505
+ import('./sidebars/types').PropSidebarItemLink;
506
+ export type PropSidebarItemHtml =
507
+ import('./sidebars/types').PropSidebarItemHtml;
508
+ export type PropSidebarItemCategory =
509
+ import('./sidebars/types').PropSidebarItemCategory;
510
+ export type PropSidebarItem = import('./sidebars/types').PropSidebarItem;
511
+ export type PropSidebarBreadcrumbsItem =
512
+ import('./sidebars/types').PropSidebarBreadcrumbsItem;
513
+ export type PropSidebar = import('./sidebars/types').PropSidebar;
514
+ export type PropSidebars = import('./sidebars/types').PropSidebars;
515
+
516
+ export type PropTagDocListDoc = Pick<
517
+ DocMetadata,
518
+ 'id' | 'title' | 'description' | 'permalink'
519
+ >;
520
+ export type PropTagDocList = TagModule & {items: PropTagDocListDoc[]};
521
+
522
+ export type PropTagsListPage = {
523
+ tags: TagsListItem[];
524
+ };
525
+
526
+ export type LoadedVersion = VersionMetadata & {
527
+ docs: DocMetadata[];
528
+ drafts: DocMetadata[];
529
+ sidebars: import('./sidebars/types').Sidebars;
530
+ };
531
+
532
+ export type LoadedContent = {
533
+ loadedVersions: LoadedVersion[];
534
+ };
535
+
536
+ export default function pluginContentDocs(
537
+ context: LoadContext,
538
+ options: PluginOptions,
539
+ ): Promise<Plugin<LoadedContent>>;
54
540
  }
55
541
 
56
542
  declare module '@theme/DocItem' {
57
- import type {TOCItem} from '@docusaurus/types';
543
+ import type {LoadedMDXContent} from '@docusaurus/mdx-loader';
544
+ import type {
545
+ PropVersionMetadata,
546
+ Assets,
547
+ DocMetadata,
548
+ DocFrontMatter,
549
+ } from '@docusaurus/plugin-content-docs';
58
550
 
59
551
  export type DocumentRoute = {
60
552
  readonly component: () => JSX.Element;
61
553
  readonly exact: boolean;
62
554
  readonly path: string;
555
+ readonly sidebar?: string;
63
556
  };
64
557
 
65
- export type FrontMatter = {
66
- readonly id: string;
67
- readonly title: string;
68
- readonly image?: string;
69
- readonly keywords?: readonly string[];
70
- readonly hide_title?: boolean;
71
- readonly hide_table_of_contents?: boolean;
72
- };
73
-
74
- export type Metadata = {
75
- readonly description?: string;
76
- readonly title?: string;
77
- readonly permalink?: string;
78
- readonly editUrl?: string;
79
- readonly lastUpdatedAt?: number;
80
- readonly formattedLastUpdatedAt?: string;
81
- readonly lastUpdatedBy?: string;
82
- readonly version?: string;
83
- readonly previous?: {readonly permalink: string; readonly title: string};
84
- readonly next?: {readonly permalink: string; readonly title: string};
85
- };
86
-
87
- export type Props = {
558
+ export interface Props {
88
559
  readonly route: DocumentRoute;
89
560
  readonly versionMetadata: PropVersionMetadata;
90
- readonly content: {
91
- readonly frontMatter: FrontMatter;
92
- readonly metadata: Metadata;
93
- readonly toc: readonly TOCItem[];
94
- readonly contentTitle: string | undefined;
95
- (): JSX.Element;
96
- };
97
- };
561
+ readonly content: LoadedMDXContent<DocFrontMatter, DocMetadata, Assets>;
562
+ }
98
563
 
99
- const DocItem: (props: Props) => JSX.Element;
100
- export default DocItem;
564
+ export default function DocItem(props: Props): JSX.Element;
101
565
  }
102
566
 
103
- declare module '@theme/DocVersionBanner' {
104
- import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
567
+ declare module '@theme/DocCategoryGeneratedIndexPage' {
568
+ import type {PropCategoryGeneratedIndex} from '@docusaurus/plugin-content-docs';
105
569
 
106
- export type Props = {
107
- readonly versionMetadata: PropVersionMetadata;
108
- };
570
+ export interface Props {
571
+ readonly categoryGeneratedIndex: PropCategoryGeneratedIndex;
572
+ }
573
+
574
+ export default function DocCategoryGeneratedIndexPage(
575
+ props: Props,
576
+ ): JSX.Element;
577
+ }
578
+
579
+ declare module '@theme/DocTagsListPage' {
580
+ import type {PropTagsListPage} from '@docusaurus/plugin-content-docs';
581
+
582
+ export interface Props extends PropTagsListPage {}
583
+ export default function DocTagsListPage(props: Props): JSX.Element;
584
+ }
585
+
586
+ declare module '@theme/DocTagDocListPage' {
587
+ import type {PropTagDocList} from '@docusaurus/plugin-content-docs';
109
588
 
110
- const DocVersionBanner: (props: Props) => JSX.Element;
111
- export default DocVersionBanner;
589
+ export interface Props {
590
+ readonly tag: PropTagDocList;
591
+ }
592
+ export default function DocTagDocListPage(props: Props): JSX.Element;
593
+ }
594
+
595
+ declare module '@theme/DocBreadcrumbs' {
596
+ export default function DocBreadcrumbs(): JSX.Element;
112
597
  }
113
598
 
114
599
  declare module '@theme/DocPage' {
115
- import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs-types';
116
- import type {DocumentRoute} from '@theme/DocItem';
600
+ import type {PropVersionMetadata} from '@docusaurus/plugin-content-docs';
601
+ import type {RouteConfigComponentProps} from 'react-router-config';
602
+ import type {Required} from 'utility-types';
117
603
 
118
- export type Props = {
119
- readonly location: {readonly pathname: string};
604
+ export interface Props extends Required<RouteConfigComponentProps, 'route'> {
120
605
  readonly versionMetadata: PropVersionMetadata;
121
- readonly route: {
122
- readonly path: string;
123
- readonly component: () => JSX.Element;
124
- readonly routes: DocumentRoute[];
125
- };
126
- };
606
+ }
127
607
 
128
- const DocPage: (props: Props) => JSX.Element;
129
- export default DocPage;
608
+ export default function DocPage(props: Props): JSX.Element;
130
609
  }
131
610
 
132
- declare module '@theme/Seo' {
133
- export type Props = {
134
- readonly title?: string;
135
- readonly description?: string;
136
- readonly keywords?: readonly string[] | string;
137
- readonly image?: string;
611
+ // TODO TS only supports reading `exports` in 4.7. We will need to merge the
612
+ // type defs (and JSDoc) here with the implementation after that
613
+ declare module '@docusaurus/plugin-content-docs/client' {
614
+ import type {UseDataOptions} from '@docusaurus/types';
615
+
616
+ export type ActivePlugin = {
617
+ pluginId: string;
618
+ pluginData: GlobalPluginData;
619
+ };
620
+ export type ActiveDocContext = {
621
+ activeVersion?: GlobalVersion;
622
+ activeDoc?: GlobalDoc;
623
+ alternateDocVersions: {[versionName: string]: GlobalDoc};
624
+ };
625
+ export type GlobalDoc = {
626
+ /**
627
+ * For generated index pages, this is the `slug`, **not** `permalink`
628
+ * (without base URL). Because slugs have leading slashes but IDs don't,
629
+ * there won't be clashes.
630
+ */
631
+ id: string;
632
+ path: string;
633
+ sidebar: string | undefined;
634
+ };
635
+
636
+ export type GlobalVersion = {
637
+ name: string;
638
+ label: string;
639
+ isLast: boolean;
640
+ path: string;
641
+ /** The doc with `slug: /`, or first doc in first sidebar */
642
+ mainDocId: string;
643
+ docs: GlobalDoc[];
644
+ /** Unversioned IDs. In development, this list is empty. */
645
+ draftIds: string[];
646
+ sidebars?: {[sidebarId: string]: GlobalSidebar};
647
+ };
648
+
649
+ export type GlobalSidebar = {
650
+ link?: {
651
+ label: string;
652
+ path: string;
653
+ };
654
+ // ... we may add other things here later
655
+ };
656
+ export type GlobalPluginData = {
657
+ path: string;
658
+ versions: GlobalVersion[];
659
+ breadcrumbs: boolean;
660
+ };
661
+ export type DocVersionSuggestions = {
662
+ /** Suggest the latest version */
663
+ latestVersionSuggestion: GlobalVersion;
664
+ /** Suggest the same doc, in latest version (if one exists) */
665
+ latestDocSuggestion?: GlobalDoc;
138
666
  };
139
667
 
140
- const Seo: (props: Props) => JSX.Element;
141
- export default Seo;
668
+ export const useAllDocsData: () => {[pluginId: string]: GlobalPluginData};
669
+ export const useDocsData: (pluginId?: string) => GlobalPluginData;
670
+ export const useActivePlugin: (
671
+ options?: UseDataOptions,
672
+ ) => ActivePlugin | undefined;
673
+ export const useActivePluginAndVersion: (
674
+ options?: UseDataOptions,
675
+ ) =>
676
+ | {activePlugin: ActivePlugin; activeVersion: GlobalVersion | undefined}
677
+ | undefined;
678
+ /** Versions are returned ordered (most recent first). */
679
+ export const useVersions: (pluginId?: string) => GlobalVersion[];
680
+ export const useLatestVersion: (pluginId?: string) => GlobalVersion;
681
+ /**
682
+ * Returns `undefined` on doc-unrelated pages, because there's no version
683
+ * currently considered as active.
684
+ */
685
+ export const useActiveVersion: (
686
+ pluginId?: string,
687
+ ) => GlobalVersion | undefined;
688
+ export const useActiveDocContext: (pluginId?: string) => ActiveDocContext;
689
+ /**
690
+ * Useful to say "hey, you are not on the latest docs version, please switch"
691
+ */
692
+ export const useDocVersionSuggestions: (
693
+ pluginId?: string,
694
+ ) => DocVersionSuggestions;
142
695
  }