Skip to content

Commit 7b8b0a8

Browse files
committed
Copy over v3.0.0 branch code from original theme; copy over our original changes
1 parent 9f5b2a5 commit 7b8b0a8

153 files changed

Lines changed: 6430 additions & 5644 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/docusaurus-theme-openapi-docs/.npmignore

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/docusaurus-theme-openapi-docs/package.json

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mxenabled/docusaurus-theme-openapi-docs",
3-
"description": "MX's OpenAPI theme for Docusaurus.",
3+
"description": "OpenAPI theme for Docusaurus.",
44
"version": "1.10.6",
55
"license": "MIT",
66
"keywords": [
@@ -24,52 +24,47 @@
2424
"types": "src/theme-openapi.d.ts",
2525
"main": "lib/index.js",
2626
"scripts": {
27-
"build": "tsc --noEmit && yarn babel:lib && yarn babel:lib-next && yarn format:lib-next",
28-
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\"",
29-
"babel:lib": "cross-env BABEL_ENV=lib babel src -d lib --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
30-
"babel:lib-next": "cross-env BABEL_ENV=lib-next babel src -d lib-next --extensions \".tsx,.ts\" --ignore \"**/*.d.ts\" --copy-files",
31-
"format:lib-next": "prettier --config ../../.prettierrc.json --write \"lib-next/**/*.{js,ts,jsx,tsc}\""
27+
"build": "tsc --build && node ../../scripts/copyUntypedFiles.mjs && prettier --config ../../.prettierrc.json --write \"lib/theme/**/*.js\"",
28+
"watch": "concurrently --names \"lib,lib-next,tsc\" --kill-others \"yarn babel:lib --watch\" \"yarn babel:lib-next --watch\" \"yarn tsc --watch\""
3229
},
3330
"devDependencies": {
34-
"@docusaurus/module-type-aliases": ">=2.0.1 <2.3.0",
35-
"@docusaurus/types": ">=2.0.1 <2.3.0",
36-
"@types/concurrently": "^6.3.0",
31+
"@docusaurus/types": "^3.0.1",
3732
"@types/crypto-js": "^4.1.0",
3833
"@types/file-saver": "^2.0.5",
39-
"@types/fs-extra": "^9.0.13",
4034
"@types/lodash": "^4.14.176",
41-
"@types/mdx-js__react": "^1.5.4",
42-
"@types/rtlcss": "^3.1.1",
43-
"concurrently": "^5.2.0"
35+
"concurrently": "^5.2.0",
36+
"eslint-plugin-prettier": "^5.0.1"
4437
},
4538
"dependencies": {
46-
"@mdx-js/react": "^1.6.21",
47-
"@mxenabled/docusaurus-plugin-openapi-docs": "^1.10.4",
48-
"@mxenabled/docusaurus-theme-common": "^2.2.5",
39+
"@docusaurus/theme-common": "^3.0.1",
40+
"@hookform/error-message": "^2.0.1",
41+
"@mxenabled/docusaurus-plugin-openapi-docs": "1.10.4",
4942
"@paloaltonetworks/postman-code-generators": "1.1.15-patch.2",
5043
"@paloaltonetworks/postman-collection": "^4.1.0",
5144
"@reduxjs/toolkit": "^1.7.1",
52-
"buffer": "^6.0.3",
5345
"clsx": "^1.1.1",
46+
"copy-text-to-clipboard": "^3.1.0",
5447
"crypto-js": "^4.1.1",
48+
"docusaurus-plugin-sass": "^0.2.3",
5549
"file-saver": "^2.0.5",
56-
"immer": "^9.0.7",
5750
"lodash": "^4.17.20",
5851
"node-polyfill-webpack-plugin": "^2.0.1",
59-
"process": "^0.11.10",
60-
"react-live": "^3.1.1",
52+
"prism-react-renderer": "^2.3.0",
53+
"react-hook-form": "^7.43.8",
54+
"react-live": "^4.0.0",
6155
"react-magic-dropzone": "^1.0.1",
6256
"react-markdown": "^8.0.1",
6357
"react-modal": "^3.15.1",
6458
"react-redux": "^7.2.0",
65-
"redux-devtools-extension": "^2.13.8",
6659
"rehype-raw": "^6.1.1",
60+
"sass": "^1.58.1",
61+
"sass-loader": "^13.3.2",
6762
"webpack": "^5.61.0",
6863
"xml-formatter": "^2.6.1"
6964
},
7065
"peerDependencies": {
71-
"react": "^16.8.4 || ^17.0.0",
72-
"react-dom": "^16.8.4 || ^17.0.0"
66+
"react": "^16.8.4 || ^17.0.0 || ^18.0.0",
67+
"react-dom": "^16.8.4 || ^17.0.0 || ^18.0.0"
7368
},
7469
"engines": {
7570
"node": ">=14"

packages/docusaurus-theme-openapi-docs/src/index.ts

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,49 @@ export default function docusaurusThemeOpenAPI(): Plugin<void> {
1616
name: "docusaurus-theme-openapi",
1717

1818
getClientModules() {
19-
const modules = [require.resolve("./theme/styles.css")];
19+
const modules = [
20+
require.resolve(
21+
path.join(__dirname, "..", "lib", "theme", "styles.scss")
22+
),
23+
];
2024
return modules;
2125
},
2226

2327
getThemePath() {
24-
return path.join(__dirname, "..", "lib-next", "theme");
28+
return path.join(__dirname, "..", "lib", "theme");
2529
},
2630

2731
getTypeScriptThemePath() {
2832
return path.resolve(__dirname, "..", "src", "theme");
2933
},
3034

31-
configureWebpack() {
35+
configureWebpack(_, isServer, utils) {
36+
const rules: any = _.module?.rules ?? [];
37+
const sassLoaderRule = rules.filter((r: any) => {
38+
return String(r.test) === String(/\.s[ca]ss$/);
39+
});
40+
const { getStyleLoaders } = utils;
41+
// Avoid conflicts with docusaurus-plugin-sass
42+
if (sassLoaderRule.length === 0) {
43+
return {
44+
plugins: [new NodePolyfillPlugin()],
45+
module: {
46+
rules: [
47+
{
48+
test: /\.s[ac]ss$/,
49+
include: path.resolve(__dirname, "..", "lib", "theme"),
50+
use: [
51+
...getStyleLoaders(isServer, {}),
52+
{
53+
loader: require.resolve("sass-loader"),
54+
options: {},
55+
},
56+
],
57+
},
58+
],
59+
},
60+
};
61+
}
3262
return {
3363
plugins: [new NodePolyfillPlugin()],
3464
};

packages/docusaurus-theme-openapi-docs/src/markdown/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
* LICENSE file in the root directory of this source tree.
66
* ========================================================================== */
77

8-
export type Children = string | undefined | (string | undefined)[];
8+
import { ReactNode } from "react";
9+
10+
export type Children = ReactNode | string | undefined | (string | undefined)[];
911

1012
export type Props = Record<string, any> & { children?: Children };
1113

@@ -35,7 +37,7 @@ export function render(children: Children): string {
3537
if (Array.isArray(children)) {
3638
return children.filter((c) => c !== undefined).join("");
3739
}
38-
return children ?? "";
40+
return (children as string) ?? "";
3941
}
4042

4143
export function toString(value: any): string | undefined {

packages/docusaurus-theme-openapi-docs/src/theme-classic.d.ts

Lines changed: 69 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,73 @@
88
/// <reference types="@docusaurus/theme-classic" />
99

1010
declare module "@docusaurus/theme-common/internal" {
11-
function useDoc(): any;
12-
export const { useDoc };
11+
import { CSSProperties, ReactNode, RefObject } from "react";
12+
13+
import type { PropDocContent } from "@docusaurus/plugin-content-docs";
14+
import { MagicCommentConfig } from "@docusaurus/theme-common/lib/utils/codeBlockUtils";
15+
import {
16+
TabsProps as ITabsProps,
17+
TabValue,
18+
} from "@docusaurus/theme-common/lib/utils/tabsUtils";
19+
import { Props as ICodeBlockProps } from "@theme/CodeBlock";
20+
import { Props as ICopyButtonProps } from "@theme/CodeBlock/CopyButton";
21+
import { Props as ILineProps } from "@theme/CodeBlock/Line";
22+
import { PrismTheme } from "prism-react-renderer";
23+
24+
export interface TabProps extends ITabsProps {}
25+
26+
export interface CopyButtonProps extends ICopyButtonProps {}
27+
export interface LineProps extends ILineProps {}
28+
export interface CodeBlockProps extends ICodeBlockProps {}
29+
30+
export function useDoc();
31+
32+
export function usePrismTheme(): PrismTheme;
33+
34+
export function sanitizeTabsChildren(children: TabProps["children"]);
35+
36+
export function getPrismCssVariables(prismTheme: PrismTheme): CSSProperties;
37+
38+
export function parseCodeBlockTitle(metastring?: string): string;
39+
40+
export function parseLanguage(className: string): string | undefined;
41+
42+
export function containsLineNumbers(metastring?: string): boolean;
43+
44+
export function useScrollPositionBlocker(): {
45+
blockElementScrollPositionUntilNextRender: (el: HTMLElement) => void;
46+
};
47+
48+
export function DocProvider({
49+
children,
50+
content,
51+
}: {
52+
children: ReactNode;
53+
content: PropDocContent;
54+
});
55+
56+
export function useTabs(props: TabProps): {
57+
selectedValue: string;
58+
selectValue: (value: string) => void;
59+
tabValues: readonly TabValue[];
60+
};
61+
62+
export function parseLines(
63+
content: string,
64+
options: {
65+
metastring: string | undefined;
66+
language: string | undefined;
67+
magicComments: MagicCommentConfig[];
68+
}
69+
): {
70+
lineClassNames: { [lineIndex: number]: string[] };
71+
code: string;
72+
};
73+
74+
export function useCodeWordWrap(): {
75+
readonly codeBlockRef: RefObject<HTMLPreElement>;
76+
readonly isEnabled: boolean;
77+
readonly isCodeScrollable: boolean;
78+
readonly toggle: () => void;
79+
};
1380
}

0 commit comments

Comments
 (0)