diff --git a/.config/typedoc.json b/.config/typedoc.json
index ae6df8d04..f3c932a86 100644
--- a/.config/typedoc.json
+++ b/.config/typedoc.json
@@ -10,6 +10,7 @@
"EventHooksMomento",
"MarkedPlugin"
],
+ "sort": ["kind", "instance-first", "required-first", "alphabetical"],
"entryPoints": ["../src"],
"entryPointStrategy": "resolve",
"excludeExternals": true,
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5ba178ca5..a0200942f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,8 @@
- Added support for detecting comments directly before parameters as the parameter comment, #2019.
- Added support for using the comment directly before a constructor parameter that declares a property as the property comment, #2019.
+- Improved schema generation to give better autocomplete for the `sort` option.
+- Optional properties are now visually distinguished in the index/sidebar by rendering `prop` as `prop?`, #2023.
### Bug Fixes
diff --git a/scripts/generate_options_schema.js b/scripts/generate_options_schema.js
index 11c66b77f..b3c9f4e51 100644
--- a/scripts/generate_options_schema.js
+++ b/scripts/generate_options_schema.js
@@ -153,6 +153,10 @@ schema.properties.extends = {
items: { type: "string" },
};
+delete schema.properties.sort.items.type;
+schema.properties.sort.items.enum =
+ require("../dist/lib/utils/sort").SORT_STRATEGIES;
+
const output = JSON.stringify(schema, null, "\t");
if (process.argv.length > 2) {
diff --git a/src/lib/output/themes/default/partials/index.tsx b/src/lib/output/themes/default/partials/index.tsx
index ff0e46945..40b3d7f4d 100644
--- a/src/lib/output/themes/default/partials/index.tsx
+++ b/src/lib/output/themes/default/partials/index.tsx
@@ -1,4 +1,4 @@
-import { classNames, displayPartsToMarkdown, wbr } from "../../lib";
+import { classNames, displayPartsToMarkdown, renderName } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
import { JSX, Raw } from "../../../../utils";
import { ContainerReflection, DeclarationReflection, ReflectionCategory, ReflectionKind } from "../../../../models";
@@ -18,7 +18,7 @@ function renderCategory({ urlTo, icons }: DefaultThemeRenderContext, item: Refle
)}
>
{icons[item.kind]()}
- {item.name ? wbr(item.name) : {wbr(item.kindString!)}}
+ {renderName(item)}
{"\n"}
>
diff --git a/src/lib/output/themes/default/partials/navigation.tsx b/src/lib/output/themes/default/partials/navigation.tsx
index 5a0487538..e2cd16e6e 100644
--- a/src/lib/output/themes/default/partials/navigation.tsx
+++ b/src/lib/output/themes/default/partials/navigation.tsx
@@ -1,7 +1,7 @@
import { ContainerReflection, DeclarationReflection, Reflection, ReflectionKind } from "../../../../models";
import { JSX, partition } from "../../../../utils";
import type { PageEvent } from "../../../events";
-import { camelToTitleCase, classNames, wbr } from "../../lib";
+import { camelToTitleCase, classNames, renderName, wbr } from "../../lib";
import type { DefaultThemeRenderContext } from "../DefaultThemeRenderContext";
export function navigation(context: DefaultThemeRenderContext, props: PageEvent) {
@@ -155,7 +155,7 @@ export function secondaryNavigation(context: DefaultThemeRenderContext, props: P
>
{context.icons[child.kind]()}
- {wbr(child.name)}
+ {renderName(child)}
);
@@ -183,7 +183,7 @@ export function secondaryNavigation(context: DefaultThemeRenderContext, props: P
>
{context.icons[effectivePageParent.kind]()}
- {wbr(effectivePageParent.name)}
+ {renderName(effectivePageParent)}
{!!pageNavigation.length && }
diff --git a/src/lib/output/themes/lib.tsx b/src/lib/output/themes/lib.tsx
index d2e0f7972..834c7faa2 100644
--- a/src/lib/output/themes/lib.tsx
+++ b/src/lib/output/themes/lib.tsx
@@ -157,3 +157,18 @@ export function displayPartsToMarkdown(parts: CommentDisplayPart[], urlTo: Defau
return result.join("");
}
+
+/**
+ * Renders the reflection name with an additional `?` if optional.
+ */
+export function renderName(refl: Reflection) {
+ if (!refl.name) {
+ return {wbr(refl.kindString!)};
+ }
+
+ if (refl.flags.isOptional) {
+ return <>{wbr(refl.name)}?>;
+ }
+
+ return wbr(refl.name);
+}