docs: migrate guides to TSDoc references (#6100)
This commit is contained in:
@@ -17,6 +17,7 @@ module.exports = {
|
||||
excludeExternals: true,
|
||||
excludeReferences: true,
|
||||
disableSources: true,
|
||||
sort: ["source-order"],
|
||||
validation: {
|
||||
notExported: false,
|
||||
// invalidLink: false,
|
||||
|
||||
@@ -15,6 +15,7 @@ const baseSectionsOptions = {
|
||||
member_signature_title: false,
|
||||
member_signature_returns: false,
|
||||
title_reflectionPath: false,
|
||||
member_declaration_children: false,
|
||||
}
|
||||
|
||||
const modulesSectionsOptions = {
|
||||
@@ -104,18 +105,64 @@ module.exports = {
|
||||
maxLevel: 1,
|
||||
},
|
||||
|
||||
// FULFILLMENT CONFIG
|
||||
"^fulfillment": {
|
||||
// FILE CONFIG
|
||||
"^file": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
},
|
||||
},
|
||||
"^file/.*AbstractFileService": {
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a file service in the Medusa backend and the methods you must implement in it.`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
slug: "/development/file-service/create-file-service",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a File Service",
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your file service in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your file service implementation:
|
||||
|
||||
1\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. Upload a file using the [Admin REST APIs](https://docs.medusajs.com/api/admin#uploads_postuploads) or using the Medusa admin, for example, to [upload a product's thumbnail](https://docs.medusajs.com/user-guide/products/manage#manage-thumbnails).
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// FULFILLMENT CONFIG
|
||||
"^fulfillment": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
},
|
||||
maxLevel: 2,
|
||||
},
|
||||
"^fulfillment/.*AbstractFulfillmentService": {
|
||||
reflectionDescription: `In this document, you’ll learn how to create a fulfillment provider to a Medusa backend and the methods you must implement in it. If you’re unfamiliar with the Shipping architecture in Medusa, make sure to [check out the overview first](https://docs.medusajs.com/modules/carts-and-checkout/shipping).`,
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a fulfillment provider in the Medusa backend and the methods you must implement in it. If you’re unfamiliar with the Shipping architecture in Medusa, make sure to [check out the overview first](https://docs.medusajs.com/modules/carts-and-checkout/shipping).`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
slug: "/modules/carts-and-checkout/backend/add-fulfillment-provider",
|
||||
@@ -123,6 +170,34 @@ module.exports = {
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Fulfillment Provider",
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your fulfillment provider in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your fulfillment provider implementation:
|
||||
|
||||
1\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. Enable your fulfillment provider in one or more regions. You can do that either using the [Admin APIs](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) or the [Medusa Admin](https://docs.medusajs.com/user-guide/regions/providers#manage-fulfillment-providers).
|
||||
|
||||
4\\. To test out your fulfillment provider implementation, create a cart and complete an order. You can do that either using the [Next.js starter](https://docs.medusajs.com/starters/nextjs-medusa-starter) or [using Medusa's APIs and clients](https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-cart).
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// INVENTORY CONFIG
|
||||
@@ -191,6 +266,36 @@ module.exports = {
|
||||
maxLevel: 3,
|
||||
},
|
||||
|
||||
// MEDUSA CONFIG CONFIG
|
||||
"^medusa_config": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
},
|
||||
expandMembers: true,
|
||||
},
|
||||
"^medusa_config/.*ConfigModule": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
slug: "/development/backend/configurations",
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a file service in the Medusa backend and the methods you must implement in it.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
This document assumes you already followed along with the [Prepare Environment documentation](https://docs.medusajs.com/development/backend/prepare-environment) and have a Medusa backend installed.
|
||||
|
||||
---`,
|
||||
reflectionTitle: "Configure Medusa Backend",
|
||||
expandMembers: true,
|
||||
expandProperties: true,
|
||||
// parameterStyle: "list",
|
||||
sections: {
|
||||
...baseSectionsOptions,
|
||||
member_declaration_title: false,
|
||||
member_declaration_children: true,
|
||||
},
|
||||
},
|
||||
|
||||
// MEDUSA REACT CONFIG
|
||||
"^medusa_react": {
|
||||
frontmatterData: {
|
||||
@@ -317,6 +422,86 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
// NOTIFICATION CONFIG
|
||||
"^notification": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
},
|
||||
},
|
||||
"^notification/.*AbstractNotificationService": {
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a notification provider in the Medusa backend and the methods you must implement in it. Learn more about the notification architecture in [this documentation](https://docs.medusajs.com/development/notification/overview)`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
slug: "/development/notification/create-notification-provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Notification Provider",
|
||||
},
|
||||
endSections: [
|
||||
`## Subscribe with Loaders
|
||||
|
||||
After creating your Notification Provider Service, you must create a [Loader](https://docs.medusajs.com/development/loaders/overview) that registers this Service as a notification handler of events.
|
||||
|
||||
For example, to register the \`email-sender\` Notification Provider as a handler for the \`order.placed\` event, create the file \`src/loaders/notification.ts\` with the following content:
|
||||
|
||||
\`\`\`ts title="src/loaders/notification.ts"
|
||||
import {
|
||||
MedusaContainer,
|
||||
NotificationService,
|
||||
} from "@medusajs/medusa"
|
||||
|
||||
export default async (
|
||||
container: MedusaContainer
|
||||
): Promise<void> => {
|
||||
const notificationService = container.resolve<
|
||||
NotificationService
|
||||
>("notificationService")
|
||||
|
||||
notificationService.subscribe(
|
||||
"order.placed",
|
||||
"email-sender"
|
||||
)
|
||||
}
|
||||
\`\`\`
|
||||
|
||||
This loader accesses the \`notificationService\` through the [MedusaContainer](https://docs.medusajs.com/development/fundamentals/dependency-injection). The \`notificationService\` has a \`subscribe\` method that accepts 2 parameters. The first one is the name of the event to subscribe to, and the second is the identifier of the Notification Provider that's subscribing to that event.`,
|
||||
`## Test Sending a Notification
|
||||
|
||||
Make sure you have an event bus module configured in your Medusa backend. You can learn more on how to do that in the [Configurations guide](https://docs.medusajs.com/development/backend/configurations#modules).
|
||||
|
||||
Then:
|
||||
|
||||
1\\. Run the \`build\` command in the root directory of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. Place an order either using the [REST APIs](https://docs.medusajs.com/api/store) or using the [storefront](https://docs.medusajs.com/starters/nextjs-medusa-starter).
|
||||
|
||||
4\\. After placing an order, you can see in your console the message “Notification Sent”. If you added your own notification sending logic, you should receive an email or alternatively the type of notification you’ve set up.`,
|
||||
`## Test Resending a Notification
|
||||
|
||||
To test resending a notification:
|
||||
|
||||
1. Retrieve the ID of the notification you just sent using the [List Notifications API Route](https://docs.medusajs.com/api/admin#notifications_getnotifications). You can pass as a body parameter the \`to\` or \`event_name\` parameters to filter out the notification you just sent.
|
||||
|
||||
2. Send a request to the [Resend Notification API Route](https://docs.medusajs.com/api/admin#notifications_postnotificationsnotificationresend) using the ID retrieved from the previous request. You can pass the \`to\` parameter in the body to change the receiver of the notification.
|
||||
|
||||
3. You should see the message “Notification Resent” in your console.
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// PAYMENT CONFIG
|
||||
"^payment": {
|
||||
frontmatterData: {
|
||||
@@ -336,6 +521,80 @@ module.exports = {
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your payment processor in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your payment processor implementation:
|
||||
|
||||
1\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. Enable your payment processor in one or more regions. You can do that either using the [Admin APIs](https://docs.medusajs.com/api/admin#regions_postregionsregionpaymentproviders) or the [Medusa Admin](https://docs.medusajs.com/user-guide/regions/providers#manage-payment-providers).
|
||||
|
||||
4\\. There are different ways to test out your payment processor, such as authorizing payment on order completion or capturing payment of an order. You test payment in a checkout flow either using the [Next.js starter](https://docs.medusajs.com/starters/nextjs-medusa-starter) or [using Medusa's APIs and clients](https://docs.medusajs.com/modules/carts-and-checkout/storefront/implement-checkout-flow).
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// PRICE SELECTION CONFIG
|
||||
"^price_selection": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
},
|
||||
},
|
||||
"^price_selection/.*AbstractPriceSelectionStrategy": {
|
||||
reflectionDescription: `In this document, you’ll learn what the price selection strategy and how to override it in the Medusa backend.`,
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
slug: "/modules/price-lists/price-selection-strategy",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Override the Price Selection Strategy",
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your price selection strategy in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your price selection strategy implementation:
|
||||
|
||||
1\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. To test out your price selection strategy implementation, you can retrieve a product and it's variants by specifying pricing parameters as explained in [this guide](https://docs.medusajs.com/modules/products/storefront/show-products#product-pricing-parameters).
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// PRICING CONFIG
|
||||
@@ -424,6 +683,62 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
// SEARCH CONFIG
|
||||
"^search": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
},
|
||||
},
|
||||
"^search/.*AbstractSearchService": {
|
||||
reflectionDescription: `In this document, you’ll learn how to create a search service in the Medusa backend and the methods you must implement in it.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
A search service must extend the \`AbstractSearchService\` class imported from the \`@medusajs/utils\` package. If you don’t already have the package
|
||||
installed, run the following command to install it within your project:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm install @medusajs/utils
|
||||
\`\`\`
|
||||
|
||||
---`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "core",
|
||||
slug: "/development/search/create",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Search Service",
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your search service in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your search service implementation:
|
||||
|
||||
1\\. Make sure you have an [event bus module](https://docs.medusajs.com/development/events/modules/redis) installed that triggers search indexing when the Medusa backend loads.
|
||||
|
||||
2\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
3\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
4\\. Try to search for products either using the [Search Products API Route](https://docs.medusajs.com/api/store#products_postproductssearch). The results returned by your search service's \`search\` method is returned in the \`hits\` response field.
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// SERVICES CONFIG
|
||||
"^services": {
|
||||
frontmatterData: {
|
||||
@@ -467,6 +782,100 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
// TAX CALCULATION CONFIG
|
||||
"^tax_calculation": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
},
|
||||
},
|
||||
"^tax_calculation/.*AbstractTaxCalculationStrategy": {
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to override the tax calculations strategy in the Medusa backend and the methods you must implement in it.`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
slug: "/modules/taxes/backend/tax-calculation-strategy",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Override a Tax Calculation Strategy",
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your tax calculation strategy in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your tax calculation strategy implementation:
|
||||
|
||||
1\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. To test out your tax calculation strategy implementation, you can [trigger taxes calculation manually](https://docs.medusajs.com/modules/taxes/storefront/manual-calculation).
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// TAX PROVIDER CONFIG
|
||||
"^tax/": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
},
|
||||
},
|
||||
"^tax/.*AbstractTaxService": {
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
reflectionDescription: `In this document, you’ll learn how to create a tax provider in the Medusa backend and the methods you must implement in it.`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
slug: "/modules/taxes/backend/create-tax-provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Tax Provider",
|
||||
},
|
||||
endSections: [
|
||||
`## Test Implementation
|
||||
|
||||
:::note
|
||||
|
||||
If you created your tax provider in a plugin, refer to [this guide on how to test plugins](https://docs.medusajs.com/development/plugins/create#test-your-plugin).
|
||||
|
||||
:::
|
||||
|
||||
After finishing your tax provider implementation:
|
||||
|
||||
1\\. Run the \`build\` command in the root of your Medusa backend:
|
||||
|
||||
\`\`\`bash npm2yarn
|
||||
npm run build
|
||||
\`\`\`
|
||||
|
||||
2\\. Start the backend with the \`develop\` command:
|
||||
|
||||
\`\`\`bash
|
||||
npx medusa develop
|
||||
\`\`\`
|
||||
|
||||
3\\. Use the tax provider in a region. You can do that either using the [Admin APIs](https://docs.medusajs.com/modules/taxes/admin/manage-tax-settings#change-tax-provider-of-a-region) or the [Medusa Admin](https://docs.medusajs.com/user-guide/taxes/manage#change-tax-provider).
|
||||
|
||||
4\\. To test out your tax provider implementation, you can [trigger taxes calculation manually](https://docs.medusajs.com/modules/taxes/storefront/manual-calculation).
|
||||
`,
|
||||
],
|
||||
},
|
||||
|
||||
// WORKFLOWS CONFIG
|
||||
"^workflows": {
|
||||
expandMembers: true,
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/tsconfig",
|
||||
"extends": [
|
||||
"../../../../packages/utils/tsconfig.json"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/file-service.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "file",
|
||||
parentIgnore: true,
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/types/src/common/config-module.ts",
|
||||
tsConfigName: "types.json",
|
||||
name: "medusa-config",
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/notification-service.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "notification",
|
||||
parentIgnore: true,
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/price-selection-strategy.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "price-selection",
|
||||
parentIgnore: true,
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/utils/src/search/abstract-service.ts",
|
||||
tsConfigName: "utils.json",
|
||||
name: "search",
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/tax-calculation-strategy.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "tax-calculation",
|
||||
parentIgnore: true,
|
||||
})
|
||||
@@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/tax-service.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "tax",
|
||||
parentIgnore: true,
|
||||
})
|
||||
@@ -16,7 +16,7 @@ import ifShowReturnsHelper from "./resources/helpers/if-show-returns"
|
||||
import ifShowTypeHierarchyHelper from "./resources/helpers/if-show-type-hierarchy"
|
||||
import indexSignatureTitleHelper from "./resources/helpers/index-signature-title"
|
||||
import parameterTableHelper from "./resources/helpers/parameter-table"
|
||||
import objectLiteralMemberHelper from "./resources/helpers/type-declaration-object-literal"
|
||||
import objectLiteralMemberHelper from "./resources/helpers/type-declaration-members"
|
||||
import referenceMember from "./resources/helpers/reference-member"
|
||||
import reflectionPathHelper from "./resources/helpers/reflection-path"
|
||||
import reflectionTitleHelper from "./resources/helpers/reflection-title"
|
||||
@@ -58,6 +58,11 @@ import ifHasMutationReturnHelper from "./resources/helpers/if-has-mutation-retur
|
||||
import reactQueryMutationReturnHelper from "./resources/helpers/react-query-mutation-return"
|
||||
import ifHasQueryReturnHelper from "./resources/helpers/if-has-query-return"
|
||||
import reactQueryQueryReturnHelper from "./resources/helpers/react-query-query-return"
|
||||
import endSectionsHelper from "./resources/helpers/end-sections"
|
||||
import getDeclarationChildrenHelper from "./resources/helpers/get-declaration-children"
|
||||
import ifShowSeparatorForTitleLevelHelper from "./resources/helpers/if-show-separator-for-title-level"
|
||||
import shouldExpandPropertiesHelper from "./resources/helpers/should-expand-properties"
|
||||
import shouldExpandDeclarationChildrenHelper from "./resources/helpers/should-expand-declaration-children"
|
||||
import { MarkdownTheme } from "./theme"
|
||||
|
||||
const TEMPLATE_PATH = path.join(__dirname, "resources", "templates")
|
||||
@@ -144,4 +149,9 @@ export function registerHelpers(theme: MarkdownTheme) {
|
||||
reactQueryMutationReturnHelper(theme)
|
||||
ifHasQueryReturnHelper(theme)
|
||||
reactQueryQueryReturnHelper(theme)
|
||||
endSectionsHelper(theme)
|
||||
getDeclarationChildrenHelper(theme)
|
||||
ifShowSeparatorForTitleLevelHelper(theme)
|
||||
shouldExpandPropertiesHelper(theme)
|
||||
shouldExpandDeclarationChildrenHelper(theme)
|
||||
}
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ export default function (theme: MarkdownTheme) {
|
||||
` = \`${stripLineBreaks(stripComments(`${this.defaultValue}`))}\``
|
||||
)
|
||||
}
|
||||
|
||||
return md.join("")
|
||||
}
|
||||
)
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import * as Handlebars from "handlebars"
|
||||
import { MarkdownTheme } from "../../theme"
|
||||
|
||||
export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper("endSections", function () {
|
||||
const { endSections } = theme.getFormattingOptionsForLocation()
|
||||
|
||||
if (!endSections?.length) {
|
||||
return ""
|
||||
}
|
||||
|
||||
const lineBreaks = "\n\n"
|
||||
const separator = `---${lineBreaks}`
|
||||
|
||||
return `${separator}${endSections.join(`${lineBreaks}${separator}`)}`
|
||||
})
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import * as Handlebars from "handlebars"
|
||||
import { DeclarationReflection } from "typedoc"
|
||||
import { getTypeChildren } from "utils"
|
||||
import { MarkdownTheme } from "../../theme"
|
||||
|
||||
export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper(
|
||||
"getDeclarationChildren",
|
||||
function (this: DeclarationReflection) {
|
||||
const { maxLevel } = theme.getFormattingOptionsForLocation()
|
||||
|
||||
if (!this.children && !this.type) {
|
||||
return []
|
||||
}
|
||||
|
||||
return (
|
||||
this.children ||
|
||||
getTypeChildren({
|
||||
reflectionType: this.type!,
|
||||
project: this.project,
|
||||
maxLevel,
|
||||
})
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import * as Handlebars from "handlebars"
|
||||
import { MarkdownTheme } from "../../theme"
|
||||
|
||||
export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper(
|
||||
"ifShowSeparatorForTitleLevel",
|
||||
function (this: unknown, options: Handlebars.HelperOptions) {
|
||||
const { currentTitleLevel } = theme
|
||||
|
||||
return currentTitleLevel <= 2 ? options.fn(this) : options.inverse(this)
|
||||
}
|
||||
)
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as Handlebars from "handlebars"
|
||||
import { MarkdownTheme } from "../../theme"
|
||||
|
||||
export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper("shouldExpandDeclarationChildren", function () {
|
||||
const { currentTitleLevel } = theme
|
||||
const { expandMembers } = theme.getFormattingOptionsForLocation()
|
||||
|
||||
return expandMembers && currentTitleLevel <= 3
|
||||
})
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import * as Handlebars from "handlebars"
|
||||
import { MarkdownTheme } from "../../theme"
|
||||
|
||||
export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper("shouldExpandProperties", function (title: string) {
|
||||
const { currentTitleLevel } = theme
|
||||
const { expandProperties = false } = theme.getFormattingOptionsForLocation()
|
||||
|
||||
return title === "Properties" && expandProperties && currentTitleLevel <= 3
|
||||
})
|
||||
}
|
||||
-2
@@ -7,8 +7,6 @@ export default function (theme: MarkdownTheme) {
|
||||
function (title: string) {
|
||||
const { parameterStyle } = theme.getFormattingOptionsForLocation()
|
||||
|
||||
// console.log(parameterStyle, title)
|
||||
|
||||
return parameterStyle === "component" && title === "Properties"
|
||||
}
|
||||
)
|
||||
|
||||
+25
-1
@@ -86,7 +86,7 @@
|
||||
|
||||
{{#with type.declaration}}
|
||||
|
||||
{{{titleLevel}}} Type declaration
|
||||
{{{titleLevel}}} Properties
|
||||
|
||||
{{/with}}
|
||||
|
||||
@@ -102,4 +102,28 @@
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{#if (sectionEnabled "member_declaration_children")}}
|
||||
|
||||
{{#if (shouldExpandDeclarationChildren)}}
|
||||
|
||||
{{#each (getDeclarationChildren)}}
|
||||
|
||||
{{> member}}
|
||||
|
||||
{{/each}}
|
||||
|
||||
{{else}}
|
||||
|
||||
{{#with (getDeclarationChildren)}}
|
||||
|
||||
{{{titleLevel}}} Properties
|
||||
|
||||
{{{typeDeclarationMembers}}}
|
||||
|
||||
{{/with}}
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{> member.sources}}
|
||||
+11
-9
@@ -56,14 +56,6 @@
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{#unless @last}}
|
||||
{{#unless hasOwnDocument}}
|
||||
{{#unless removeSeparator}}
|
||||
___
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
|
||||
{{#unless hasOwnDocument}}
|
||||
|
||||
{{#if name}}
|
||||
@@ -72,4 +64,14 @@ ___
|
||||
|
||||
{{/if}}
|
||||
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
|
||||
{{#ifShowSeparatorForTitleLevel}}
|
||||
{{#unless @last}}
|
||||
{{#unless hasOwnDocument}}
|
||||
{{#unless removeSeparator}}
|
||||
___
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/unless}}
|
||||
{{/ifShowSeparatorForTitleLevel}}
|
||||
+20
-2
@@ -4,9 +4,11 @@
|
||||
|
||||
{{#each categories}}
|
||||
|
||||
{{#ifShowSeparatorForTitleLevel}}
|
||||
{{#unless @first}}
|
||||
___
|
||||
{{/unless}}
|
||||
{{/ifShowSeparatorForTitleLevel}}
|
||||
|
||||
{{#unless (getFormattingOption "expandMembers")}}
|
||||
|
||||
@@ -20,7 +22,15 @@ ___
|
||||
|
||||
{{/unless}}
|
||||
|
||||
{{#if (showPropertiesAsComponent title)}}
|
||||
{{#if (shouldExpandProperties title)}}
|
||||
|
||||
{{#each children}}
|
||||
|
||||
{{> member }}
|
||||
|
||||
{{/each}}
|
||||
|
||||
{{else if (showPropertiesAsComponent title)}}
|
||||
|
||||
{{#with children}}
|
||||
|
||||
@@ -64,7 +74,15 @@ ___
|
||||
|
||||
{{/unless}}
|
||||
|
||||
{{#if (showPropertiesAsComponent title)}}
|
||||
{{#if (shouldExpandProperties title)}}
|
||||
|
||||
{{#each children}}
|
||||
|
||||
{{> member }}
|
||||
|
||||
{{/each}}
|
||||
|
||||
{{else if (showPropertiesAsComponent title)}}
|
||||
|
||||
{{#with children}}
|
||||
|
||||
|
||||
@@ -4,9 +4,11 @@
|
||||
|
||||
{{#each categories}}
|
||||
|
||||
{{#ifShowSeparatorForTitleLevel}}
|
||||
{{#unless @first}}
|
||||
___
|
||||
{{/unless}}
|
||||
{{/ifShowSeparatorForTitleLevel}}
|
||||
|
||||
{{#unless allChildrenHaveOwnDocument}}
|
||||
|
||||
@@ -44,9 +46,11 @@ ___
|
||||
|
||||
{{#unless allChildrenHaveOwnDocument}}
|
||||
|
||||
{{#ifShowSeparatorForTitleLevel}}
|
||||
{{#unless @first}}
|
||||
___
|
||||
{{/unless}}
|
||||
{{/ifShowSeparatorForTitleLevel}}
|
||||
|
||||
{{> members.group}}
|
||||
|
||||
|
||||
@@ -7,3 +7,5 @@
|
||||
{{{comment this}}}
|
||||
|
||||
{{/with}}
|
||||
|
||||
{{{ endSections }}}
|
||||
+3
-1
@@ -144,4 +144,6 @@
|
||||
|
||||
{{> main}}
|
||||
|
||||
{{/with}}
|
||||
{{/with}}
|
||||
|
||||
{{{ endSections }}}
|
||||
+2
@@ -11,3 +11,5 @@
|
||||
{{decrementCurrentTitleLevel}}
|
||||
|
||||
{{/with}}
|
||||
|
||||
{{{ endSections }}}
|
||||
+34
-20
@@ -31,7 +31,7 @@ export function getReflectionTypeParameters({
|
||||
comment,
|
||||
level = 1,
|
||||
maxLevel,
|
||||
wrapObject = false,
|
||||
wrapObject,
|
||||
isReturn = true,
|
||||
}: GetReflectionTypeParametersParams): Parameter[] {
|
||||
const typeName = getType({
|
||||
@@ -52,6 +52,20 @@ export function getReflectionTypeParameters({
|
||||
})
|
||||
|
||||
const formatParameter = () => {
|
||||
let description = ""
|
||||
|
||||
if (comment) {
|
||||
if (isReturn) {
|
||||
description = getReturnComment(comment)
|
||||
}
|
||||
|
||||
if (!description.length) {
|
||||
description = Handlebars.helpers.comment(comment.summary)
|
||||
}
|
||||
} else if (!isReturn) {
|
||||
description = loadComment(typeName, project)
|
||||
}
|
||||
|
||||
return {
|
||||
name: "name" in reflectionType ? reflectionType.name : typeName,
|
||||
type,
|
||||
@@ -65,13 +79,7 @@ export function getReflectionTypeParameters({
|
||||
reflectionType.declaration as DeclarationReflection
|
||||
) || ""
|
||||
: "",
|
||||
description: comment
|
||||
? isReturn
|
||||
? getReturnComment(comment)
|
||||
: Handlebars.helpers.comment(comment.summary)
|
||||
: !comment && !isReturn
|
||||
? loadComment(typeName, project)
|
||||
: "",
|
||||
description,
|
||||
expandable: comment?.hasModifier(`@expandable`) || false,
|
||||
featureFlag: Handlebars.helpers.featureFlag(comment),
|
||||
children: [],
|
||||
@@ -99,20 +107,25 @@ export function getReflectionTypeParameters({
|
||||
if (!reflectionTypeArg) {
|
||||
return
|
||||
}
|
||||
const typeArgComponent = getReflectionTypeParameters({
|
||||
reflectionType: reflectionTypeArg,
|
||||
project,
|
||||
level: level + 1,
|
||||
maxLevel,
|
||||
})
|
||||
|
||||
componentItem[parentKey - 1].children?.push(...typeArgComponent)
|
||||
componentItem[parentKey - 1].children?.push(
|
||||
...getReflectionTypeParameters({
|
||||
reflectionType: reflectionTypeArg,
|
||||
project,
|
||||
level: level + 1,
|
||||
maxLevel,
|
||||
isReturn: false,
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
} else {
|
||||
const reflection = (reflectionType.reflection ||
|
||||
getProjectChild(project, reflectionType.name)) as DeclarationReflection
|
||||
const parentKey = wrapObject
|
||||
const shouldWrapObject =
|
||||
wrapObject ||
|
||||
(wrapObject === undefined && level > 1 && canRetrieveChildren)
|
||||
const parentKey = shouldWrapObject
|
||||
? componentItem.push(formatParameter())
|
||||
: undefined
|
||||
if (reflection) {
|
||||
@@ -149,10 +162,8 @@ export function getReflectionTypeParameters({
|
||||
? componentItem[parentKey - 1].children?.push(childParameter)
|
||||
: componentItem.push(childParameter)
|
||||
}
|
||||
} else {
|
||||
parentKey
|
||||
? componentItem[parentKey - 1].children?.push(formatParameter())
|
||||
: componentItem.push(formatParameter())
|
||||
} else if (!parentKey) {
|
||||
componentItem.push(formatParameter())
|
||||
}
|
||||
}
|
||||
} else if (reflectionType.type === "array") {
|
||||
@@ -163,6 +174,7 @@ export function getReflectionTypeParameters({
|
||||
project,
|
||||
level: level + 1,
|
||||
maxLevel,
|
||||
isReturn: false,
|
||||
})
|
||||
componentItem[parentKey - 1].children?.push(...elementTypeItem)
|
||||
}
|
||||
@@ -186,6 +198,7 @@ export function getReflectionTypeParameters({
|
||||
project,
|
||||
level: level + 1,
|
||||
maxLevel,
|
||||
isReturn: false,
|
||||
})
|
||||
pushTo.push(...elementTypeItem)
|
||||
})
|
||||
@@ -200,6 +213,7 @@ export function getReflectionTypeParameters({
|
||||
project,
|
||||
level: level + 1,
|
||||
maxLevel,
|
||||
isReturn: false,
|
||||
})
|
||||
|
||||
parentKey
|
||||
|
||||
+2
@@ -62,6 +62,7 @@ export type FormattingOptionType = {
|
||||
}
|
||||
reflectionDescription?: string
|
||||
expandMembers?: boolean
|
||||
expandProperties?: boolean
|
||||
showCommentsAsHeader?: boolean
|
||||
showCommentsAsDetails?: boolean
|
||||
parameterStyle?: ParameterStyle
|
||||
@@ -71,6 +72,7 @@ export type FormattingOptionType = {
|
||||
mdxImports?: string[]
|
||||
maxLevel?: number
|
||||
fileNameSeparator?: string
|
||||
endSections?: string[]
|
||||
}
|
||||
|
||||
export declare module "typedoc" {
|
||||
|
||||
+118366
-115681
File diff suppressed because it is too large
Load Diff
+49976
-34226
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user