Skip to content

Commit 5c4e136

Browse files
committed
chore: Better typedoc generation
1 parent a44c919 commit 5c4e136

34 files changed

+1443
-1272
lines changed

.vscode/tasks.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
"label": "Build Millennium SDK",
2323
"detail": "build the Millennium software developement kit",
2424
"dependsOn": ["Install Node Modules"]
25+
},
26+
{
27+
"type": "npm",
28+
"script": "docs",
29+
"group": "build",
30+
"problemMatcher": [],
31+
"label": "Build Millennium SDK Docs",
32+
"detail": "build the Millennium software developement kit documentation"
2533
}
2634
]
2735
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"husky": "^9.1.7",
1515
"lerna": "^8.2.2",
1616
"typedoc": "^0.28.5",
17-
"typedoc-plugin-markdown": "^4.6.4"
17+
"typedoc-plugin-markdown": "^4.6.4",
18+
"typedoc-plugin-frontmatter": "^1.3.0"
1819
},
1920
"pnpm": {
2021
"peerDependencyRules": {

pnpm-lock.yaml

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

python-packages/core-utils/MillenniumUtils/__init__.py

Lines changed: 43 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json, os
33
import Millennium # type: ignore[import]
44
import builtins
5+
import enum
56

67
config_path = os.path.join(os.getenv("MILLENNIUM__CONFIG_PATH"), "plugins.json")
78

@@ -124,6 +125,9 @@ def __init__(cls, name, bases, class_dict):
124125
else:
125126
raise Exception("Millennium only allows one instance of plugin settings.")
126127

128+
def __get_raw__(self, name):
129+
return super().__getattribute__(name)
130+
127131
def __getattribute__(self, name, *args, **kwargs):
128132
attributeValue = super().__getattribute__(name)
129133
returnValue = None
@@ -155,13 +159,28 @@ def __setattr__(self, targetKey, newValue):
155159
return super().__setattr__(targetKey, newValue)
156160

157161

162+
class CallbackLocation(enum.Enum):
163+
LOCAL = "local"
164+
EXTERNAL = "external"
165+
166+
class OnAfterChangeCallback:
167+
def __init__(self, func):
168+
self.func = func
169+
170+
def __call__(self, *args, **kwargs):
171+
print("Before the function call")
172+
result = self.func(*args, **kwargs)
173+
print("After the function call")
174+
return result
175+
158176
class DefineSetting:
159-
def __init__(self, name, description, style, default, step=None, range=None):
177+
def __init__(self, name, style, default, description=None, configurable=None, step=None, range=None):
160178
self.name = name
161-
self.desc = description
179+
self.desc = description or "No description yet."
162180
self.type = type(style)
163181
self.instance = style
164182
self.default = default
183+
self.configurable = configurable or True
165184

166185
def _get_info(self):
167186
return (self.name, self.desc, self.type, self.range)
@@ -196,16 +215,32 @@ def hookedFunction(_, *args, **kwargs):
196215
"type": self.type,
197216
"default": self.default,
198217
"instance": self.instance,
218+
"configurable": self.configurable,
199219
}
200220

201221
return hookedFunction
202222

203223

224+
225+
204226
def UpdateSettingsValue(name, value):
227+
previousValue = getattr(__builtins__["__millennium_plugin_settings_do_not_use__"], name)()
228+
229+
def InvokeOnCallback():
230+
pluginSettings = __builtins__["__millennium_plugin_settings_do_not_use__"]
231+
232+
for func_name in dir(pluginSettings):
233+
func = getattr(pluginSettings, func_name)
234+
235+
if func.__class__ == OnAfterChangeCallback:
236+
func(pluginSettings, name, value, previousValue, CallbackLocation.LOCAL)
237+
205238
settingsStore = GetPluginSettingsStore()
206239
settingsStore[name] = value
207240
SetPluginSettingsStore(settingsStore)
208241

242+
InvokeOnCallback()
243+
209244
builtins.__update_settings_value__ = UpdateSettingsValue
210245

211246
def ParsePluginSettings():
@@ -221,11 +256,13 @@ def ParsePluginSettings():
221256
"name": attribute._metadata["name"],
222257
"desc": attribute._metadata["desc"],
223258
"value": attribute(),
224-
"functionName": attributeName
259+
"functionName": attributeName,
260+
"configurable": attribute._metadata["configurable"],
225261
}
226-
if isinstance(attribute._metadata["type"], tuple) and issubclass(attribute._metadata["type"][0], DropDown):
227-
setting["options"] = attribute._metadata["type"][1]
228-
setting["type"] = attribute._metadata["type"][0].__name__
262+
263+
if issubclass(attribute._metadata["type"], DropDown):
264+
setting["options"] = attribute._metadata["instance"].items
265+
setting["type"] = attribute._metadata["type"].__name__
229266

230267
elif issubclass(attribute._metadata["type"], (NumberTextInput, FloatTextInput)):
231268
setting["range"] = attribute._metadata["instance"].range

typedoc.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"entryPoints": ["typescript-packages/client/src/index.ts", "typescript-packages/browser/src/index.ts"],
33
"out": "docs",
4-
"plugin": ["typedoc-plugin-markdown"],
4+
"plugin": ["typedoc-plugin-markdown", "typedoc-plugin-frontmatter"],
55
"readme": "README.md",
66
"includeVersion": true,
77
"tsconfig": "tsconfig.base.json",
88
"expandObjects": true,
99
"enumMembersFormat": "table",
1010
"useCodeBlocks": true,
11-
"expandParameters": false
11+
"expandParameters": false,
12+
"frontmatterCommentTags": ["component"]
1213
}

typescript-packages/client/src/components/Button.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import { DialogButton, DialogButtonProps } from './Dialog';
44

55
export interface ButtonProps extends DialogButtonProps {}
66

7-
// Button isn't exported, so call DialogButton to grab it
7+
/** @component React Components */
88
export const Button = (DialogButton as any)?.render({}).type as FC<ButtonProps>;

typescript-packages/client/src/components/ButtonItem.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { ItemProps } from './Item';
55
import { createPropListRegex } from '../utils';
66

77
export interface ButtonItemProps extends ItemProps {
8-
onClick?(e: MouseEvent): void;
9-
disabled?: boolean;
8+
onClick?(e: MouseEvent): void;
9+
disabled?: boolean;
1010
}
11-
const buttonItemRegex = createPropListRegex(["highlightOnFocus", "childrenContainerWidth"], false);
11+
const buttonItemRegex = createPropListRegex(['highlightOnFocus', 'childrenContainerWidth'], false);
12+
/** @component React Components */
1213
export const ButtonItem = Object.values(CommonUIModule).find(
13-
(mod: any) =>
14-
(mod?.render?.toString && buttonItemRegex.test(mod.render.toString())) ||
15-
mod?.render?.toString?.().includes('childrenContainerWidth:"min"'),
14+
(mod: any) => (mod?.render?.toString && buttonItemRegex.test(mod.render.toString())) || mod?.render?.toString?.().includes('childrenContainerWidth:"min"'),
1615
) as FC<ButtonItemProps>;

typescript-packages/client/src/components/Carousel.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@ import { HTMLAttributes, ReactNode, RefAttributes, FC } from 'react';
33
import { Export, findModuleExport } from '../webpack';
44

55
export interface CarouselProps extends HTMLAttributes<HTMLDivElement> {
6-
autoFocus?: boolean;
7-
enableBumperPaging?: boolean;
8-
fnDoesItemTakeFocus?: (...unknown: any[]) => boolean;
9-
fnGetColumnWidth?: (...unknown: any[]) => number;
10-
fnGetId?: (id: number) => number;
11-
fnItemRenderer?: (id: number, ...unknown: any[]) => ReactNode;
12-
fnUpdateArrows?: (...unknown: any[]) => any;
13-
initialColumn?: number;
14-
nHeight?: number;
15-
nIndexLeftmost?: number;
16-
nItemHeight?: number;
17-
nItemMarginX?: number;
18-
nNumItems?: number;
19-
name?: string;
20-
scrollToAlignment?: 'center';
6+
autoFocus?: boolean;
7+
enableBumperPaging?: boolean;
8+
fnDoesItemTakeFocus?: (...unknown: any[]) => boolean;
9+
fnGetColumnWidth?: (...unknown: any[]) => number;
10+
fnGetId?: (id: number) => number;
11+
fnItemRenderer?: (id: number, ...unknown: any[]) => ReactNode;
12+
fnUpdateArrows?: (...unknown: any[]) => any;
13+
initialColumn?: number;
14+
nHeight?: number;
15+
nIndexLeftmost?: number;
16+
nItemHeight?: number;
17+
nItemMarginX?: number;
18+
nNumItems?: number;
19+
name?: string;
20+
scrollToAlignment?: 'center';
2121
}
22-
23-
export const Carousel = findModuleExport((e: Export) => e.render?.toString().includes('setFocusedColumn:')) as FC<
24-
CarouselProps & RefAttributes<HTMLDivElement>
25-
>;
22+
/** @component React Components */
23+
export const Carousel = findModuleExport((e: Export) => e.render?.toString().includes('setFocusedColumn:')) as FC<CarouselProps & RefAttributes<HTMLDivElement>>;

typescript-packages/client/src/components/ControlsList.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ import { FC, ReactNode } from 'react';
33
import { Export, findModuleExport } from '../webpack';
44

55
export interface ControlsListProps {
6-
alignItems?: 'left' | 'right' | 'center';
7-
spacing?: 'standard' | 'extra';
8-
children?: ReactNode;
6+
alignItems?: 'left' | 'right' | 'center';
7+
spacing?: 'standard' | 'extra';
8+
children?: ReactNode;
99
}
10-
10+
/** @component React Components */
1111
export const ControlsList: FC<ControlsListProps> = findModuleExport(
12-
(e: Export) =>
13-
e?.toString && e.toString().includes('().ControlsListChild') && e.toString().includes('().ControlsListOuterPanel'),
12+
(e: Export) => e?.toString && e.toString().includes('().ControlsListChild') && e.toString().includes('().ControlsListOuterPanel'),
1413
);

typescript-packages/client/src/components/Dialog.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,32 @@ const MappedDialogDivs = new Map(
6565
}),
6666
);
6767

68+
/** @component React Components */
6869
export const DialogHeader = MappedDialogDivs.get('DialogHeader') as FC<DialogCommonProps>;
70+
/** @component React Components */
6971
export const DialogSubHeader = MappedDialogDivs.get('DialogSubHeader') as FC<DialogCommonProps>;
72+
/** @component React Components */
7073
export const DialogFooter = MappedDialogDivs.get('DialogFooter') as FC<DialogCommonProps>;
74+
/** @component React Components */
7175
export const DialogLabel = MappedDialogDivs.get('DialogLabel') as FC<DialogCommonProps>;
76+
/** @component React Components */
7277
export const DialogBodyText = MappedDialogDivs.get('DialogBodyText') as FC<DialogCommonProps>;
78+
/** @component React Components */
7379
export const DialogBody = MappedDialogDivs.get('DialogBody') as FC<DialogCommonProps>;
80+
/** @component React Components */
7481
export const DialogControlsSection = MappedDialogDivs.get('DialogControlsSection') as FC<DialogCommonProps>;
82+
/** @component React Components */
7583
export const DialogControlsSectionHeader = MappedDialogDivs.get('DialogControlsSectionHeader') as FC<DialogCommonProps>;
7684

85+
/** @component React Components */
7786
export const DialogButtonPrimary = Object.values(CommonUIModule).find((mod: any) =>
7887
mod?.render?.toString()?.includes('"DialogButton","_DialogLayout","Primary"'),
7988
) as FC<DialogButtonProps>;
8089

90+
/** @component React Components */
8191
export const DialogButtonSecondary = Object.values(CommonUIModule).find((mod: any) =>
8292
mod?.render?.toString()?.includes('"DialogButton","_DialogLayout","Secondary"'),
8393
) as FC<DialogButtonProps>;
8494

85-
// This is the "main" button. The Primary can act as a submit button,
86-
// therefore secondary is chosen (also for backwards comp. reasons)
95+
/** @component React Components */
8796
export const DialogButton = DialogButtonSecondary;

typescript-packages/client/src/components/DialogCheckbox.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,29 @@ import { DialogCommonProps } from './Dialog';
55
import { FooterLegendProps } from './FooterLegend';
66

77
export interface DialogCheckboxProps extends DialogCommonProps, FooterLegendProps {
8-
onChange?(checked: boolean): void;
9-
label?: ReactNode;
10-
description?: ReactNode;
11-
disabled?: boolean;
12-
tooltip?: string;
13-
color?: string;
14-
highlightColor?: string;
15-
bottomSeparator?: 'standard' | 'thick' | 'none';
16-
controlled?: boolean;
17-
checked?: boolean;
18-
onClick?(evt: Event): void;
8+
onChange?(checked: boolean): void;
9+
label?: ReactNode;
10+
description?: ReactNode;
11+
disabled?: boolean;
12+
tooltip?: string;
13+
color?: string;
14+
highlightColor?: string;
15+
bottomSeparator?: 'standard' | 'thick' | 'none';
16+
controlled?: boolean;
17+
checked?: boolean;
18+
onClick?(evt: Event): void;
1919
}
2020

21+
/** @component React Components */
2122
export const DialogCheckbox = Object.values(
22-
findModule((m: any) => {
23-
if (typeof m !== 'object') return false;
24-
for (const prop in m) {
25-
if (m[prop]?.prototype?.GetPanelElementProps) return true;
26-
}
27-
return false;
28-
}),
23+
findModule((m: any) => {
24+
if (typeof m !== 'object') return false;
25+
for (const prop in m) {
26+
if (m[prop]?.prototype?.GetPanelElementProps) return true;
27+
}
28+
return false;
29+
}),
2930
).find(
30-
(m: any) =>
31-
m.contextType &&
32-
m.prototype?.render.toString().includes('fallback:') &&
33-
m?.prototype?.SetChecked &&
34-
m?.prototype?.Toggle &&
35-
m?.prototype?.GetPanelElementProps,
31+
(m: any) =>
32+
m.contextType && m.prototype?.render.toString().includes('fallback:') && m?.prototype?.SetChecked && m?.prototype?.Toggle && m?.prototype?.GetPanelElementProps,
3633
) as FC<DialogCheckboxProps>;

0 commit comments

Comments
 (0)