docs: add TSDoc for payment processor + generate docs (#5917)
* added tsdocs for payment processor * generated reference for payment processor
This commit is contained in:
@@ -12,7 +12,7 @@ const require = createRequire(import.meta.url)
|
||||
const referenceNames = process.argv.slice(2) || ["all"]
|
||||
const basePath = path.join(require.resolve("typedoc-config"), "..")
|
||||
let generatedCount = 0
|
||||
let totalCount = 0
|
||||
let totalCount = referenceNames.length
|
||||
let ranMerger = false
|
||||
|
||||
if (!referenceNames.length) {
|
||||
@@ -37,7 +37,6 @@ referenceNames.forEach((name) => {
|
||||
} else if (name === "merge") {
|
||||
runMerger()
|
||||
} else {
|
||||
totalCount = 1
|
||||
generateReference(`${name}.js`)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -227,6 +227,27 @@ module.exports = {
|
||||
},
|
||||
},
|
||||
|
||||
// PAYMENT CONFIG
|
||||
"^payment": {
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
},
|
||||
maxLevel: 2,
|
||||
},
|
||||
"^payment/.*AbstractPaymentProcessor": {
|
||||
reflectionDescription: `In this document, you’ll learn how to create a Payment Processor in your Medusa backend. If you’re unfamiliar with the Payment architecture in Medusa, make sure to check out the [overview](https://docs.medusajs.com/modules/carts-and-checkout/payment) first.`,
|
||||
frontmatterData: {
|
||||
displayed_sidebar: "modules",
|
||||
slug: "/modules/carts-and-checkout/backend/add-payment-provider",
|
||||
},
|
||||
reflectionTitle: {
|
||||
fullReplacement: "How to Create a Payment Processor",
|
||||
},
|
||||
reflectionGroups: {
|
||||
Properties: false,
|
||||
},
|
||||
},
|
||||
|
||||
// PRICING CONFIG
|
||||
"^(pricing|IPricingModuleService)": {
|
||||
...modulesOptions,
|
||||
|
||||
@@ -5,5 +5,4 @@ module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/fulfillment-service.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "fulfillment",
|
||||
// enableInternalResolve: true,
|
||||
})
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||
const getConfig = require("./utils/get-config")
|
||||
|
||||
module.exports = getConfig({
|
||||
entryPointPath: "packages/medusa/src/interfaces/payment-processor.ts",
|
||||
tsConfigName: "medusa.json",
|
||||
name: "payment",
|
||||
})
|
||||
+7
-5
@@ -8,7 +8,7 @@ import {
|
||||
} from "typedoc"
|
||||
import { MarkdownTheme } from "../../theme"
|
||||
import { memberSymbol, stripComments } from "../../utils"
|
||||
import { escapeChars, stripLineBreaks } from "utils"
|
||||
import { escapeChars, stripLineBreaks, getType as getTypeUtils } from "utils"
|
||||
|
||||
export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper(
|
||||
@@ -25,10 +25,12 @@ export default function (theme: MarkdownTheme) {
|
||||
}
|
||||
return (
|
||||
(reflection.parent?.kindOf(ReflectionKind.Enum) ? " = " : ": ") +
|
||||
Handlebars.helpers.type.call(
|
||||
reflectionType ? reflectionType : reflection,
|
||||
"object"
|
||||
)
|
||||
getTypeUtils({
|
||||
reflectionType: reflectionType || reflection.type,
|
||||
collapse: "object",
|
||||
escape: true,
|
||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+3
-1
@@ -66,7 +66,9 @@ export default function (theme: MarkdownTheme) {
|
||||
md.push(`(${getParameters(this.parameters, false)})`)
|
||||
|
||||
if (this.type && !this.parent?.kindOf(ReflectionKind.Constructor)) {
|
||||
md.push(`: ${Handlebars.helpers.type.call(this.type, "none", false)}`)
|
||||
md.push(
|
||||
`: ${Handlebars.helpers.type.call(this.type, "none", !expandMembers)}`
|
||||
)
|
||||
}
|
||||
|
||||
if (!expandMembers) {
|
||||
|
||||
+1
-1
@@ -19,7 +19,7 @@ export default function (theme: MarkdownTheme) {
|
||||
|
||||
const properties = this.reduce(
|
||||
(acc: ReflectionParameterType[], current: ReflectionParameterType) =>
|
||||
parseParams(current, acc),
|
||||
parseParams(current, acc, false),
|
||||
[]
|
||||
) as DeclarationReflection[]
|
||||
|
||||
|
||||
@@ -23,13 +23,16 @@ export function flattenParams(
|
||||
|
||||
export function parseParams(
|
||||
current: ReflectionParameterType,
|
||||
acc: ReflectionParameterType[]
|
||||
acc: ReflectionParameterType[],
|
||||
flatten?: boolean
|
||||
): ReflectionParameterType[] {
|
||||
const shouldFlatten =
|
||||
current.type &&
|
||||
"declaration" in current.type &&
|
||||
current.type?.declaration?.kind === ReflectionKind.TypeLiteral &&
|
||||
current.type?.declaration?.children
|
||||
flatten !== undefined
|
||||
? flatten
|
||||
: current.type &&
|
||||
"declaration" in current.type &&
|
||||
current.type?.declaration?.kind === ReflectionKind.TypeLiteral &&
|
||||
current.type?.declaration?.children
|
||||
return shouldFlatten
|
||||
? [...acc, current, ...flattenParams(current)]
|
||||
: [...acc, current]
|
||||
|
||||
+2
-10
@@ -128,12 +128,13 @@ export function reflectionComponentFormatter({
|
||||
reflectionType: reflection.type,
|
||||
collapse: "object",
|
||||
project: reflection.project,
|
||||
escape: true,
|
||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||
})
|
||||
: getReflectionType({
|
||||
reflectionType: reflection,
|
||||
collapse: "object",
|
||||
wrapBackticks: true,
|
||||
// escape: true,
|
||||
project: reflection.project,
|
||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||
}),
|
||||
@@ -153,15 +154,6 @@ export function reflectionComponentFormatter({
|
||||
(reflection.type || hasChildren) &&
|
||||
level + 1 <= (maxLevel || MarkdownTheme.MAX_LEVEL)
|
||||
) {
|
||||
// if (
|
||||
// reflection.name === "user" &&
|
||||
// reflection.type &&
|
||||
// "name" in reflection.type &&
|
||||
// reflection.type.name.startsWith("Omit") &&
|
||||
// "typeArguments" in reflection.type
|
||||
// ) {
|
||||
// console.log(reflection)
|
||||
// }
|
||||
const children = hasChildren
|
||||
? reflection.children
|
||||
: getTypeChildren(reflection.type!, project || reflection.project)
|
||||
|
||||
+7
@@ -34,14 +34,21 @@ export function returnReflectionComponentFormatter({
|
||||
reflectionType,
|
||||
collapse: "object",
|
||||
wrapBackticks: false,
|
||||
escape: false,
|
||||
hideLink: true,
|
||||
project,
|
||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||
})
|
||||
// if (
|
||||
// typeName === "Record<string, unknown> \\| PaymentProcessorError"
|
||||
// ) {
|
||||
// console.log(reflectionType)
|
||||
// }
|
||||
const type = getType({
|
||||
reflectionType: reflectionType,
|
||||
collapse: "object",
|
||||
project,
|
||||
escape: true,
|
||||
getRelativeUrlMethod: Handlebars.helpers.relativeURL,
|
||||
})
|
||||
const componentItem: Parameter[] = []
|
||||
|
||||
@@ -312,10 +312,9 @@ export function getReferenceType({
|
||||
getRelativeUrlMethod,
|
||||
...options
|
||||
}: TypeOptions<ReferenceType>): string {
|
||||
escape = getShouldEscape(wrapBackticks, escape)
|
||||
|
||||
const shouldShowLink = !hideLink && model.name !== "Record"
|
||||
const wrappedInBackticks = wrapBackticks && !shouldShowLink
|
||||
escape = getShouldEscape(wrappedInBackticks, escape)
|
||||
let modelReflection = model.reflection
|
||||
if (!modelReflection && project) {
|
||||
// try to load reflection
|
||||
|
||||
+21400
-15623
File diff suppressed because it is too large
Load Diff
@@ -69,7 +69,7 @@
|
||||
},
|
||||
{
|
||||
"kind": "code",
|
||||
"text": "```ts title=src/services/my-fulfillment.ts\nimport { AbstractFulfillmentService } from \"@medusajs/medusa\"\n\nclass MyFulfillmentService extends AbstractFulfillmentService {\n // methods here...\n}\n```"
|
||||
"text": "```ts title=src/services/my-fulfillment.ts\nimport { AbstractFulfillmentService } from \"@medusajs/medusa\"\n\nclass MyFulfillmentService extends AbstractFulfillmentService {\n // methods here...\n}\n\nexport default MyFulfillmentService\n```"
|
||||
},
|
||||
{
|
||||
"kind": "text",
|
||||
@@ -105,7 +105,7 @@
|
||||
},
|
||||
{
|
||||
"kind": "text",
|
||||
"text": " property in the class is used when the fulfillment provider is created in the database.\n\nThe value of this property is also used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.\n\n"
|
||||
"text": " property in the fulfillment provider service is used when the fulfillment provider is added to the database.\n\nThe value of this property is also used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.\n\n"
|
||||
},
|
||||
{
|
||||
"kind": "code",
|
||||
@@ -154,7 +154,7 @@
|
||||
"content": [
|
||||
{
|
||||
"kind": "code",
|
||||
"text": "```ts\nclass MyFulfillmentService extends AbstractFulfillmentService {\n static identifier = \"my-fulfillment\"\n\n // ...\n}\n```"
|
||||
"text": "```ts\nclass MyFulfillmentService extends AbstractFulfillmentService {\n // ...\n constructor(container, options) {\n super(container)\n // you can access options here\n\n // you can also initialize a client that\n // communicates with a third-party service.\n this.client = new Client(options)\n }\n // ...\n}\n```"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -2204,7 +2204,7 @@
|
||||
},
|
||||
{
|
||||
"kind": "code",
|
||||
"text": "```ts title=src/services/my-fulfillment.ts\nimport { AbstractFulfillmentService } from \"@medusajs/medusa\"\n\nclass MyFulfillmentService extends AbstractFulfillmentService {\n // methods here...\n}\n```"
|
||||
"text": "```ts title=src/services/my-fulfillment.ts\nimport { AbstractFulfillmentService } from \"@medusajs/medusa\"\n\nclass MyFulfillmentService extends AbstractFulfillmentService {\n // methods here...\n}\n\nexport default MyFulfillmentService\n```"
|
||||
},
|
||||
{
|
||||
"kind": "text",
|
||||
@@ -2240,7 +2240,7 @@
|
||||
},
|
||||
{
|
||||
"kind": "text",
|
||||
"text": " property in the class is used when the fulfillment provider is created in the database.\n\nThe value of this property is also used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.\n\n"
|
||||
"text": " property in the fulfillment provider service is used when the fulfillment provider is added to the database.\n\nThe value of this property is also used to reference the fulfillment provider throughout Medusa. For example, it is used to [add a fulfillment provider](https://docs.medusajs.com/api/admin#regions_postregionsregionfulfillmentproviders) to a region.\n\n"
|
||||
},
|
||||
{
|
||||
"kind": "code",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user