@alauda/doom 1.22.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/eslint.js CHANGED
@@ -68,6 +68,8 @@ async function doom(userConfigOrRoot) {
68
68
  {
69
69
  files: ['**/*.mdx'],
70
70
  rules: {
71
+ '@eslint-react/jsx-no-children-prop': 'off',
72
+ '@eslint-react/rules-of-hooks': 'off',
71
73
  'no-unused-expressions': 'off',
72
74
  },
73
75
  },
@@ -1,26 +1,5 @@
1
1
  /**
2
- * modified based on @see https://github.com/crdsdev/doc/blob/main/template/doc.html
2
+ * @deprecated Use `K8sAPI` component instead
3
3
  */
4
- import type { OpenAPIV3_1 } from 'openapi-types';
5
- export interface K8sCrdProps {
6
- /**
7
- * The `metadata.name` of the CustomResourceDefinition
8
- */
9
- name: string;
10
- /**
11
- * The specific path to the CRD, otherwise the first matched will be used.
12
- */
13
- crdPath?: string;
14
- }
15
- export declare const K8sCrdSchemaPart: ({ name, parent, schema: property, expandAll, }: {
16
- name: string;
17
- parent: OpenAPIV3_1.SchemaObject;
18
- schema: OpenAPIV3_1.SchemaObject;
19
- expandAll: boolean;
20
- }) => import("react/jsx-runtime").JSX.Element;
21
- export declare const K8sCrdSchema: ({ schema, version, }: {
22
- schema: OpenAPIV3_1.SchemaObject;
23
- version: string;
24
- }) => import("react/jsx-runtime").JSX.Element;
25
- export declare const K8sCrd: ({ name, crdPath }: K8sCrdProps) => import("react/jsx-runtime").JSX.Element | null;
4
+ export declare const K8sCrd: ({ name, namespaced, pathPrefix, filepath, apiGroup, apiVersion, apiKind, }: import("./K8sAPI.js").K8sAPIProps) => import("react/jsx-runtime").JSX.Element | null;
26
5
  export default K8sCrd;
@@ -1,69 +1,7 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { K8sAPI } from './K8sAPI.js';
2
2
  /**
3
- * modified based on @see https://github.com/crdsdev/doc/blob/main/template/doc.html
3
+ * @deprecated Use `K8sAPI` component instead
4
4
  */
5
- import { Badge, Button } from '@rspress/core/theme-original';
6
- import crdsMap from 'doom-@api-crdsMap';
7
- import { useCallback, useEffect, useMemo, useState } from 'react';
8
- import { useIsPrint, useTranslation } from '../hooks/index.js';
9
- import { Directive } from './Directive.js';
10
- import { Markdown } from './Markdown.js';
11
- import { X } from './_X.js';
12
- export const K8sCrdSchemaPart = ({ name, parent, schema: property, expandAll, }) => {
13
- const [open, setOpen] = useState(expandAll);
14
- const onToggle = useCallback((open) => {
15
- setOpen(open);
16
- }, []);
17
- useEffect(() => {
18
- // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
19
- setOpen(expandAll);
20
- }, [expandAll]);
21
- const [props, required, type, schema] = useMemo(() => {
22
- let schema = property;
23
- let props = property.properties;
24
- let type = property.type;
25
- if (property.type === 'array') {
26
- const itemsSchema = property.items;
27
- if (itemsSchema.type === 'object') {
28
- schema = itemsSchema;
29
- props = itemsSchema.properties;
30
- type = `[]object`;
31
- }
32
- else if (itemsSchema.type) {
33
- type = `[]${itemsSchema.type}`;
34
- }
35
- }
36
- let required = false;
37
- if (parent.required?.includes(name)) {
38
- required = true;
39
- }
40
- return [props, required, type, schema];
41
- }, [name, parent, property]);
42
- return (_jsx(_Fragment, { children: _jsxs(Directive, { type: "details", title: _jsxs(_Fragment, { children: [name, type && (_jsxs(_Fragment, { children: [' ', _jsx("code", { children: type })] })), required && (_jsxs(_Fragment, { children: [' ', _jsx(Badge, { children: "required" })] }))] }), open: open, onToggle: onToggle, children: [_jsx(Markdown, { children: schema.description }), props &&
43
- Object.entries(props).map(([name, subSchema]) => (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name)))] }) }));
44
- };
45
- const SKIPPED_PROPERTIES = ['apiVersion', 'kind', 'metadata'];
46
- export const K8sCrdSchema = ({ schema, version, }) => {
47
- const { description, properties } = schema;
48
- const isPrint = useIsPrint();
49
- const t = useTranslation();
50
- const [expandAll, setExpandAll] = useState(isPrint);
51
- const toggleExpandAll = useCallback(() => {
52
- setExpandAll((all) => !all);
53
- }, []);
54
- return (_jsxs(_Fragment, { children: [_jsx(Markdown, { children: description }), _jsxs("div", { className: "rp-flex rp-items-center", children: [_jsxs("span", { children: [_jsx("code", { children: version }), " ", _jsx(Badge, { children: "version" })] }), !isPrint && properties != null && (_jsx(Button, { className: "rp-ml-auto doom-btn", type: "button", size: "medium", theme: "alt", children: _jsxs("span", { onClick: toggleExpandAll, children: [expandAll ? '-' : '+', ' ', t(expandAll ? 'collapse_all' : 'expand_all')] }) }))] }), properties == null ? (_jsx(Directive, { type: "warning", children: t('crd_no_schema') })) : (_jsx("div", { className: "doom-collapse-group", children: Object.entries(properties).map(([name, subSchema]) => SKIPPED_PROPERTIES.includes(name) || (_jsx(K8sCrdSchemaPart, { name: name, parent: schema, schema: subSchema, expandAll: expandAll }, name))) }))] }));
55
- };
56
- export const K8sCrd = ({ name, crdPath }) => {
57
- const [, crd] = useMemo(() => Object.entries(crdsMap).find(([pathname, crd]) => {
58
- if (crdPath && pathname !== crdPath) {
59
- return false;
60
- }
61
- return crd.metadata.name === name;
62
- }) || [], [crdPath, name]);
63
- if (!crd) {
64
- console.error(`No CustomResourceDefinition found for ${name}`);
65
- return null;
66
- }
67
- return (_jsxs(_Fragment, { children: [_jsxs(X.p, { children: [_jsx("code", { children: crd.spec.group }), " ", _jsx(Badge, { children: "group" })] }), crd.spec.versions.map((version) => (_jsx(K8sCrdSchema, { schema: version.schema.openAPIV3Schema, version: version.name }, version.name)))] }));
68
- };
5
+ export const K8sCrd = K8sAPI;
6
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
69
7
  export default K8sCrd;
@@ -57,7 +57,7 @@ export const K8sPermissionTable = ({ functions }) => {
57
57
  }
58
58
  return matched;
59
59
  }),
60
- // eslint-disable-next-line react-hooks/exhaustive-deps
60
+ // eslint-disable-next-line @eslint-react/exhaustive-deps
61
61
  functions);
62
62
  const roleTemplates = useMemo(() => sortBy(Object.values(roleTemplatesMap).flat(), [
63
63
  (it) => it.metadata.annotations['auth.cpaas.io/role.id'],
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { NoSSR } from '@rspress/core/runtime';
3
3
  import { lazy, Suspense, useLayoutEffect, useRef, } from 'react';
4
4
  const LazyMasonry = lazy(() => import('masonry-layout').then(({ default: MasonryLayout }) => {
5
+ // eslint-disable-next-line @eslint-react/component-hook-factories
5
6
  const Masonry = ({ options, ...props }) => {
6
7
  const ref = useRef(null);
7
8
  useLayoutEffect(() => {
@@ -26,9 +26,7 @@ export const OpenAPIParameters = ({ parameters, openapi, }) => {
26
26
  else if (type) {
27
27
  typeNode = _jsx(RefLink, { "$ref": type.$ref });
28
28
  }
29
- return (
30
- // eslint-disable-next-line @eslint-react/no-array-index-key
31
- _jsxs(X.li, { children: [_jsx("code", { children: paramObj.name }), " (", _jsxs("em", { children: ["in ", paramObj.in] }), "): ", typeNode, paramObj.required && (_jsxs(_Fragment, { children: [' ', _jsx(Badge, { children: "required" })] })), _jsxs(_Fragment, { children: [' ', _jsx(Markdown, { children: paramObj.description })] })] }, index));
29
+ return (_jsxs(X.li, { children: [_jsx("code", { children: paramObj.name }), " (", _jsxs("em", { children: ["in ", paramObj.in] }), "): ", typeNode, paramObj.required && (_jsxs(_Fragment, { children: [' ', _jsx(Badge, { children: "required" })] })), _jsxs(_Fragment, { children: [' ', _jsx(Markdown, { children: paramObj.description })] })] }, index));
32
30
  }) }));
33
31
  };
34
32
  export const OpenAPIResponses = ({ responses, openapi, }) => {
@@ -101,7 +101,6 @@ export const OpenAPIRef = ({ schema, openapiPath: openapiPath_, collectRefs = tr
101
101
  continue;
102
102
  }
103
103
  const schemaItem = resolveRef(openapi, schema);
104
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
105
104
  if (schemaItem) {
106
105
  return [schemaItem, openapi, pathname];
107
106
  }
@@ -6,8 +6,6 @@ export const Tabs = ({ ref, children, ...props }) => {
6
6
  const isPrint = useIsPrint();
7
7
  return (_jsx("div", { className: "doom-tabs", ref: ref, children: isPrint ? (
8
8
  // eslint-disable-next-line @eslint-react/no-children-map
9
- Children.map(children, (child, index) => (
10
- // eslint-disable-next-line @eslint-react/no-array-index-key
11
- _jsx(Tabs_, { ...props, children: child }, index)))) : (_jsx(Tabs_, { ...props, children: children })) }));
9
+ Children.map(children, (child, index) => (_jsx(Tabs_, { ...props, children: child }, index)))) : (_jsx(Tabs_, { ...props, children: children })) }));
12
10
  };
13
11
  export default Tabs;
@@ -7,9 +7,7 @@ export const TermsTable = ({ terms }) => {
7
7
  const t = useTranslation();
8
8
  const normalized = terms ?? namedTermItems;
9
9
  const withName = normalized.some(({ name }) => name);
10
- const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (
11
- // eslint-disable-next-line @eslint-react/no-array-index-key
12
- _jsx(X.li, { children: _jsx(Markdown, { children: item }) }, index))) })) : ('-');
10
+ const renderBadCases = (list) => list?.length ? (_jsx(X.ul, { children: list.map((item, index) => (_jsx(X.li, { children: _jsx(Markdown, { children: item }) }, index))) })) : ('-');
13
11
  return (_jsxs(X.table, { children: [_jsx("thead", { children: _jsxs(X.tr, { children: [withName && _jsx(X.th, { children: t('name') }), _jsx(X.th, { children: t('chinese') }), _jsx(X.th, { children: t('chinese_bad_cases') }), _jsx(X.th, { children: t('english') }), _jsx(X.th, { children: t('english_bad_cases') }), _jsx(X.th, { children: t('description') })] }) }), _jsx("tbody", { children: normalized.map((term, index) => (_jsxs(X.tr, { children: [withName && _jsx(X.td, { children: term.name || '-' }), _jsx(X.td, { children: _jsx(Markdown, { children: term.zh || term.en }) }), _jsx(X.td, { children: renderBadCases(term.badCases?.zh) }), _jsx(X.td, { children: _jsx(Markdown, { children: term.en }) }), _jsx(X.td, { children: renderBadCases(term.badCases?.en) }), _jsx(X.td, { children: term.description ? _jsx(Markdown, { children: term.description }) : '-' })] }, term.name || index))) })] }));
14
12
  };
15
13
  export default TermsTable;
@@ -5,7 +5,8 @@ export const RefLink = ({ $ref }) => {
5
5
  if (!$ref) {
6
6
  return null;
7
7
  }
8
- // #/components/schemas/, #/components/requestBodies/, etc.
8
+ // https://swagger.io/docs/specification/v3_0/components/#components-structure
9
+ // #/components/schemas/, #/components/requestBodies/, #/components/responses/, etc.
9
10
  const ref = $ref.replace(/^#\/components\/[^/]+\//, '#');
10
11
  const plainRef = ref.slice(1);
11
12
  const refName = modelName(plainRef);
@@ -2,7 +2,6 @@ import { useEffect, useRef } from 'react';
2
2
  export function useInterval(cb, delay) {
3
3
  const cbRef = useRef(cb);
4
4
  // Remember the latest callback.
5
- // eslint-disable-next-line react-hooks/refs
6
5
  cbRef.current = cb;
7
6
  // Set up the interval.
8
7
  useEffect(() => {
@@ -5,7 +5,6 @@ export const useMemoizedFn =
5
5
  (fn) => {
6
6
  /* eslint-enable @typescript-eslint/no-explicit-any */
7
7
  const fnRef = useRef(fn);
8
- // eslint-disable-next-line react-hooks/refs
9
8
  fnRef.current = fn;
10
9
  return useCallback(
11
10
  // eslint-disable-next-line @typescript-eslint/no-unsafe-return
@@ -1,6 +1,6 @@
1
1
  import type { OpenAPIV3_1 } from 'openapi-types';
2
2
  export declare const modelName: (ref: string) => string;
3
- export declare const resolveRef: <T extends object = OpenAPIV3_1.SchemaObject>(openapi: OpenAPIV3_1.Document, ref: string) => T;
3
+ export declare const resolveRef: <T extends object = OpenAPIV3_1.SchemaObject>(openapi: OpenAPIV3_1.Document, ref: string) => T | undefined;
4
4
  export declare const COMMON_REFS: {
5
5
  [x: string]: string;
6
6
  };
@@ -5,11 +5,29 @@ export const modelName = (ref) => {
5
5
  const lastPart = last(ref.split('.'));
6
6
  return upperFirst(lastPart.startsWith('#') ? lastPart.slice(1) : lastPart);
7
7
  };
8
+ // https://swagger.io/docs/specification/v3_0/components/#components-structure
9
+ const COMPONENTS = [
10
+ 'schemas',
11
+ 'parameters',
12
+ 'securitySchemes',
13
+ 'requestBodies',
14
+ 'responses',
15
+ 'headers',
16
+ 'examples',
17
+ 'links',
18
+ 'callbacks',
19
+ ];
20
+ const COMPONENTS_REFS = COMPONENTS.map((component) => `#/components/${component}/`);
8
21
  export const resolveRef = (openapi, ref) => {
9
- if (!ref.startsWith('#/')) {
10
- ref = `#/components/schemas/${ref}`;
22
+ const refs = ref.startsWith('#/')
23
+ ? [ref]
24
+ : COMPONENTS_REFS.map((prefix) => `${prefix}${ref}`);
25
+ for (const ref of refs) {
26
+ const resolved = get(openapi, ref.slice(2).split('/'));
27
+ if (resolved) {
28
+ return resolved;
29
+ }
11
30
  }
12
- return get(openapi, ref.slice(2).split('/'));
13
31
  };
14
32
  const DEFAULT_COMMON_REFS = {
15
33
  'v1alpha1.ListMeta': 'list-meta/',
@@ -18,7 +18,7 @@ export const AutoExpandable = ({ threshold = 240, children, }) => {
18
18
  let observer;
19
19
  const calculate = () => {
20
20
  if (containerEl.scrollHeight > threshold) {
21
- // eslint-disable-next-line @eslint-react/hooks-extra/no-direct-set-state-in-use-effect
21
+ // eslint-disable-next-line @eslint-react/set-state-in-effect
22
22
  setExpandable(true);
23
23
  }
24
24
  observer?.disconnect();
@@ -23,7 +23,6 @@ const VersionsNav_ = () => {
23
23
  // eslint-disable-next-line @typescript-eslint/no-deprecated
24
24
  const { nav } = useLocaleSiteData();
25
25
  const configNav = useMemo(() => (Array.isArray(nav) ? nav : nav.default), [nav]);
26
- const originalConfigNav = useMemo(() => [...configNav], [configNav]);
27
26
  // hack to rerender nav when configNav is changed
28
27
  const forceRender = useForceRender();
29
28
  const lang = useLang();
@@ -72,11 +71,13 @@ const VersionsNav_ = () => {
72
71
  navList.push({
73
72
  text: t('download_pdf'),
74
73
  link: downloadLink,
74
+ download: true,
75
+ _hacked: true,
75
76
  });
76
77
  }
77
78
  if (versionsBase == null) {
78
79
  if (version) {
79
- navList.push({ text: version, items: [] });
80
+ navList.push({ text: version, items: [], _hacked: true });
80
81
  }
81
82
  }
82
83
  else {
@@ -92,16 +93,16 @@ const VersionsNav_ = () => {
92
93
  navList.push({
93
94
  text: version,
94
95
  items: versionItems,
96
+ _hacked: true,
95
97
  });
96
98
  }
97
99
  return navList;
98
100
  }, [downloadLink, t, version, versionsBase, versions]);
99
101
  useEffect(() => {
100
- // eslint-disable-next-line react-hooks/immutability
101
- configNav.length = originalConfigNav.length;
102
+ configNav.length = configNav.filter((item) => !('_hacked' in item && item._hacked === true)).length;
102
103
  configNav.push(...navList);
103
104
  forceRender();
104
- }, [configNav, forceRender, navList, originalConfigNav]);
105
+ }, [configNav, forceRender, navList]);
105
106
  return null;
106
107
  };
107
108
  export const VersionsNav = () => (_jsx(NoSSR, { children: _jsx(VersionsNav_, {}) }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alauda/doom",
3
- "version": "1.22.0",
3
+ "version": "2.0.0",
4
4
  "type": "module",
5
5
  "description": "Doctor Doom making docs.",
6
6
  "repository": {
@@ -11,7 +11,7 @@
11
11
  "homepage": "https://github.com/alauda/doom#readme",
12
12
  "license": "MIT",
13
13
  "engines": {
14
- "node": ">=20.19.0"
14
+ "node": ">=22.18.0"
15
15
  },
16
16
  "bin": "lib/cli/index.js",
17
17
  "exports": {
@@ -41,19 +41,19 @@
41
41
  ],
42
42
  "dependencies": {
43
43
  "@alauda/doom-export": "^0.4.1",
44
- "@cspell/eslint-plugin": "^9.7.0",
45
- "@eslint-react/eslint-plugin": "^2.13.0",
46
- "@eslint/js": "^9.39.3",
47
- "@inquirer/prompts": "^8.3.0",
44
+ "@cspell/eslint-plugin": "^10.0.0",
45
+ "@eslint-react/eslint-plugin": "^4.2.3",
46
+ "@eslint/js": "^10.0.1",
47
+ "@inquirer/prompts": "^8.4.1",
48
48
  "@openapi-contrib/openapi-schema-to-json-schema": "^5.1.0",
49
49
  "@rsbuild/plugin-react": "^1.4.6",
50
50
  "@rsbuild/plugin-sass": "^1.5.1",
51
51
  "@rsbuild/plugin-svgr": "^1.3.1",
52
52
  "@rsbuild/plugin-yaml": "^1.0.4",
53
- "@rspress/core": "2.0.5",
54
- "@rspress/plugin-algolia": "2.0.5",
55
- "@rspress/plugin-sitemap": "2.0.5",
56
- "@rspress/shared": "2.0.5",
53
+ "@rspress/core": "2.0.8",
54
+ "@rspress/plugin-algolia": "2.0.8",
55
+ "@rspress/plugin-sitemap": "2.0.8",
56
+ "@rspress/shared": "2.0.8",
57
57
  "@shikijs/transformers": "^4.0.2",
58
58
  "@total-typescript/ts-reset": "^0.6.1",
59
59
  "@types/react": "^19.2.14",
@@ -63,7 +63,7 @@
63
63
  "commander": "^14.0.3",
64
64
  "ejs": "^5.0.1",
65
65
  "es-toolkit": "^1.45.1",
66
- "eslint": "^9.39.3",
66
+ "eslint": "^10.2.0",
67
67
  "eslint-plugin-mdx": "^3.7.0",
68
68
  "globals": "^17.4.0",
69
69
  "hastscript": "^9.0.1",
@@ -75,11 +75,11 @@
75
75
  "mdast-util-phrasing": "^4.1.0",
76
76
  "mdast-util-to-markdown": "^2.1.2",
77
77
  "mdast-util-to-string": "^4.0.0",
78
- "mermaid": "^11.13.0",
79
- "openai": "^6.27.0",
78
+ "mermaid": "^11.14.0",
79
+ "openai": "^6.33.0",
80
80
  "openapi-types": "^12.1.3",
81
81
  "p-ratelimit": "^1.0.1",
82
- "picomatch": "^4.0.3",
82
+ "picomatch": "^4.0.4",
83
83
  "pluralize": "^8.0.0",
84
84
  "react-markdown": "^10.1.0",
85
85
  "react-tooltip": "^5.30.0",
@@ -97,13 +97,13 @@
97
97
  "remark-mdx": "^3.1.1",
98
98
  "remark-message-control": "^8.0.0",
99
99
  "remark-stringify": "^11.0.0",
100
- "simple-git": "^3.33.0",
100
+ "simple-git": "^3.35.2",
101
101
  "string-width": "^8.2.0",
102
102
  "swagger2openapi": "^7.0.8",
103
- "tinyglobby": "^0.2.15",
104
- "type-fest": "^5.4.4",
105
- "typescript": "^5.9.3",
106
- "typescript-eslint": "^8.57.0",
103
+ "tinyglobby": "^0.2.16",
104
+ "type-fest": "^5.5.0",
105
+ "typescript": "^6.0.2",
106
+ "typescript-eslint": "^8.58.1",
107
107
  "unified": "^11.0.5",
108
108
  "unified-lint-rule": "^3.0.1",
109
109
  "unist-util-position": "^5.0.0",