From 9238252d08cbc649ac0e7e61fb09dc2d5ba32a73 Mon Sep 17 00:00:00 2001 From: Nick Bourdakos Date: Mon, 18 Dec 2023 21:52:10 -0500 Subject: [PATCH] Fix admonitions support in Docusaurus v3 (#271) --- demo/examples/openapi-cos.json | 2 +- packages/docusaurus-plugin-openapi/package.json | 1 - packages/docusaurus-plugin-openapi/src/index.ts | 1 + .../src/markdown/createDeprecationNotice.ts | 2 +- packages/docusaurus-plugin-openapi/src/options.ts | 7 ------- 5 files changed, 3 insertions(+), 10 deletions(-) diff --git a/demo/examples/openapi-cos.json b/demo/examples/openapi-cos.json index c784b3a1..c6c9abbd 100644 --- a/demo/examples/openapi-cos.json +++ b/demo/examples/openapi-cos.json @@ -79,7 +79,7 @@ "put": { "tags": ["Bucket operations"], "summary": "Create a bucket", - "description": "A `PUT` request sent to the endpoint root followed by a string will create a bucket.\nFor more information about endpoints, see [Endpoints and storage locations](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints).\nBucket names must be globally unique and DNS-compliant; names between 3 and 63 characters long must be made of lowercase letters, numbers, and dashes.\nBucket names must begin and end with a lowercase letter or number.\nBucket names resembling IP addresses are not allowed.\nThis operation doesn't make use of operation specific query parameters.\n\n:::info important\nBucket names must be unique because all buckets in the public cloud share a global namespace.\nThis allows for access to a bucket without needing to provide any service instance or account information.\nIt is also not possible to create a bucket with a name beginning with `cosv1-` or `account-` as these prefixes are reserved by the system.\n:::\n\n:::note\nPersonally Identifiable Information (PII): When creating buckets or adding objects, please ensure to not use any information that can identify any user (natural person) by name, location or any other means in the name of the bucket or object.\n:::\n\n## Create a bucket with a different storage class\n\nTo create a bucket with a different storage class, send an XML block specifying a bucket configuration with a `LocationConstraint` of `{provisioning code}` in the body of a `PUT` request to a bucket endpoint.\nFor more information about endpoints, see [Endpoints and storage locations](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints).\nNote that standard bucket [naming rules](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-compatibility-api-bucket-operations#compatibility-api-new-bucket) apply.\nThis operation does not make use of operation specific query parameters.\n\nThe body of the request must contain an XML block with the following schema:\n\n```xml\n\n us-vault\n\n```\n\nA list of valid provisioning codes for `LocationConstraint` can be referenced in [the Storage Classes guide](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-classes#classes-locationconstraint).\n\n## Create a new bucket with Key Protect or Hyper Protect Crypto Services managed encryption keys (SSE-KP)\n\nTo create a bucket where the encryption keys are managed by Key Protect or Hyper Protect Crypto Services, it is necessary to have access to an active Key Protect or Hyper Protect Crypto Services service instance located in the same location as the new bucket.\nThis operation does not make use of operation specific query parameters.\n\nFor more information on using Key Protect to manage your encryption keys, [see the documentation for Key Protect](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial).\n\nFor more information on Hyper Protect Crypto Services, [see the documentation](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started).\n\n:::note\nNote that managed encryption is **not** available in a Cross Region configuration and any SSE-KP buckets must be Regional.\n:::", + "description": "A `PUT` request sent to the endpoint root followed by a string will create a bucket.\nFor more information about endpoints, see [Endpoints and storage locations](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints).\nBucket names must be globally unique and DNS-compliant; names between 3 and 63 characters long must be made of lowercase letters, numbers, and dashes.\nBucket names must begin and end with a lowercase letter or number.\nBucket names resembling IP addresses are not allowed.\nThis operation doesn't make use of operation specific query parameters.\n\n:::info[important]\nBucket names must be unique because all buckets in the public cloud share a global namespace.\nThis allows for access to a bucket without needing to provide any service instance or account information.\nIt is also not possible to create a bucket with a name beginning with `cosv1-` or `account-` as these prefixes are reserved by the system.\n:::\n\n:::note\nPersonally Identifiable Information (PII): When creating buckets or adding objects, please ensure to not use any information that can identify any user (natural person) by name, location or any other means in the name of the bucket or object.\n:::\n\n## Create a bucket with a different storage class\n\nTo create a bucket with a different storage class, send an XML block specifying a bucket configuration with a `LocationConstraint` of `{provisioning code}` in the body of a `PUT` request to a bucket endpoint.\nFor more information about endpoints, see [Endpoints and storage locations](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-endpoints#endpoints).\nNote that standard bucket [naming rules](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-compatibility-api-bucket-operations#compatibility-api-new-bucket) apply.\nThis operation does not make use of operation specific query parameters.\n\nThe body of the request must contain an XML block with the following schema:\n\n```xml\n\n us-vault\n\n```\n\nA list of valid provisioning codes for `LocationConstraint` can be referenced in [the Storage Classes guide](https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-classes#classes-locationconstraint).\n\n## Create a new bucket with Key Protect or Hyper Protect Crypto Services managed encryption keys (SSE-KP)\n\nTo create a bucket where the encryption keys are managed by Key Protect or Hyper Protect Crypto Services, it is necessary to have access to an active Key Protect or Hyper Protect Crypto Services service instance located in the same location as the new bucket.\nThis operation does not make use of operation specific query parameters.\n\nFor more information on using Key Protect to manage your encryption keys, [see the documentation for Key Protect](https://cloud.ibm.com/docs/key-protect?topic=key-protect-getting-started-tutorial).\n\nFor more information on Hyper Protect Crypto Services, [see the documentation](https://cloud.ibm.com/docs/hs-crypto?topic=hs-crypto-get-started).\n\n:::note\nNote that managed encryption is **not** available in a Cross Region configuration and any SSE-KP buckets must be Regional.\n:::", "parameters": [ { "name": "bucketName", diff --git a/packages/docusaurus-plugin-openapi/package.json b/packages/docusaurus-plugin-openapi/package.json index 85f74aaf..215a3314 100644 --- a/packages/docusaurus-plugin-openapi/package.json +++ b/packages/docusaurus-plugin-openapi/package.json @@ -44,7 +44,6 @@ "lodash": "^4.17.20", "openapi-to-postmanv2": "^1.2.1", "postman-collection": "^4.1.0", - "remark-directive": "^3.0.0", "webpack": "^5.88.1" }, "peerDependencies": { diff --git a/packages/docusaurus-plugin-openapi/src/index.ts b/packages/docusaurus-plugin-openapi/src/index.ts index ffc704d0..7c8cb81b 100644 --- a/packages/docusaurus-plugin-openapi/src/index.ts +++ b/packages/docusaurus-plugin-openapi/src/index.ts @@ -271,6 +271,7 @@ export default function pluginOpenAPI( { loader: require.resolve("@docusaurus/mdx-loader"), options: { + admonitions: options.admonitions, remarkPlugins, rehypePlugins, beforeDefaultRehypePlugins, diff --git a/packages/docusaurus-plugin-openapi/src/markdown/createDeprecationNotice.ts b/packages/docusaurus-plugin-openapi/src/markdown/createDeprecationNotice.ts index 99e43428..2aa501b5 100644 --- a/packages/docusaurus-plugin-openapi/src/markdown/createDeprecationNotice.ts +++ b/packages/docusaurus-plugin-openapi/src/markdown/createDeprecationNotice.ts @@ -8,7 +8,7 @@ import { guard, Props, render } from "./utils"; function createAdmonition({ children }: Props) { - return `:::caution deprecated\n\n${render(children)}\n\n:::`; + return `:::caution[deprecated]\n\n${render(children)}\n\n:::`; } interface DeprecationNoticeProps { diff --git a/packages/docusaurus-plugin-openapi/src/options.ts b/packages/docusaurus-plugin-openapi/src/options.ts index a2ed3b6f..a173fd88 100644 --- a/packages/docusaurus-plugin-openapi/src/options.ts +++ b/packages/docusaurus-plugin-openapi/src/options.ts @@ -13,7 +13,6 @@ import { AdmonitionsSchema, } from "@docusaurus/utils-validation"; import chalk from "chalk"; -import admonitions from "remark-directive"; import type { PluginOptions } from "./types"; @@ -84,11 +83,5 @@ export function validateOptions({ const normalizedOptions = validate(OptionsSchema, options); - if (normalizedOptions.admonitions) { - normalizedOptions.remarkPlugins = normalizedOptions.remarkPlugins.concat([ - [admonitions, normalizedOptions.admonitions], - ]); - } - return normalizedOptions; }