);
-}
+};
diff --git a/src/Theme/Partials/Navigation/Sidebar/index.ts b/src/Theme/Partials/Navigation/Sidebar/index.ts
new file mode 100644
index 0000000..32879ec
--- /dev/null
+++ b/src/Theme/Partials/Navigation/Sidebar/index.ts
@@ -0,0 +1,24 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * This module contains the components that are used when rendering the sidebar.
+ *
+ * @module Theme/Partials/Navigation/Sidebar
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+
+export * from './navigation';
+export * from './sidebar';
+export * from './sidebarLinks';
diff --git a/src/Theme/Partials/Navigation/Sidebar/navigation.tsx b/src/Theme/Partials/Navigation/Sidebar/navigation.tsx
new file mode 100644
index 0000000..97fbe5f
--- /dev/null
+++ b/src/Theme/Partials/Navigation/Sidebar/navigation.tsx
@@ -0,0 +1,33 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+
+/**
+ * @module Theme/Partials/Navigation/Sidebar
+ * @author Alan Rodas Bonjour
+ */
+
+import { DefaultThemeRenderContext, JSX, PageEvent, Reflection, ReflectionKind } from 'typedoc';
+
+import { classNames } from '../../../../Utils/lib';
+
+export const navigation = (context: DefaultThemeRenderContext, props: PageEvent): JSX.Element => (
+
+);
diff --git a/src/templates/document.tsx b/src/Theme/Partials/Navigation/Sidebar/sidebar.tsx
old mode 100755
new mode 100644
similarity index 61%
rename from src/templates/document.tsx
rename to src/Theme/Partials/Navigation/Sidebar/sidebar.tsx
index fff1e1d..1ef3732
--- a/src/templates/document.tsx
+++ b/src/Theme/Partials/Navigation/Sidebar/sidebar.tsx
@@ -10,11 +10,17 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
-import type { DefaultThemeRenderContext, DocumentReflection } from 'typedoc';
-import { JSX, PageEvent } from 'typedoc';
-export const documentTemplate = ({ markdown }: DefaultThemeRenderContext, props: PageEvent) => (
-
-
-
+/**
+ * @module Theme/Partials/Navigation/Sidebar
+ * @author Alan Rodas Bonjour
+ */
+
+import { DefaultThemeRenderContext, JSX, PageEvent, Reflection } from 'typedoc';
+
+export const sidebar = (context: DefaultThemeRenderContext, props: PageEvent): JSX.Element => (
+ <>
+ {context.sidebarLinks()}
+ {context.navigation(props)}
+ >
);
diff --git a/src/partials/navigation/sidebar/sidebarLinks.tsx b/src/Theme/Partials/Navigation/Sidebar/sidebarLinks.tsx
similarity index 82%
rename from src/partials/navigation/sidebar/sidebarLinks.tsx
rename to src/Theme/Partials/Navigation/Sidebar/sidebarLinks.tsx
index df840cb..5aa155f 100644
--- a/src/partials/navigation/sidebar/sidebarLinks.tsx
+++ b/src/Theme/Partials/Navigation/Sidebar/sidebarLinks.tsx
@@ -10,9 +10,15 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
-import { JSX, DefaultThemeRenderContext } from 'typedoc';
-export function sidebarLinks(context: DefaultThemeRenderContext) {
+/**
+ * @module Theme/Partials/Navigation/Sidebar
+ * @author Alan Rodas Bonjour
+ */
+
+import { DefaultThemeRenderContext, JSX } from 'typedoc';
+
+export const sidebarLinks = (context: DefaultThemeRenderContext): JSX.Element | null => {
const links = Object.entries(context.options.getValue('sidebarLinks'));
const navLinks = Object.entries(context.options.getValue('navigationLinks'));
@@ -30,4 +36,4 @@ export function sidebarLinks(context: DefaultThemeRenderContext) {
))}
);
-}
+};
diff --git a/src/Theme/Partials/Navigation/Toolbar/index.ts b/src/Theme/Partials/Navigation/Toolbar/index.ts
new file mode 100644
index 0000000..e0e3549
--- /dev/null
+++ b/src/Theme/Partials/Navigation/Toolbar/index.ts
@@ -0,0 +1,22 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * This module contains the components that are used when rendering the toolbar.
+ *
+ * @module Theme/Partials/Navigation/Toolbar
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+
+export * from './toolbar';
diff --git a/src/partials/navigation/toolbar/toolbar.tsx b/src/Theme/Partials/Navigation/Toolbar/toolbar.tsx
similarity index 84%
rename from src/partials/navigation/toolbar/toolbar.tsx
rename to src/Theme/Partials/Navigation/Toolbar/toolbar.tsx
index a196803..8b0f5f1 100755
--- a/src/partials/navigation/toolbar/toolbar.tsx
+++ b/src/Theme/Partials/Navigation/Toolbar/toolbar.tsx
@@ -10,12 +10,18 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * @module Theme/Partials/Navigation/Toolbar
+ * @author Alan Rodas Bonjour
+ */
+
import { JSX } from 'typedoc';
-import type { Reflection, PageEvent, DefaultThemeRenderContext } from 'typedoc';
+import type { DefaultThemeRenderContext, PageEvent, Reflection } from 'typedoc';
-import { getDisplayName } from '../../lib';
+import { getDisplayName } from '../../../../Utils/lib';
-export const toolbar = (context: DefaultThemeRenderContext, props: PageEvent) => (
+export const toolbar = (context: DefaultThemeRenderContext, props: PageEvent): JSX.Element => (
diff --git a/src/Theme/Partials/Navigation/index.ts b/src/Theme/Partials/Navigation/index.ts
new file mode 100644
index 0000000..1c54dde
--- /dev/null
+++ b/src/Theme/Partials/Navigation/index.ts
@@ -0,0 +1,25 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * This module contains the components that are used when rendering the different
+ * navigation elements of the page.
+ *
+ * @module Theme/Partials/Navigation
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+
+export * from './PageSidebar';
+export * from './Sidebar';
+export * from './Toolbar';
diff --git a/src/partials/sections/breadcrumb.tsx b/src/Theme/Partials/Sections/breadcrumb.tsx
similarity index 92%
rename from src/partials/sections/breadcrumb.tsx
rename to src/Theme/Partials/Sections/breadcrumb.tsx
index 9d58561..841b688 100755
--- a/src/partials/sections/breadcrumb.tsx
+++ b/src/Theme/Partials/Sections/breadcrumb.tsx
@@ -10,6 +10,12 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * @module Theme/Partials/Sections
+ * @author Alan Rodas Bonjour
+ */
+
import { JSX } from 'typedoc';
import type { DefaultThemeRenderContext, Reflection } from 'typedoc';
diff --git a/src/partials/sections/footer.tsx b/src/Theme/Partials/Sections/footer.tsx
similarity index 91%
rename from src/partials/sections/footer.tsx
rename to src/Theme/Partials/Sections/footer.tsx
index 77b4219..2844610 100755
--- a/src/partials/sections/footer.tsx
+++ b/src/Theme/Partials/Sections/footer.tsx
@@ -10,11 +10,17 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * @module Theme/Partials/Sections
+ * @author Alan Rodas Bonjour
+ */
+
import { JSX } from 'typedoc';
import type { GobstonesThemeContext } from '../../GobstonesThemeContext';
-export function footer(context: GobstonesThemeContext) {
+export const footer = (context: GobstonesThemeContext): JSX.Element => {
const hideGenerator = context.options.getValue('hideGenerator');
let generatorDisplay = <>>;
if (!hideGenerator) {
@@ -22,7 +28,7 @@ export function footer(context: GobstonesThemeContext) {
// Only handles one occurrence, but that's all I expect...
const index = message.indexOf('TypeDoc');
- if (index == -1) {
+ if (index === -1) {
generatorDisplay =
+);
diff --git a/src/Theme/Partials/index.ts b/src/Theme/Partials/index.ts
new file mode 100644
index 0000000..4b52eb6
--- /dev/null
+++ b/src/Theme/Partials/index.ts
@@ -0,0 +1,35 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * This module exports all the components used when rendering the elements
+ * of the page.
+ *
+ *
+ * @module Theme/Partials
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+
+export * from './Comments';
+export * from './Members';
+export * from './Navigation';
+export * from './Sections';
+export * from './Types';
+
+export * from './anchor-icon';
+export * from './hierarchy';
+export * from '../Icons/icon';
+export * from './indexElement';
+export * from './parameter';
+export * from './reflectionPreview';
diff --git a/src/partials/index.tsx b/src/Theme/Partials/indexElement.tsx
similarity index 65%
rename from src/partials/index.tsx
rename to src/Theme/Partials/indexElement.tsx
index dd07a69..9859dab 100755
--- a/src/partials/index.tsx
+++ b/src/Theme/Partials/indexElement.tsx
@@ -10,46 +10,50 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * @module Theme/Partials
+ * @author Alan Rodas Bonjour
+ */
+
import { JSX } from 'typedoc';
-import type { DefaultThemeRenderContext, ContainerReflection, ReflectionCategory, ReflectionGroup } from 'typedoc';
+import type { ContainerReflection, DefaultThemeRenderContext, ReflectionCategory, ReflectionGroup } from 'typedoc';
-import { classNames, renderName } from './lib';
+import { classNames, renderName } from '../../Utils/lib';
-function renderCategory(
+const renderCategory = (
{ urlTo, icons, getReflectionClasses, markdown }: DefaultThemeRenderContext,
item: ReflectionCategory | ReflectionGroup,
prependName = ''
-) {
- return (
-
-
+);
diff --git a/src/partials/reflectionPreview.tsx b/src/Theme/Partials/reflectionPreview.tsx
similarity index 83%
rename from src/partials/reflectionPreview.tsx
rename to src/Theme/Partials/reflectionPreview.tsx
index 4555217..6373a08 100755
--- a/src/partials/reflectionPreview.tsx
+++ b/src/Theme/Partials/reflectionPreview.tsx
@@ -10,18 +10,24 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * @module Theme/Partials
+ * @author Alan Rodas Bonjour
+ */
+
import {
DeclarationReflection,
- ReflectionKind,
- Reflection,
- ReflectionType,
DefaultThemeRenderContext,
- JSX
+ JSX,
+ Reflection,
+ ReflectionKind,
+ ReflectionType
} from 'typedoc';
-import { getKindClass, renderTypeParametersSignature } from './lib';
+import { getKindClass, renderTypeParametersSignature } from '../../Utils/lib';
-export function reflectionPreview(context: DefaultThemeRenderContext, props: Reflection) {
+export const reflectionPreview = (context: DefaultThemeRenderContext, props: Reflection): JSX.Element | undefined => {
if (!(props instanceof DeclarationReflection)) return;
// Each property of the interface will have a member rendered later on the page describing it, so generate
@@ -38,4 +44,4 @@ export function reflectionPreview(context: DefaultThemeRenderContext, props: Ref
);
}
return undefined;
-}
+};
diff --git a/src/Theme/Templates/documentTemplate.tsx b/src/Theme/Templates/documentTemplate.tsx
new file mode 100755
index 0000000..c04d9b3
--- /dev/null
+++ b/src/Theme/Templates/documentTemplate.tsx
@@ -0,0 +1,38 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+
+/**
+ * @module Theme/Templates
+ * @author Alan Rodas Bonjour
+ */
+
+import type { DefaultThemeRenderContext, DocumentReflection } from 'typedoc';
+import { JSX, PageEvent } from 'typedoc';
+
+/**
+ * The component that defines how to render a markdown document
+ * page. Rendering documents other than the README use this template.
+ *
+ * @param context - The theme context.
+ * @param props - A page event with the document's reflection.
+ *
+ * @returns A JSX.Element to render the markdown document.
+ */
+export const documentTemplate = (
+ context: DefaultThemeRenderContext,
+ props: PageEvent
+): JSX.Element => (
+
+
+
+);
diff --git a/src/Theme/Templates/hierarchyTemplate.tsx b/src/Theme/Templates/hierarchyTemplate.tsx
new file mode 100755
index 0000000..1421a17
--- /dev/null
+++ b/src/Theme/Templates/hierarchyTemplate.tsx
@@ -0,0 +1,86 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+
+/**
+ * @module Theme/Templates
+ * @author Alan Rodas Bonjour
+ */
+
+import { JSX } from 'typedoc';
+import type { DeclarationReflection, DefaultThemeRenderContext, PageEvent, ProjectReflection } from 'typedoc';
+
+import { getHierarchyRoots } from '../../Utils/lib';
+
+/**
+ * The component that defines how to render an element's hierarchy.
+ * The page that displays the hierarchy of an element as main content
+ * uses this template.
+ *
+ * @param context - The theme context.
+ * @param props - A page event with the project's reflection.
+ *
+ * @returns A JSX.Element to render the hierarchy.
+ */
+export const hierarchyTemplate = (
+ context: DefaultThemeRenderContext,
+ props: PageEvent
+): JSX.Element => (
+ <>
+
+ ))}
+ >
+);
+
+/**
+ * The component that defines how to render an element's hierarchy
+ * from a particular root, recursively.
+ *
+ * @param context - The theme context.
+ * @param root - The main reflation from which to start the recursion.
+ * @param seen - A set containing all previously seen elements.
+ *
+ * @returns A JSX.Element to render the hierarchy of this element.
+ */
+const fullHierarchy = (
+ context: DefaultThemeRenderContext,
+ root: DeclarationReflection,
+ seen = new Set()
+): JSX.Element | undefined => {
+ if (seen.has(root)) return;
+ seen.add(root);
+
+ // Note: We don't use root.anchor for the anchor, because those are built on a per page basis.
+ // And classes/interfaces get their own page, so all the anchors will be empty anyways.
+ // Full name should be safe here, since this list only includes classes/interfaces.
+ return (
+
+ );
+};
diff --git a/src/Theme/Templates/index.ts b/src/Theme/Templates/index.ts
new file mode 100644
index 0000000..28b06a0
--- /dev/null
+++ b/src/Theme/Templates/index.ts
@@ -0,0 +1,28 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * This sub-module exposes the main templates of the theme.
+ * A template is an organization for the main elements of the
+ * page, that is, the structure of the main content, which varies
+ * depending on the content type.
+ *
+ * @module Theme/Templates
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+
+export * from './documentTemplate';
+export * from './hierarchyTemplate';
+export * from './indexTemplate';
+export * from './reflectionTemplate';
diff --git a/src/Theme/Templates/indexTemplate.tsx b/src/Theme/Templates/indexTemplate.tsx
new file mode 100755
index 0000000..a70e9d4
--- /dev/null
+++ b/src/Theme/Templates/indexTemplate.tsx
@@ -0,0 +1,34 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+
+/**
+ * @module Theme/Templates
+ * @author Alan Rodas Bonjour
+ */
+
+import type { DefaultThemeRenderContext, PageEvent, ProjectReflection } from 'typedoc';
+import { JSX } from 'typedoc';
+
+/**
+ * The component that defines how to render the main README file.
+ *
+ * @param context - The theme context.
+ * @param props - A page event with the project's reflection.
+ *
+ * @returns A JSX.Element to render the README file.
+ */
+export const indexTemplate = (context: DefaultThemeRenderContext, props: PageEvent): JSX.Element => (
+
+
+
+);
diff --git a/src/templates/reflection.tsx b/src/Theme/Templates/reflectionTemplate.tsx
similarity index 72%
rename from src/templates/reflection.tsx
rename to src/Theme/Templates/reflectionTemplate.tsx
index 375e04f..c9fc0f5 100755
--- a/src/templates/reflection.tsx
+++ b/src/Theme/Templates/reflectionTemplate.tsx
@@ -10,22 +10,41 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * @module Theme/Templates
+ * @author Alan Rodas Bonjour
+ */
+
import {
ContainerReflection,
+ DeclarationReflection,
DefaultThemeRenderContext,
+ JSX,
PageEvent,
- DeclarationReflection,
ReflectionKind,
ReflectionType,
- SignatureReflection,
- JSX
+ SignatureReflection
} from 'typedoc';
-import { classNames, getKindClass, hasTypeParameters } from '../partials/lib';
+import { classNames, getKindClass, hasTypeParameters } from '../../Utils/lib';
-export function reflectionTemplate(context: DefaultThemeRenderContext, props: PageEvent) {
+/**
+ * The component that defines how to render any reflection element.
+ * Any type of element to display, such as a module, class, function or other
+ * uses this template as the main structure.
+ *
+ * @param context - The theme context.
+ * @param props - A page event with the container's reflection.
+ *
+ * @returns A JSX.Element to render the reflection element.
+ */
+export const reflectionTemplate = (
+ context: DefaultThemeRenderContext,
+ props: PageEvent
+): JSX.Element => {
if (
- props.model.kindOf(ReflectionKind.TypeAlias | ReflectionKind.Variable) &&
+ props.model.kindOf(ReflectionKind.TypeAlias || ReflectionKind.Variable) &&
props.model instanceof DeclarationReflection
) {
return context.memberDeclaration(props.model);
@@ -92,24 +111,22 @@ export function reflectionTemplate(context: DefaultThemeRenderContext, props: Pa
{context.members(props.model)}
>
);
-}
+};
-function renderIndexSignature(context: DefaultThemeRenderContext, index: SignatureReflection) {
- return (
-
+);
diff --git a/src/Theme/index.ts b/src/Theme/index.ts
new file mode 100644
index 0000000..b31cfaf
--- /dev/null
+++ b/src/Theme/index.ts
@@ -0,0 +1,25 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+
+/**
+ * The Theme module comprises the main elements that make up the theme,
+ * including the `Theme` class and the `ThemeContext` class, as well
+ * as all submodules that comprise the styles and behavior of the theme.
+ *
+ * @module Theme
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+export * from './GobstonesTheme';
+export * from './GobstonesThemeContext';
diff --git a/src/Utils/Options.ts b/src/Utils/Options.ts
new file mode 100644
index 0000000..f824d80
--- /dev/null
+++ b/src/Utils/Options.ts
@@ -0,0 +1,77 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * @module Utils
+ * @author Alan Rodas Bonjour
+ */
+
+import { Application } from 'typedoc';
+
+/**
+ * Hook a set of options to the application, both at the moment
+ * and just after the bootstrapping of the application has been performed.
+ *
+ * @param typedocApp - The instance of the running TypeDoc application
+ * @param optionValues - The options to set in the application.
+ */
+export const hookThemeDefaultOptions = (typedocApp: Application, optionValues: Record): void => {
+ // Do a first setup right now with the properties that can be set
+ setThemeDefaultOptions(typedocApp, optionValues);
+ // Then hook to the bootstrap end
+ typedocApp.on(Application.EVENT_BOOTSTRAP_END, () => {
+ setThemeDefaultOptions(typedocApp, optionValues);
+ });
+};
+
+/**
+ * Set the given options that are not defined already into the application.
+ *
+ * @param typedocApp - The instance of the running TypeDoc application
+ * @param optionValues - The options to set in the application.
+ *
+ * @internal
+ */
+const setThemeDefaultOptions = (typedocApp: Application, optionValues: Record): void => {
+ for (const optionName of Object.keys(optionValues)) {
+ setOptionIfNotDefined(typedocApp, optionName, optionValues[optionName]);
+ }
+};
+
+/**
+ * Set a given option with the given value on the application if not previously defined.
+ *
+ * @param typedocApp - The instance of the running TypeDoc application
+ * @param option - The option name to set.
+ * @param value - The value to set the option to.
+ *
+ * @internal
+ */
+const setOptionIfNotDefined = (typedocApp: Application, option: string, value: unknown): void => {
+ let isDefined: boolean = false;
+ let isSet: boolean = false;
+ try {
+ // Note that we can not set all options defined, always, as some options
+ // only become available after some plugins have defined them.
+ // The isSet function throws if the option is not defined, thus, the
+ // try catch is required to verify if the option was or not defined
+ // before setting it.
+ isSet = typedocApp.options.isSet(option);
+ isDefined = true;
+ } catch {
+ isDefined = false;
+ }
+
+ if (isDefined && !isSet) {
+ typedocApp.options.setValue(option, value);
+ }
+};
diff --git a/src/Utils/Plugins.ts b/src/Utils/Plugins.ts
new file mode 100644
index 0000000..59b315e
--- /dev/null
+++ b/src/Utils/Plugins.ts
@@ -0,0 +1,58 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * @module Utils
+ * @author Alan Rodas Bonjour
+ */
+
+import { Application } from 'typedoc';
+
+/**
+ * A class that wraps the idea of a `Plugin` for TypeDoc.
+ *
+ * @remarks
+ * Similarly to themes, this class is structured so that
+ * subclasses can access the main TypeDoc app through
+ * the `this.application` property.
+ *
+ * Subclasses are expected to overwrite this class and to
+ * define an `initialize` method, which is just a fancy name
+ * for the `load` function that is exported by regular plugins.
+ */
+export abstract class TypedocPlugin {
+ /**
+ * Create a new instance of this plugin.
+ *
+ * @param application - The instance of the running TypeDoc application
+ */
+ public constructor(public application: Application) {}
+
+ /**
+ * Initialize the plugin, loading all required configuration for it.
+ *
+ * @remarks
+ * This function is called when the plugin is loaded, after instantiation
+ * by the {@link loadPlugin} function.
+ */
+ public abstract initialize(): void;
+}
+
+/**
+ * Load a plugin into the application.
+ *
+ * @param typedocApp - The instance of the running TypeDoc application
+ * @param plugin - The class of the plugin to load.
+ */
+export const loadPlugin = (typedocApp: Application, plugin: new (app: Application) => TypedocPlugin): void => {
+ new plugin(typedocApp).initialize();
+};
diff --git a/src/Utils/index.ts b/src/Utils/index.ts
new file mode 100644
index 0000000..73a005f
--- /dev/null
+++ b/src/Utils/index.ts
@@ -0,0 +1,28 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+/**
+ * This module contains utility functions and elements used through the theme.
+ *
+ * It include's some helpers to load plugins and options, as well as a
+ * copy from the lib file used in default typedoc theme, that is
+ * not exposed with the library, with some minor changes.
+ *
+ * @module Utils
+ * @author Alan Rodas Bonjour
+ *
+ * @internal
+ */
+
+export * from './lib';
+export * from './Options';
+export * from './Plugins';
diff --git a/src/partials/lib.tsx b/src/Utils/lib.tsx
similarity index 78%
rename from src/partials/lib.tsx
rename to src/Utils/lib.tsx
index e1c570c..e3cc124 100755
--- a/src/partials/lib.tsx
+++ b/src/Utils/lib.tsx
@@ -10,32 +10,33 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
/**
- * This module contains utility functions used through the theme.
- * It's a copy from the lib file used in default typedoc theme, that is
- * not exposed with the library.
+ * @module Utils/lib
+ * @author Alan Rodas Bonjour
*/
+
import {
- DefaultThemeRenderContext,
DeclarationReflection,
+ DefaultThemeRenderContext,
+ JSX,
ProjectReflection,
ReferenceReflection,
Reflection,
ReflectionKind,
SignatureReflection,
- TypeParameterReflection,
- JSX
+ TypeParameterReflection
} from 'typedoc';
/**
* Turn any element into it's string form.
*/
-export function stringify(data: unknown) {
+export const stringify = (data: unknown): string => {
if (typeof data === 'bigint') {
return data.toString() + 'n';
}
return JSON.stringify(data);
-}
+};
/**
* Get the full package name.
@@ -43,25 +44,24 @@ export function stringify(data: unknown) {
* @param refl
* @returns
*/
-export function getDisplayName(refl: Reflection): string {
+export const getDisplayName = (refl: Reflection): string => {
let version = '';
if ((refl instanceof DeclarationReflection || refl instanceof ProjectReflection) && refl.packageVersion) {
version = ` - v${refl.packageVersion}`;
}
return `${refl.name}${version}`;
-}
+};
-export function toStyleClass(str: string): string {
- return str.replace(/(\w)([A-Z])/g, (_m, m1: string, m2: string) => m1 + '-' + m2).toLowerCase();
-}
+export const toStyleClass = (str: string): string =>
+ str.replace(/(\w)([A-Z])/g, (_m, m1: string, m2: string) => m1 + '-' + m2).toLowerCase();
-export function getKindClass(refl: Reflection): string {
+export const getKindClass = (refl: Reflection): string => {
if (refl instanceof ReferenceReflection) {
return getKindClass(refl.getTargetReflectionDeep());
}
return ReflectionKind.classString(refl.kind);
-}
+};
/**
* Insert word break tags ```` into the given string.
@@ -71,7 +71,7 @@ export function getKindClass(refl: Reflection): string {
* @param str The string that should be split.
* @return The original string containing ```` tags where possible.
*/
-export function wbr(str: string): (string | JSX.Element)[] {
+export const wbr = (str: string): (string | JSX.Element)[] => {
// TODO surely there is a better way to do this, but I'm tired.
const ret: (string | JSX.Element)[] = [];
const re = /[\s\S]*?(?:[^_-][_-](?=[^_-])|[^A-Z](?=[A-Z][^A-Z]))/g;
@@ -84,9 +84,9 @@ export function wbr(str: string): (string | JSX.Element)[] {
ret.push(str.slice(i));
return ret;
-}
+};
-export function join(joiner: JSX.Children, list: readonly T[], cb: (x: T) => JSX.Children) {
+export const join = (joiner: JSX.Children, list: readonly T[], cb: (x: T) => JSX.Children): JSX.Element => {
const result: JSX.Children = [];
for (const item of list) {
@@ -97,9 +97,12 @@ export function join(joiner: JSX.Children, list: readonly T[], cb: (x: T) =>
}
return <>{result}>;
-}
+};
-export function classNames(names: Record, extraCss?: string) {
+export const classNames = (
+ names: Record,
+ extraCss?: string
+): string | undefined => {
const css = Object.keys(names)
.filter((key) => names[key])
.concat(extraCss || '')
@@ -107,24 +110,21 @@ export function classNames(names: Record, ex
.trim()
.replace(/\s+/g, ' ');
return css.length ? css : undefined;
-}
+};
-export function hasTypeParameters(
+export const hasTypeParameters = (
reflection: Reflection
-): reflection is Reflection & { typeParameters: TypeParameterReflection[] } {
- return (
- (reflection instanceof DeclarationReflection || reflection instanceof SignatureReflection) &&
- reflection.typeParameters !== undefined &&
- // eslint-disable-next-line no-null/no-null
- reflection.typeParameters !== null &&
- reflection.typeParameters.length > 0
- );
-}
-
-export function renderTypeParametersSignature(
+): reflection is Reflection & { typeParameters: TypeParameterReflection[] } =>
+ (reflection instanceof DeclarationReflection || reflection instanceof SignatureReflection) &&
+ reflection.typeParameters !== undefined &&
+ // eslint-disable-next-line no-null/no-null
+ reflection.typeParameters !== null &&
+ reflection.typeParameters.length > 0;
+
+export const renderTypeParametersSignature = (
context: DefaultThemeRenderContext,
typeParameters: readonly TypeParameterReflection[] | undefined
-): JSX.Element {
+): JSX.Element => {
if (!typeParameters || typeParameters.length === 0) return <>>;
const hideParamTypes = context.options.getValue('hideParameterTypesInTitle');
@@ -165,20 +165,20 @@ export function renderTypeParametersSignature(
{'>'}
>
);
-}
+};
/**
* Renders the reflection name with an additional `?` if optional.
*/
-export function renderName(refl: Reflection) {
+export const renderName = (refl: Reflection): JSX.Element | (string | JSX.Element)[] => {
if (refl.flags.isOptional) {
return <>{wbr(refl.name)}?>;
}
return wbr(refl.name);
-}
+};
-export function getHierarchyRoots(project: ProjectReflection): DeclarationReflection[] {
+export const getHierarchyRoots = (project: ProjectReflection): DeclarationReflection[] => {
const allClasses = project.getReflectionsByKind(ReflectionKind.ClassOrInterface) as DeclarationReflection[];
const roots = allClasses.filter((refl) => {
@@ -199,12 +199,10 @@ export function getHierarchyRoots(project: ProjectReflection): DeclarationReflec
return types.every(
(type) =>
!type.visit({
- reference(ref) {
- return ref.reflection !== undefined;
- }
+ reference: (ref) => ref.reflection !== undefined
})
);
});
return roots.sort((a, b) => a.name.localeCompare(b.name));
-}
+};
diff --git a/src/defaults.tsx b/src/defaults.tsx
new file mode 100755
index 0000000..53f5e0d
--- /dev/null
+++ b/src/defaults.tsx
@@ -0,0 +1,47 @@
+/*
+ * *****************************************************************************
+ * Copyright (C) National University of Quilmes 2018-2024
+ * Gobstones (TM) is a trademark of the National University of Quilmes.
+ *
+ * This program is free software distributed under the terms of the
+ * GNU Affero General Public License version 3.
+ * Additional terms added in compliance to section 7 of such license apply.
+ *
+ * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
+ * *****************************************************************************
+ */
+
+/**
+ * @module Main
+ * @author Alan Rodas Bonjour
+ */
+
+import { Application } from 'typedoc';
+
+/**
+ * Return the theme's default configuration to be set, if no configuration
+ * that overwrites it is provided by the user.
+ *
+ * @param typedocApp - The instance of the running TypeDoc application
+ *
+ * @returns A TypeDoc partial configuration.
+ */
+export const getDefaults = (typedocApp: Application): Record => ({
+ includeVersion: true,
+ categorizeByGroup: true,
+ excludeExternals: true,
+ excludeInternal: false,
+ excludePrivate: false,
+ hideGenerator: true,
+ disableSources: false,
+ githubPages: true,
+ excludeTags: ['@override', '@virtual', '@satisfies', '@overload'],
+ visibilityFilters: {
+ '@internal': false,
+ protected: false,
+ private: false,
+ inherited: false
+ },
+ mergeModulesMergeMode: 'module-category',
+ modifierTags: ['@mergeTarget', ...typedocApp.options.getValue('modifierTags')]
+});
diff --git a/src/index.tsx b/src/index.tsx
index 8f0ec82..741b664 100755
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -10,24 +10,50 @@
* You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
* *****************************************************************************
*/
+
+/**
+ * The main module of the theme.
+ *
+ * @remarks
+ * To define a theme in TypeDoc, the main module need's to export only
+ * a `load` function. This is the module that exports such function.
+ *
+ * Additionally, this module provides the default options used by the theme.
+ * Note that not all the configuration can be provided by the theme, and
+ * some minimal configuration should be provided through the typedoc
+ * configuration file.
+ *
+ * @module Main
+ * @author Alan Rodas Bonjour
+ */
import { Application } from 'typedoc';
-import { GobstonesTheme } from './GobstonesTheme';
-import { loadPlugin } from './plugins';
-import { MdnLinksPlugin } from './plugins/MdnLinksPlugin';
-import { MergeModulePlugin } from './plugins/MergeModulePlugin';
-import { NotExportedPlugin } from './plugins/NotExportedPlugin';
-import { RemoveReferencesPlugin } from './plugins/RemoveReferencesPlugin';
+import { getDefaults } from './defaults';
+import { MdnLinksPlugin, MergeModulePlugin, NotExportedPlugin, RemoveReferencesPlugin } from './Plugins';
+import { GobstonesTheme } from './Theme/GobstonesTheme';
+import * as Options from './Utils/Options';
+import * as Plugins from './Utils/Plugins';
/**
- * Called by TypeDoc when loading this theme as a plugin
+ * The **load** function is called by TypeDoc when loading the theme
+ * (as a plugin). This function performs all side-loads
+ * and uses the received `app` to define a new theme,
+ * with a given name and associated with a particular theme class.
+ *
+ * @param typedocApp - The instance of the running TypeDoc application
*/
-export function load(app: Application) {
+export const load = (typedocApp: Application): void => {
+ // Hook the default options so they are loaded
+ // if no option was overwritten by the user configuration
+ // This needs to come first than any other action.
+ Options.hookThemeDefaultOptions(typedocApp, getDefaults(typedocApp));
+
// Included plugins
- loadPlugin(app, NotExportedPlugin);
- loadPlugin(app, MergeModulePlugin);
- loadPlugin(app, RemoveReferencesPlugin);
- loadPlugin(app, MdnLinksPlugin);
- // Main theme
- app.renderer.defineTheme('gobstones', GobstonesTheme);
-}
+ Plugins.loadPlugin(typedocApp, NotExportedPlugin);
+ Plugins.loadPlugin(typedocApp, MergeModulePlugin);
+ Plugins.loadPlugin(typedocApp, RemoveReferencesPlugin);
+ Plugins.loadPlugin(typedocApp, MdnLinksPlugin);
+
+ // Include theme
+ typedocApp.renderer.defineTheme('gobstones', GobstonesTheme);
+};
diff --git a/src/partials/navigation/sidebar/navigation.tsx b/src/partials/navigation/sidebar/navigation.tsx
deleted file mode 100644
index 4c658a4..0000000
--- a/src/partials/navigation/sidebar/navigation.tsx
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * *****************************************************************************
- * Copyright (C) National University of Quilmes 2018-2024
- * Gobstones (TM) is a trademark of the National University of Quilmes.
- *
- * This program is free software distributed under the terms of the
- * GNU Affero General Public License version 3.
- * Additional terms added in compliance to section 7 of such license apply.
- *
- * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
- * *****************************************************************************
- */
-import { Reflection, JSX, ReflectionKind, PageEvent, DefaultThemeRenderContext } from 'typedoc';
-
-import { classNames } from '../../lib';
-
-export const navigation = function navigation(context: DefaultThemeRenderContext, props: PageEvent) {
- return (
-
- );
-};
diff --git a/src/partials/types/typeParameters.tsx b/src/partials/types/typeParameters.tsx
deleted file mode 100755
index 15947a0..0000000
--- a/src/partials/types/typeParameters.tsx
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * *****************************************************************************
- * Copyright (C) National University of Quilmes 2018-2024
- * Gobstones (TM) is a trademark of the National University of Quilmes.
- *
- * This program is free software distributed under the terms of the
- * GNU Affero General Public License version 3.
- * Additional terms added in compliance to section 7 of such license apply.
- *
- * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
- * *****************************************************************************
- */
-import type { DefaultThemeRenderContext, TypeParameterReflection } from 'typedoc';
-import { JSX } from 'typedoc';
-
-export function typeParameters(context: DefaultThemeRenderContext, typeParameters: TypeParameterReflection[]) {
- return (
- <>
-
-
-
- >
- );
-}
diff --git a/src/static/assets/css/typedoc-theme-gobstones.css b/src/static/assets/css/typedoc-theme-gobstones.css
index eed5ca1..b2c5d79 100755
--- a/src/static/assets/css/typedoc-theme-gobstones.css
+++ b/src/static/assets/css/typedoc-theme-gobstones.css
@@ -45,6 +45,16 @@ html {
align-self: center;
margin-right: 0.5rem;
}
+:root[data-theme='dark'] .tsd-icon-inverted {
+ -webkit-filter: invert(.75); /* safari 6.0 - 9.0 */
+ filter: invert(.75);
+}
+@media(prefers-color-scheme: dark) {
+ :root[data-theme='os'] .tsd-icon-inverted {
+ -webkit-filter: invert(.75); /* safari 6.0 - 9.0 */
+ filter: invert(.75);
+ }
+}
/* Improve headings */
.tsd-page-header .tsd-breadcrumb {
diff --git a/src/static/assets/js/typedoc-theme-gobstones.js b/src/static/assets/js/typedoc-theme-gobstones.js
index f06b954..3b3f0ed 100644
--- a/src/static/assets/js/typedoc-theme-gobstones.js
+++ b/src/static/assets/js/typedoc-theme-gobstones.js
@@ -1,5 +1,6 @@
+/** @module @ignore */
/* eslint-disable no-undef */
-document.addEventListener('DOMContentLoaded', function () {
+document.addEventListener('DOMContentLoaded', () => {
const privateRemarks = document.getElementById('Private Remarks');
if (!privateRemarks) return;
const privateRemarksTitle = privateRemarks.parentElement;
diff --git a/src/templates/hierarchy.tsx b/src/templates/hierarchy.tsx
deleted file mode 100755
index 31e8199..0000000
--- a/src/templates/hierarchy.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * *****************************************************************************
- * Copyright (C) National University of Quilmes 2018-2024
- * Gobstones (TM) is a trademark of the National University of Quilmes.
- *
- * This program is free software distributed under the terms of the
- * GNU Affero General Public License version 3.
- * Additional terms added in compliance to section 7 of such license apply.
- *
- * You may read the full license at https://gobstones.github.io/gobstones-guidelines/LICENSE.
- * *****************************************************************************
- */
-import { JSX } from 'typedoc';
-import type { DefaultThemeRenderContext, PageEvent, DeclarationReflection, ProjectReflection } from 'typedoc';
-
-import { getHierarchyRoots } from '../partials/lib';
-
-function fullHierarchy(
- context: DefaultThemeRenderContext,
- root: DeclarationReflection,
- seen = new Set()
-) {
- if (seen.has(root)) return;
- seen.add(root);
-
- // Note: We don't use root.anchor for the anchor, because those are built on a per page basis.
- // And classes/interfaces get their own page, so all the anchors will be empty anyways.
- // Full name should be safe here, since this list only includes classes/interfaces.
- return (
-