@docusaurus/plugin-content-docs 0.0.0-4524 → 0.0.0-4525

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/cli.d.ts CHANGED
@@ -5,4 +5,4 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
  import type { PathOptions, SidebarOptions } from '@docusaurus/plugin-content-docs';
8
- export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): void;
8
+ export declare function cliDocsVersionCommand(version: string | null | undefined, siteDir: string, pluginId: string, options: PathOptions & SidebarOptions): Promise<void>;
package/lib/cli.js CHANGED
@@ -14,11 +14,11 @@ const path_1 = (0, tslib_1.__importDefault)(require("path"));
14
14
  const sidebars_1 = require("./sidebars");
15
15
  const utils_1 = require("@docusaurus/utils");
16
16
  const logger_1 = (0, tslib_1.__importDefault)(require("@docusaurus/logger"));
17
- function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
17
+ async function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }) {
18
18
  // Load current sidebar and create a new versioned sidebars file (if needed).
19
19
  // Note: we don't need the sidebars file to be normalized: it's ok to let
20
20
  // plugin option changes to impact older, versioned sidebars
21
- const sidebars = (0, sidebars_1.loadSidebarsFile)(sidebarPath);
21
+ const sidebars = await (0, sidebars_1.loadSidebarsFile)(sidebarPath);
22
22
  // Do not create a useless versioned sidebars file if sidebars file is empty
23
23
  // or sidebars are disabled/false)
24
24
  const shouldCreateVersionedSidebarFile = Object.keys(sidebars).length > 0;
@@ -30,7 +30,7 @@ function createVersionedSidebarFile({ siteDir, pluginId, sidebarPath, version, }
30
30
  }
31
31
  }
32
32
  // Tests depend on non-default export for mocking.
33
- function cliDocsVersionCommand(version, siteDir, pluginId, options) {
33
+ async function cliDocsVersionCommand(version, siteDir, pluginId, options) {
34
34
  // It wouldn't be very user-friendly to show a [default] log prefix,
35
35
  // so we use [docs] instead of [default]
36
36
  const pluginIdLogPrefix = pluginId === utils_1.DEFAULT_PLUGIN_ID ? '[docs]' : `[${pluginId}]`;
@@ -73,7 +73,7 @@ function cliDocsVersionCommand(version, siteDir, pluginId, options) {
73
73
  else {
74
74
  throw new Error(`${pluginIdLogPrefix}: there is no docs to version!`);
75
75
  }
76
- createVersionedSidebarFile({
76
+ await createVersionedSidebarFile({
77
77
  siteDir,
78
78
  pluginId,
79
79
  version,
@@ -11,6 +11,6 @@ import type { PluginOptions } from '@docusaurus/plugin-content-docs';
11
11
  export declare const DefaultSidebars: SidebarsConfig;
12
12
  export declare const DisabledSidebars: SidebarsConfig;
13
13
  export declare function resolveSidebarPathOption(siteDir: string, sidebarPathOption: PluginOptions['sidebarPath']): PluginOptions['sidebarPath'];
14
- export declare function loadSidebarsFile(sidebarFilePath: string | false | undefined): SidebarsConfig;
15
- export declare function loadNormalizedSidebars(sidebarFilePath: string | false | undefined, params: NormalizeSidebarsParams): NormalizedSidebars;
14
+ export declare function loadSidebarsFile(sidebarFilePath: string | false | undefined): Promise<SidebarsConfig>;
15
+ export declare function loadNormalizedSidebars(sidebarFilePath: string | false | undefined, params: NormalizeSidebarsParams): Promise<NormalizedSidebars>;
16
16
  export declare function loadSidebars(sidebarFilePath: string | false | undefined, options: SidebarProcessorParams): Promise<Sidebars>;
@@ -32,7 +32,7 @@ function resolveSidebarPathOption(siteDir, sidebarPathOption) {
32
32
  : sidebarPathOption;
33
33
  }
34
34
  exports.resolveSidebarPathOption = resolveSidebarPathOption;
35
- function loadSidebarsFileUnsafe(sidebarFilePath) {
35
+ async function loadSidebarsFileUnsafe(sidebarFilePath) {
36
36
  // false => no sidebars
37
37
  if (sidebarFilePath === false) {
38
38
  return exports.DisabledSidebars;
@@ -50,14 +50,14 @@ function loadSidebarsFileUnsafe(sidebarFilePath) {
50
50
  // We don't want sidebars to be cached because of hot reloading.
51
51
  return (0, import_fresh_1.default)(sidebarFilePath);
52
52
  }
53
- function loadSidebarsFile(sidebarFilePath) {
54
- const sidebarsConfig = loadSidebarsFileUnsafe(sidebarFilePath);
53
+ async function loadSidebarsFile(sidebarFilePath) {
54
+ const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
55
55
  (0, validation_1.validateSidebars)(sidebarsConfig);
56
56
  return sidebarsConfig;
57
57
  }
58
58
  exports.loadSidebarsFile = loadSidebarsFile;
59
- function loadNormalizedSidebars(sidebarFilePath, params) {
60
- return (0, normalization_1.normalizeSidebars)(loadSidebarsFile(sidebarFilePath), params);
59
+ async function loadNormalizedSidebars(sidebarFilePath, params) {
60
+ return (0, normalization_1.normalizeSidebars)(await loadSidebarsFile(sidebarFilePath), params);
61
61
  }
62
62
  exports.loadNormalizedSidebars = loadNormalizedSidebars;
63
63
  // Note: sidebarFilePath must be absolute, use resolveSidebarPathOption
@@ -67,7 +67,7 @@ async function loadSidebars(sidebarFilePath, options) {
67
67
  version: options.version,
68
68
  categoryLabelSlugger: (0, utils_1.createSlugger)(),
69
69
  };
70
- const normalizedSidebars = loadNormalizedSidebars(sidebarFilePath, normalizeSidebarsParams);
70
+ const normalizedSidebars = await loadNormalizedSidebars(sidebarFilePath, normalizeSidebarsParams);
71
71
  return (0, processor_1.processSidebars)(normalizedSidebars, options);
72
72
  }
73
73
  exports.loadSidebars = loadSidebars;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docusaurus/plugin-content-docs",
3
- "version": "0.0.0-4524",
3
+ "version": "0.0.0-4525",
4
4
  "description": "Docs plugin for Docusaurus.",
5
5
  "main": "lib/index.js",
6
6
  "exports": {
@@ -22,11 +22,11 @@
22
22
  },
23
23
  "license": "MIT",
24
24
  "dependencies": {
25
- "@docusaurus/core": "0.0.0-4524",
26
- "@docusaurus/logger": "0.0.0-4524",
27
- "@docusaurus/mdx-loader": "0.0.0-4524",
28
- "@docusaurus/utils": "0.0.0-4524",
29
- "@docusaurus/utils-validation": "0.0.0-4524",
25
+ "@docusaurus/core": "0.0.0-4525",
26
+ "@docusaurus/logger": "0.0.0-4525",
27
+ "@docusaurus/mdx-loader": "0.0.0-4525",
28
+ "@docusaurus/utils": "0.0.0-4525",
29
+ "@docusaurus/utils-validation": "0.0.0-4525",
30
30
  "combine-promises": "^1.1.0",
31
31
  "fs-extra": "^10.0.0",
32
32
  "import-fresh": "^3.2.2",
@@ -39,8 +39,8 @@
39
39
  "webpack": "^5.61.0"
40
40
  },
41
41
  "devDependencies": {
42
- "@docusaurus/module-type-aliases": "0.0.0-4524",
43
- "@docusaurus/types": "0.0.0-4524",
42
+ "@docusaurus/module-type-aliases": "0.0.0-4525",
43
+ "@docusaurus/types": "0.0.0-4525",
44
44
  "@types/js-yaml": "^4.0.0",
45
45
  "@types/picomatch": "^2.2.1",
46
46
  "commander": "^5.1.0",
@@ -56,5 +56,5 @@
56
56
  "engines": {
57
57
  "node": ">=14"
58
58
  },
59
- "gitHead": "41a6bff3a67446f7d2a2972cbe4d05fec7378a15"
59
+ "gitHead": "c1122ee21d114f85261bed9b8296ab3501454098"
60
60
  }
package/src/cli.ts CHANGED
@@ -20,7 +20,7 @@ import {loadSidebarsFile, resolveSidebarPathOption} from './sidebars';
20
20
  import {DEFAULT_PLUGIN_ID} from '@docusaurus/utils';
21
21
  import logger from '@docusaurus/logger';
22
22
 
23
- function createVersionedSidebarFile({
23
+ async function createVersionedSidebarFile({
24
24
  siteDir,
25
25
  pluginId,
26
26
  sidebarPath,
@@ -34,7 +34,7 @@ function createVersionedSidebarFile({
34
34
  // Load current sidebar and create a new versioned sidebars file (if needed).
35
35
  // Note: we don't need the sidebars file to be normalized: it's ok to let
36
36
  // plugin option changes to impact older, versioned sidebars
37
- const sidebars = loadSidebarsFile(sidebarPath);
37
+ const sidebars = await loadSidebarsFile(sidebarPath);
38
38
 
39
39
  // Do not create a useless versioned sidebars file if sidebars file is empty
40
40
  // or sidebars are disabled/false)
@@ -56,12 +56,12 @@ function createVersionedSidebarFile({
56
56
  }
57
57
 
58
58
  // Tests depend on non-default export for mocking.
59
- export function cliDocsVersionCommand(
59
+ export async function cliDocsVersionCommand(
60
60
  version: string | null | undefined,
61
61
  siteDir: string,
62
62
  pluginId: string,
63
63
  options: PathOptions & SidebarOptions,
64
- ): void {
64
+ ): Promise<void> {
65
65
  // It wouldn't be very user-friendly to show a [default] log prefix,
66
66
  // so we use [docs] instead of [default]
67
67
  const pluginIdLogPrefix =
@@ -127,7 +127,7 @@ export function cliDocsVersionCommand(
127
127
  throw new Error(`${pluginIdLogPrefix}: there is no docs to version!`);
128
128
  }
129
129
 
130
- createVersionedSidebarFile({
130
+ await createVersionedSidebarFile({
131
131
  siteDir,
132
132
  pluginId,
133
133
  version,
@@ -38,9 +38,9 @@ export function resolveSidebarPathOption(
38
38
  : sidebarPathOption;
39
39
  }
40
40
 
41
- function loadSidebarsFileUnsafe(
41
+ async function loadSidebarsFileUnsafe(
42
42
  sidebarFilePath: string | false | undefined,
43
- ): SidebarsConfig {
43
+ ): Promise<SidebarsConfig> {
44
44
  // false => no sidebars
45
45
  if (sidebarFilePath === false) {
46
46
  return DisabledSidebars;
@@ -62,19 +62,19 @@ function loadSidebarsFileUnsafe(
62
62
  return importFresh(sidebarFilePath);
63
63
  }
64
64
 
65
- export function loadSidebarsFile(
65
+ export async function loadSidebarsFile(
66
66
  sidebarFilePath: string | false | undefined,
67
- ): SidebarsConfig {
68
- const sidebarsConfig = loadSidebarsFileUnsafe(sidebarFilePath);
67
+ ): Promise<SidebarsConfig> {
68
+ const sidebarsConfig = await loadSidebarsFileUnsafe(sidebarFilePath);
69
69
  validateSidebars(sidebarsConfig);
70
70
  return sidebarsConfig;
71
71
  }
72
72
 
73
- export function loadNormalizedSidebars(
73
+ export async function loadNormalizedSidebars(
74
74
  sidebarFilePath: string | false | undefined,
75
75
  params: NormalizeSidebarsParams,
76
- ): NormalizedSidebars {
77
- return normalizeSidebars(loadSidebarsFile(sidebarFilePath), params);
76
+ ): Promise<NormalizedSidebars> {
77
+ return normalizeSidebars(await loadSidebarsFile(sidebarFilePath), params);
78
78
  }
79
79
 
80
80
  // Note: sidebarFilePath must be absolute, use resolveSidebarPathOption
@@ -87,7 +87,7 @@ export async function loadSidebars(
87
87
  version: options.version,
88
88
  categoryLabelSlugger: createSlugger(),
89
89
  };
90
- const normalizedSidebars = loadNormalizedSidebars(
90
+ const normalizedSidebars = await loadNormalizedSidebars(
91
91
  sidebarFilePath,
92
92
  normalizeSidebarsParams,
93
93
  );