docs: fix empty return in references (#11343)
This commit is contained in:
@@ -132,10 +132,6 @@ class MyAuthProviderService extends AbstractAuthModuleProvider {
|
||||
|
||||
<TypeList types={[{"name":"options","type":"`Record<any, any>`","description":"The provider's options.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
#### Returns
|
||||
|
||||
<TypeList types={[]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
### authenticate
|
||||
|
||||
This method authenticates the user.
|
||||
|
||||
@@ -116,10 +116,6 @@ class MyFileProviderService extends AbstractFileProviderService {
|
||||
|
||||
<TypeList types={[{"name":"options","type":"`Record<any, any>`","description":"The provider's options.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
#### Returns
|
||||
|
||||
<TypeList types={[]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
### upload
|
||||
|
||||
This method uploads a file using your provider's custom logic.
|
||||
|
||||
@@ -104,10 +104,6 @@ class MyNotificationProviderService extends AbstractNotificationProviderService
|
||||
|
||||
<TypeList types={[{"name":"options","type":"`Record<any, any>`","description":"The provider's options.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
#### Returns
|
||||
|
||||
<TypeList types={[]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
### send
|
||||
|
||||
This method is used to send a notification using the third-party provider or your custom logic.
|
||||
|
||||
@@ -135,10 +135,6 @@ class MyPaymentProviderService extends AbstractPaymentProvider<Options> {
|
||||
|
||||
<TypeList types={[{"name":"options","type":"`Record<any, any>`","description":"The provider's options.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
#### Returns
|
||||
|
||||
<TypeList types={[]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="validateOptions"/>
|
||||
|
||||
### capturePayment
|
||||
|
||||
This method is used to capture a payment. The payment is captured in one of the following scenarios:
|
||||
|
||||
@@ -79,7 +79,3 @@ myWorkflow()
|
||||
## Parameters
|
||||
|
||||
<TypeList types={[{"name":"message","type":"`string`","description":"An optional message to be logged.","optional":false,"defaultValue":"\"Permanent failure\"","expandable":false,"children":[]},{"name":"compensateInput","type":"`unknown`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="permanentFailure"/>
|
||||
|
||||
## Returns
|
||||
|
||||
<TypeList types={[]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" sectionTitle="permanentFailure"/>
|
||||
|
||||
@@ -10,13 +10,22 @@ export default function (theme: MarkdownTheme) {
|
||||
Handlebars.registerHelper(
|
||||
"returns",
|
||||
function (reflection: SignatureReflection) {
|
||||
let returnContent = ""
|
||||
if (reflection.variant === "signature" && "type" in reflection) {
|
||||
return getReturnFromType(theme, reflection)
|
||||
returnContent = getReturnFromType(theme, reflection)
|
||||
} else if (reflection.comment) {
|
||||
return getReturnFromComment(theme, reflection.comment, reflection.name)
|
||||
} else {
|
||||
returnContent = getReturnFromComment(
|
||||
theme,
|
||||
reflection.comment,
|
||||
reflection.name
|
||||
)
|
||||
}
|
||||
|
||||
if (!returnContent.length) {
|
||||
return ""
|
||||
}
|
||||
|
||||
return `${Handlebars.helpers.titleLevel()} Returns\n\n${returnContent}`
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -44,6 +53,10 @@ function getReturnFromType(
|
||||
maxLevel,
|
||||
})
|
||||
|
||||
if (!componentItems.length) {
|
||||
return ""
|
||||
}
|
||||
|
||||
if (parameterStyle === "component") {
|
||||
return formatParameterComponent({
|
||||
parameterComponent,
|
||||
|
||||
@@ -68,12 +68,12 @@
|
||||
|
||||
{{#if type}}
|
||||
|
||||
{{{titleLevel}}} Returns
|
||||
|
||||
{{#if (sectionEnabled "member_signature_returns")}}
|
||||
|
||||
{{#with type}}
|
||||
|
||||
{{{titleLevel}}} Returns
|
||||
|
||||
{{{type 'all'}}}
|
||||
|
||||
{{/with}}
|
||||
|
||||
@@ -280,12 +280,27 @@ export function loadComment(
|
||||
return ""
|
||||
}
|
||||
|
||||
const emptyValues = ["void", "never", "undefined"]
|
||||
|
||||
export function isEmpty(reflectionTypes: SomeType[]) {
|
||||
return reflectionTypes.every(
|
||||
(type) =>
|
||||
type.type === "intrinsic" &&
|
||||
(type.name === "void" ||
|
||||
type.name === "never" ||
|
||||
type.name === "undefined")
|
||||
)
|
||||
return reflectionTypes.every((type) => {
|
||||
if (type.type === "intrinsic" && emptyValues.includes(type.name)) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (type.type !== "union") {
|
||||
return false
|
||||
}
|
||||
|
||||
return type.types.every((unionType) => {
|
||||
if (
|
||||
unionType.type === "intrinsic" &&
|
||||
emptyValues.includes(unionType.name)
|
||||
) {
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user