@docusaurus/plugin-content-docs 2.0.0-beta.1decd6f80 → 2.0.0-beta.20

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