diff --git a/docs-util/packages/typedoc-config/_merger.js b/docs-util/packages/typedoc-config/_merger.js index 9779688f8e..0af5346beb 100644 --- a/docs-util/packages/typedoc-config/_merger.js +++ b/docs-util/packages/typedoc-config/_merger.js @@ -221,9 +221,14 @@ module.exports = { "https://docs.medusajs.com/development/entities/repositories#retrieving-a-list-of-records", }, }, + "^medusa/classes/medusa\\.(Store*|Admin*)": { + reflectionGroups: { + Constructors: false, + }, + }, // PRICING CONFIG - "^pricing": { + "^(pricing|IPricingModuleService)": { ...modulesOptions, frontmatterData: { displayed_sidebar: "pricingReference", diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts index 31c55c9a69..7bc755f056 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/render-utils.ts @@ -91,7 +91,7 @@ export function registerHelpers(theme: MarkdownTheme) { ifShowBreadcrumbsHelper(theme) ifShowNamedAnchorsHelper(theme) ifShowPageTitleHelper(theme) - ifShowReturnsHelper() + ifShowReturnsHelper(theme) ifShowTypeHierarchyHelper() indexSignatureTitleHelper() parameterTableHelper() @@ -126,6 +126,6 @@ export function registerHelpers(theme: MarkdownTheme) { featureFlagHelper() decrementCurrentTitleLevelHelper(theme) incrementCurrentTitleLevelHelper(theme) - hasMoreThanOneSignatureHelper() + hasMoreThanOneSignatureHelper(theme) ifCanShowConstructorsTitleHelper() } diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/has-more-than-one-signature.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/has-more-than-one-signature.ts index d24549f3d8..e7c5d0e365 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/has-more-than-one-signature.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/has-more-than-one-signature.ts @@ -1,10 +1,13 @@ import { DeclarationReflection } from "typedoc" import * as Handlebars from "handlebars" +import getCorrectDeclarationReflection from "../../utils/get-correct-declaration-reflection" +import { MarkdownTheme } from "../../theme" -export default function () { +export default function (theme: MarkdownTheme) { Handlebars.registerHelper( "hasMoreThanOneSignature", function (model: DeclarationReflection) { + model = getCorrectDeclarationReflection(model, theme) || model return (model?.signatures?.length || 0) > 1 } ) diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/if-show-returns.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/if-show-returns.ts index 30cc221fec..4ddb3d46fa 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/if-show-returns.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/if-show-returns.ts @@ -1,10 +1,14 @@ import * as Handlebars from "handlebars" import { ReflectionKind, SignatureReflection } from "typedoc" +import getCorrectDeclarationReflection from "../../utils/get-correct-declaration-reflection" +import { MarkdownTheme } from "../../theme" -export default function () { +export default function (theme: MarkdownTheme) { Handlebars.registerHelper( "ifShowReturns", function (this: SignatureReflection, options: Handlebars.HelperOptions) { + this.parent = + getCorrectDeclarationReflection(this.parent, theme) || this.parent return this.type && !this.parent?.kindOf(ReflectionKind.Constructor) ? options.fn(this) : options.inverse(this) diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/signature-title.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/signature-title.ts index cce2772513..7d20368eb9 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/signature-title.ts +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/signature-title.ts @@ -7,6 +7,7 @@ import { import { memberSymbol } from "../../utils" import { MarkdownTheme } from "../../theme" import { getHTMLChar } from "utils" +import getCorrectDeclarationReflection from "../../utils/get-correct-declaration-reflection" export default function (theme: MarkdownTheme) { Handlebars.registerHelper( @@ -14,6 +15,8 @@ export default function (theme: MarkdownTheme) { function (this: SignatureReflection, accessor?: string, standalone = true) { const { sections, expandMembers = false } = theme.getFormattingOptionsForLocation() + this.parent = + getCorrectDeclarationReflection(this.parent, theme) || this.parent const parentHasMoreThanOneSignature = Handlebars.helpers.hasMoreThanOneSignature(this.parent) if ( @@ -24,6 +27,7 @@ export default function (theme: MarkdownTheme) { // only show title if there are more than one signatures return "" } + const md: string[] = [] if (!expandMembers) { diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs index f9cbb59a86..695a8c19c9 100755 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.declaration.hbs @@ -70,7 +70,7 @@ {{incrementCurrentTitleLevel}} -{{> member.signature showSources=false }} +{{> member.signature showSources=false parent=../type.declaration }} {{decrementCurrentTitleLevel}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.hbs index 30ac37c284..004ee43628 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.hbs @@ -16,7 +16,7 @@ {{#each signatures}} -{{> member.signature showSources=true }} +{{> member.signature showSources=true parent=.. }} {{/each}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs index 15c12ac98d..fc3de65f07 100644 --- a/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/resources/partials/member.signature.hbs @@ -1,4 +1,4 @@ -{{{signatureTitle accessor}}} +{{{signatureTitle accessor parent}}} {{#if (getFormattingOption "expandMembers")}} @@ -90,7 +90,7 @@ {{#each declaration.signatures}} -{{> member.signature showSources=false }} +{{> member.signature showSources=false parent=../declaration }} {{/each}} diff --git a/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/get-correct-declaration-reflection.ts b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/get-correct-declaration-reflection.ts new file mode 100644 index 0000000000..a55d74e379 --- /dev/null +++ b/docs-util/packages/typedoc-plugin-markdown-medusa/src/utils/get-correct-declaration-reflection.ts @@ -0,0 +1,33 @@ +import { DeclarationReflection } from "typedoc" +import { MarkdownTheme } from "../theme" + +/** + * Some reflections are loaded as objects rather than instances + * of DeclarationReflection. This tries to reload the declaration reflection + * if that's the case. + */ +export default function getCorrectDeclarationReflection( + refl: unknown, + theme: MarkdownTheme +): DeclarationReflection | undefined { + if ( + refl && + !(refl instanceof DeclarationReflection) && + typeof refl === "object" && + "id" in refl && + refl.id + ) { + if (theme.reflection?.id === refl.id) { + refl = theme.reflection! + } else { + refl = + (theme.project?.getReflectionById( + refl.id as number + ) as DeclarationReflection) || refl + } + } else if (!refl && theme.reflection) { + refl = theme.reflection + } + + return refl as DeclarationReflection | undefined +} diff --git a/www/apps/docs/content/references/IPricingModuleService/methods/pricing.IPricingModuleService.addPrices.mdx b/www/apps/docs/content/references/IPricingModuleService/methods/pricing.IPricingModuleService.addPrices.mdx index c5fa22ae65..49f1ee43f4 100644 --- a/www/apps/docs/content/references/IPricingModuleService/methods/pricing.IPricingModuleService.addPrices.mdx +++ b/www/apps/docs/content/references/IPricingModuleService/methods/pricing.IPricingModuleService.addPrices.mdx @@ -13,11 +13,11 @@ import ParameterTypes from "@site/src/components/ParameterTypes" This documentation provides a reference to the `addPrices` method. This belongs to the Pricing Module. -`**addPrices**(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)>` +## addPrices(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)> This method adds prices to a price set. -## Example +### Example To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`: @@ -88,7 +88,7 @@ async function addPricesToPriceSet (priceSetId: string) { } ``` -## Parameters +### Parameters -## Returns +### Returns -`**addPrices**(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]>` +## addPrices(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]> This method adds prices to multiple price sets. -## Example +### Example To add a default price to a price set, don't pass it any rules and make sure to pass it the `currency_code`: @@ -458,7 +458,7 @@ async function addPricesToPriceSet (priceSetId: string) { } ``` -## Parameters +### Parameters -## Returns +### Returns -## Returns +### Returns -`**addRules**(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]>` +## addRules(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]> This method adds rules to multiple price sets. -## Example +### Example ```ts import { @@ -304,7 +304,7 @@ async function addRulesToPriceSet (priceSetId: string) { } ``` -## Parameters +### Parameters -## Returns +### Returns -## Returns +### Returns -`**create**(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]>` +## create(data, sharedContext?): Promise<[PriceSetDTO](../../pricing/interfaces/pricing.PriceSetDTO.mdx)[]> This method is used to create multiple price sets. -## Example +### Example To create price sets with a default price, don't pass any rules and make sure to pass the `currency_code` of the price. For example: @@ -483,7 +483,7 @@ async function createPriceSets () { } ``` -## Parameters +### Parameters -## Returns +### Returns - -___ - ## Properties - -___ - ## Properties - -___ - ## Properties - -___ - ## Properties - -___ - ## Properties - -___ - ## Properties - -___ - ## Properties - -___ - ## Properties