Skip to content

Commit

Permalink
Introduce support for Docusaurus 3.5.0+ (#919)
Browse files Browse the repository at this point in the history
* upgrade to docusaurus 3.5.2

* refactor imports and add plugin-content-docs declaration

* add module mapper for neotraverse/legacy
  • Loading branch information
sserrata authored Aug 19, 2024
1 parent 071a66e commit 02e0ae8
Show file tree
Hide file tree
Showing 9 changed files with 1,020 additions and 1,115 deletions.
6 changes: 3 additions & 3 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"re-gen": "yarn clean-all && yarn gen-all"
},
"dependencies": {
"@docusaurus/core": "3.4.0",
"@docusaurus/plugin-google-gtag": "3.4.0",
"@docusaurus/preset-classic": "3.4.0",
"@docusaurus/core": "3.5.2",
"@docusaurus/plugin-google-gtag": "3.5.2",
"@docusaurus/preset-classic": "3.5.2",
"clsx": "^1.1.1",
"docusaurus-plugin-openapi-docs": "^3.0.2",
"docusaurus-theme-openapi-docs": "^3.0.2",
Expand Down
4 changes: 4 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ module.exports = {
"<rootDir>/packages/docusaurus-plugin-openapi-docs/src",
"<rootDir>/packages/docusaurus-theme-openapi-docs/src",
],
moduleNameMapper: {
"^neotraverse/legacy$":
"<rootDir>/node_modules/neotraverse/dist/legacy/legacy.cjs",
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* ============================================================================
* Copyright (c) Palo Alto Networks
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
* ========================================================================== */

/// <reference types="@docusaurus/theme-classic" />

declare module "@docusaurus/plugin-content-docs/client" {
export function DocProvider({
children,
content,
}: {
children: ReactNode;
content: PropDocContent;
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// @ts-nocheck
import React, { useState } from "react";

import { useDoc } from "@docusaurus/theme-common/internal";
import { useDoc } from "@docusaurus/plugin-content-docs/client";
import Accept from "@theme/ApiExplorer/Accept";
import Authorization from "@theme/ApiExplorer/Authorization";
import Body from "@theme/ApiExplorer/Body";
Expand All @@ -31,7 +31,7 @@ import { FormProvider, useForm } from "react-hook-form";

import makeRequest from "./makeRequest";

function Request({ item }: { item: NonNullable<ApiItem> }) {
function Request({ item }: { item: ApiItem }) {
const postman = new sdk.Request(item.postman);
const metadata = useDoc();
const { proxy, hide_send_button: hideSendButton } = metadata.frontMatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import React from "react";

// @ts-ignore
import { useDoc } from "@docusaurus/plugin-content-docs/client";
import { usePrismTheme } from "@docusaurus/theme-common";
import { useDoc } from "@docusaurus/theme-common/internal";
import ApiCodeBlock from "@theme/ApiExplorer/ApiCodeBlock";
import { useTypedDispatch, useTypedSelector } from "@theme/ApiItem/hooks";
import SchemaTabs from "@theme/SchemaTabs";
Expand Down Expand Up @@ -38,7 +39,7 @@ function formatXml(xml: string) {
return formatted.substring(1, formatted.length - 3);
}

function Response({ item }: { item: NonNullable<ApiItem> }) {
function Response({ item }: { item: ApiItem }) {
const metadata = useDoc();
const hideSendButton = metadata.frontMatter.hide_send_button;
const prismTheme = usePrismTheme();
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import React from "react";

import BrowserOnly from "@docusaurus/BrowserOnly";
import ExecutionEnvironment from "@docusaurus/ExecutionEnvironment";
import { DocProvider } from "@docusaurus/plugin-content-docs/client";
import { HtmlClassNameProvider } from "@docusaurus/theme-common";
import { DocProvider } from "@docusaurus/theme-common/internal";
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import useIsBrowser from "@docusaurus/useIsBrowser";
import { createAuth } from "@theme/ApiExplorer/Authorization/slice";
import { createPersistanceMiddleware } from "@theme/ApiExplorer/persistanceMiddleware";
import DocItemLayout from "@theme/ApiItem/Layout";
import type { Props } from "@theme/DocItem";
import DocItemLayout from "@theme/DocItem/Layout";
import DocItemMetadata from "@theme/DocItem/Metadata";
import clsx from "clsx";
import { ServerObject } from "docusaurus-plugin-openapi-docs/src/openapi/types";
Expand Down
Loading

0 comments on commit 02e0ae8

Please sign in to comment.