Skip to content

Commit

Permalink
chore: allow typedoc theme even without default group options
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardomourar committed Nov 2, 2022
1 parent 76cc6b5 commit cb102a6
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/core-theme-documentation-generator/src/theme.tsx
@@ -1,16 +1,29 @@
import {
DefaultTheme,
DefaultThemeRenderContext,
JSX, // eslint-disable-line @typescript-eslint/no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
JSX,
PageEvent,
Reflection,
ReflectionCategory,
ReflectionKind,
} from "typedoc";

class SdkThemeContext extends DefaultThemeRenderContext {
override primaryNavigation = (props: PageEvent<Reflection>) => {
const defaultGroup = this.options.getValue("defaultGroup") as string;
const { categories } = props.model?.["groups"]?.find((value) => value.title === defaultGroup) ?? {};
const categories = [];
try {
const defaultGroup = this.options.getValue("defaultGroup") as string;
const group = props.model?.["groups"]?.find((value) => value.title === defaultGroup) ?? {};
categories.push(...(group.categories || []));
} catch (err) {
console.warn("No value was set for `defaultGroup` options");
if (props.model.isProject()) {
const category = new ReflectionCategory("Modules");
category.children.push(...props.model.getChildrenByKind(ReflectionKind.SomeModule));
categories.push(category);
}
}
if (categories?.length) {
const selected = props.model.isProject();

Expand Down

0 comments on commit cb102a6

Please sign in to comment.