Skip to content

Commit

Permalink
migrate configurations guide to reference
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Jan 19, 2024
1 parent 5305dab commit 5dc2813
Show file tree
Hide file tree
Showing 435 changed files with 12,756 additions and 10,934 deletions.
31 changes: 31 additions & 0 deletions docs-util/packages/typedoc-config/_merger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const baseSectionsOptions = {
member_signature_title: false,
member_signature_returns: false,
title_reflectionPath: false,
member_declaration_children: false,
}

const modulesSectionsOptions = {
Expand Down Expand Up @@ -265,6 +266,36 @@ npx medusa develop
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: {
Expand Down
8 changes: 8 additions & 0 deletions docs-util/packages/typedoc-config/medusa-config.js
Original file line number Diff line number Diff line change
@@ -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",
})
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -59,6 +59,10 @@ import reactQueryMutationReturnHelper from "./resources/helpers/react-query-muta
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")
Expand Down Expand Up @@ -146,4 +150,8 @@ export function registerHelpers(theme: MarkdownTheme) {
ifHasQueryReturnHelper(theme)
reactQueryQueryReturnHelper(theme)
endSectionsHelper(theme)
getDeclarationChildrenHelper(theme)
ifShowSeparatorForTitleLevelHelper(theme)
shouldExpandPropertiesHelper(theme)
shouldExpandDeclarationChildrenHelper(theme)
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function (theme: MarkdownTheme) {
` = \`${stripLineBreaks(stripComments(`${this.defaultValue}`))}\``
)
}

return md.join("")
}
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
})
)
}
)
}
Original file line number Diff line number Diff line change
@@ -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)
}
)
}
Original file line number Diff line number Diff line change
@@ -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
})
}
Original file line number Diff line number Diff line change
@@ -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
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

{{#with type.declaration}}

{{{titleLevel}}} Type declaration
{{{titleLevel}}} Properties

{{/with}}

Expand All @@ -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}}
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@

{{/if}}

{{#unless @last}}
{{#unless hasOwnDocument}}
{{#unless removeSeparator}}
___
{{/unless}}
{{/unless}}
{{/unless}}

{{#unless hasOwnDocument}}

{{#if name}}
Expand All @@ -72,4 +64,14 @@ ___

{{/if}}

{{/unless}}
{{/unless}}

{{#ifShowSeparatorForTitleLevel}}
{{#unless @last}}
{{#unless hasOwnDocument}}
{{#unless removeSeparator}}
___
{{/unless}}
{{/unless}}
{{/unless}}
{{/ifShowSeparatorForTitleLevel}}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

{{#each categories}}

{{#ifShowSeparatorForTitleLevel}}
{{#unless @first}}
___
{{/unless}}
{{/ifShowSeparatorForTitleLevel}}

{{#unless (getFormattingOption "expandMembers")}}

Expand All @@ -20,7 +22,15 @@ ___

{{/unless}}

{{#if (showPropertiesAsComponent title)}}
{{#if (shouldExpandProperties title)}}

{{#each children}}

{{> member }}

{{/each}}

{{else if (showPropertiesAsComponent title)}}

{{#with children}}

Expand Down Expand Up @@ -64,7 +74,15 @@ ___

{{/unless}}

{{#if (showPropertiesAsComponent title)}}
{{#if (shouldExpandProperties title)}}

{{#each children}}

{{> member }}

{{/each}}

{{else if (showPropertiesAsComponent title)}}

{{#with children}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

{{#each categories}}

{{#ifShowSeparatorForTitleLevel}}
{{#unless @first}}
___
{{/unless}}
{{/ifShowSeparatorForTitleLevel}}

{{#unless allChildrenHaveOwnDocument}}

Expand Down Expand Up @@ -44,9 +46,11 @@ ___

{{#unless allChildrenHaveOwnDocument}}

{{#ifShowSeparatorForTitleLevel}}
{{#unless @first}}
___
{{/unless}}
{{/ifShowSeparatorForTitleLevel}}

{{> members.group}}

Expand Down
1 change: 1 addition & 0 deletions docs-util/packages/types/lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export type FormattingOptionType = {
}
reflectionDescription?: string
expandMembers?: boolean
expandProperties?: boolean
showCommentsAsHeader?: boolean
showCommentsAsDetails?: boolean
parameterStyle?: ParameterStyle
Expand Down
Loading

0 comments on commit 5dc2813

Please sign in to comment.