Skip to content

Commit 13f19ae

Browse files
committed
Fix documentation not being correctly generated for modules-lib
1 parent 3ea31c4 commit 13f19ae

File tree

14 files changed

+130
-122
lines changed

14 files changed

+130
-122
lines changed

lib/buildtools/src/build/__tests__/manifest.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ describe('Test bundle manifest schema validation', () => {
1010

1111
test('Valid Schema', async () => {
1212
mockedReadFile.mockResolvedValueOnce('{ "tabs": [] }');
13+
mockedReadFile.mockResolvedValueOnce('{ version: "1.0.0" }');
1314

1415
await expect(getBundleManifest('yes'))
1516
.resolves
1617
.toMatchObject({
17-
tabs: []
18+
tabs: [],
19+
version: '1.0.0'
1820
});
1921
});
2022

2123
test('Valid Schema with tabs without verification', async () => {
2224
mockedReadFile.mockResolvedValueOnce('{ "tabs": ["tab0", "tab1"] }');
25+
mockedReadFile.mockResolvedValueOnce('{ version: "1.0.0" }');
2326

2427
await expect(getBundleManifest('yes', false))
2528
.resolves
2629
.toMatchObject({
27-
tabs: ['tab0', 'tab1']
30+
tabs: ['tab0', 'tab1'],
31+
version: '1.0.0'
2832
});
2933
});
3034

3135
test('Valid schema with tabs and verification', async () => {
3236
mockedReadFile.mockResolvedValueOnce('{ "tabs": ["tab0"] }');
37+
mockedReadFile.mockResolvedValueOnce('{}');
3338

3439
await expect(getBundleManifest('yes', true))
3540
.resolves
@@ -40,13 +45,15 @@ describe('Test bundle manifest schema validation', () => {
4045

4146
test('Valid schema with invalid tab verification', async () => {
4247
mockedReadFile.mockResolvedValueOnce('{ "tabs": ["tab2"] }');
48+
mockedReadFile.mockResolvedValueOnce('{}');
4349

4450
await expect(getBundleManifest('yes', true))
4551
.rejects.toThrow();
4652
});
4753

4854
test('Schema with additional properties', async () => {
4955
mockedReadFile.mockResolvedValueOnce('{ "tabs": ["tab0", "tab1"], "unknown": true }');
56+
mockedReadFile.mockResolvedValueOnce('{}');
5057

5158
await expect(getBundleManifest('yes'))
5259
.rejects
@@ -55,6 +62,7 @@ describe('Test bundle manifest schema validation', () => {
5562

5663
test('Schema with invalid requires', async () => {
5764
mockedReadFile.mockResolvedValueOnce('{ "tabs": ["tab0", "tab1"], "requires": "yes" }');
65+
mockedReadFile.mockResolvedValueOnce('{}');
5866

5967
await expect(getBundleManifest('yes'))
6068
.rejects

lib/buildtools/src/build/manifest.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,22 @@ import manifestSchema from './modules/manifest.schema.json' with { type: 'json'
1111
/**
1212
* Checks that the given bundle manifest was correctly specified
1313
*/
14-
export async function getBundleManifest(manifestFile: string, tabCheck?: boolean): Promise<BundleManifest | undefined> {
14+
export async function getBundleManifest(directory: string, tabCheck?: boolean): Promise<BundleManifest | undefined> {
1515
let manifestStr: string;
1616

1717
try {
18-
manifestStr = await fs.readFile(manifestFile, 'utf-8');
18+
manifestStr = await fs.readFile(`${directory}/manifest.json`, 'utf-8');
19+
} catch (error) {
20+
if (isNodeError(error) && error.code === 'ENOENT') {
21+
return undefined;
22+
}
23+
throw error;
24+
}
25+
26+
let versionStr: string | undefined;
27+
try {
28+
const rawPackageJson = await fs.readFile(`${directory}/package.json`, 'utf-8')
29+
;({ version: versionStr } = JSON.parse(rawPackageJson));
1930
} catch (error) {
2031
if (isNodeError(error) && error.code === 'ENOENT') {
2132
return undefined;
@@ -26,9 +37,10 @@ export async function getBundleManifest(manifestFile: string, tabCheck?: boolean
2637
const rawManifest = JSON.parse(manifestStr) as BundleManifest;
2738
validate(rawManifest, manifestSchema, { throwError: true });
2839

29-
const manifest = {
40+
const manifest: BundleManifest = {
3041
...rawManifest,
3142
tabs: !rawManifest.tabs ? rawManifest.tabs : rawManifest.tabs.map(each => each.trim()),
43+
version: versionStr,
3244
};
3345

3446
// Make sure that all the tabs specified exist
@@ -62,7 +74,7 @@ export async function getBundleManifests(bundlesDir: string, tabCheck?: boolean)
6274
const fullPath = pathlib.join(bundlesDir, fileName);
6375
const stats = await fs.stat(fullPath);
6476
if (stats.isDirectory()) {
65-
const manifest = await getBundleManifest(`${fullPath}/manifest.json`, tabCheck);
77+
const manifest = await getBundleManifest(fullPath, tabCheck);
6678
if (manifest === undefined) return undefined;
6779
return [fileName, manifest] as [string, BundleManifest];
6880
}
@@ -88,7 +100,7 @@ export async function resolveSingleBundle(bundleDir: string): Promise<ResolvedBu
88100
const stats = await fs.stat(fullyResolved);
89101
if (!stats.isDirectory()) return undefined;
90102

91-
const manifest = await getBundleManifest(`${fullyResolved}/manifest.json`);
103+
const manifest = await getBundleManifest(fullyResolved);
92104
if (!manifest) return undefined;
93105

94106
try {

lib/modules-lib/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
"@types/react": "^18.3.1",
88
"@types/react-dom": "^18.3.1",
99
"eslint": "^9.29.0",
10+
"typedoc": "^0.28.4",
11+
"typedoc-plugin-markdown": "^4.7.0",
12+
"typedoc-plugin-rename-defaults": "^0.7.3",
1013
"typescript": "^5.8.2",
1114
"vitest": "^3.2.3"
1215
},

lib/modules-lib/src/tabs/AnimationCanvas.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import PlayButton from './PlayButton';
88
import WebGLCanvas from './WebglCanvas';
99
import { BP_TAB_BUTTON_MARGIN, BP_TEXT_MARGIN, CANVAS_MAX_WIDTH } from './css_constants';
1010

11-
type AnimCanvasProps = {
11+
export type AnimCanvasProps = {
1212
animation: glAnimation;
1313
};
1414

@@ -28,12 +28,7 @@ type AnimCanvasState = {
2828
errored?: any;
2929
};
3030

31-
/**
32-
* Canvas to display glAnimations.
33-
*
34-
* Uses WebGLCanvas internally.
35-
*/
36-
export default class AnimationCanvas extends React.Component<
31+
class AnimationCanvasInternal extends React.Component<
3732
AnimCanvasProps,
3833
AnimCanvasState
3934
> {
@@ -345,3 +340,12 @@ export default class AnimationCanvas extends React.Component<
345340
</div>;
346341
}
347342
}
343+
344+
/**
345+
* React Component for displaying {@link glAnimation|glAnimations}.
346+
*
347+
* Uses {@link WebGLCanvas} internally.
348+
*/
349+
export default function AnimationCanvas(props: AnimCanvasProps) {
350+
return <AnimationCanvasInternal {...props} />;
351+
}

lib/modules-lib/src/tabs/AutoLoopSwitch.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,17 @@ export type AutoLoopSwitchProps = Omit<SwitchProps, 'checked' | 'style'> & {
77
};
88

99
/* [Main] */
10-
export default class AutoLoopSwitch extends React.Component<AutoLoopSwitchProps> {
11-
render() {
12-
return <Switch
13-
style={{
10+
export default function AutoLoopSwitch(props: AutoLoopSwitchProps) {
11+
return <Switch
12+
style={{
1413
// Remove default bottom margin
15-
marginBottom: '0px',
14+
marginBottom: '0px',
1615

17-
// Prevent label from wrapping at every letter when width is small
18-
whiteSpace: 'nowrap'
19-
}}
20-
label="Auto Loop"
21-
checked={ this.props.isAutoLooping }
22-
{...this.props}
23-
/>;
24-
}
16+
// Prevent label from wrapping at every letter when width is small
17+
whiteSpace: 'nowrap'
18+
}}
19+
label="Auto Loop"
20+
checked={props.isAutoLooping}
21+
{...props}
22+
/>;
2523
}

lib/modules-lib/src/tabs/ButtonComponent.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,22 @@ const defaultOptions = {
99
minimal: true
1010
};
1111

12-
type Props = {
12+
export type ButtonComponentProps = {
1313
onClick?: MouseEventHandler<HTMLElement>,
1414
disabled?: boolean,
1515
children?: ReactNode,
1616
};
1717

18-
const ButtonComponent = (props: Props) => {
18+
/**
19+
* Button Component that retains interactability even when disabled. Refer to
20+
* {@link https://blueprintjs.com/docs/#core/components/buttons.anchorbutton|this} for more information
21+
*/
22+
export default function ButtonComponent(props: ButtonComponentProps) {
1923
const buttonProps = {
2024
...defaultOptions,
2125
...props
2226
};
2327
return props.disabled
24-
? (
25-
<AnchorButton {...buttonProps} />
26-
)
27-
: (
28-
<Button {...buttonProps} />
29-
);
28+
? <AnchorButton {...buttonProps} />
29+
: <Button {...buttonProps} />;
3030
};
31-
export default ButtonComponent;

lib/modules-lib/src/tabs/ModalDiv.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ const backdropStyle = {
3939
filter: 'blur(10px)'
4040
} as CSSProperties;
4141

42-
interface ModalProp {
42+
export interface ModalProps {
4343
open: boolean
4444
height: string
4545
width: string
4646
handleClose: MouseEventHandler
4747
children: ReactElement
4848
}
49-
const Modal = ({ open, height, width, children, handleClose }: ModalProp) => (
49+
const Modal = ({ open, height, width, children, handleClose }: ModalProps) => (
5050
<>
5151
{open && (
5252
<>

lib/modules-lib/src/tabs/MultItemDisplay.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@ import { IconNames } from '@blueprintjs/icons';
33
import { clamp } from 'lodash';
44
import React from 'react';
55

6-
type MultiItemDisplayProps = {
6+
export type MultiItemDisplayProps = {
77
elements: React.JSX.Element[]
88
};
99

10-
const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
10+
/**
11+
* React Component for displaying multiple items
12+
*/
13+
const MultiItemDisplay = (props: MultiItemDisplayProps) => {
1114
// The actual index of the currently selected element
1215
const [currentStep, setCurrentStep] = React.useState(0);
1316

@@ -16,7 +19,7 @@ const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
1619
const [stepEditorFocused, setStepEditorFocused] = React.useState(false);
1720

1821
const resetStepEditor = () => setStepEditorValue((currentStep + 1).toString());
19-
const elementsDigitCount = Math.floor(Math.log10(Math.max(1, elements.length))) + 1;
22+
const elementsDigitCount = Math.floor(Math.log10(Math.max(1, props.elements.length))) + 1;
2023

2124
return (
2225
<div
@@ -68,7 +71,7 @@ const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
6871
<div style={{ width: `${stepEditorFocused ? elementsDigitCount + 2 : elementsDigitCount}ch` }}>
6972
<EditableText
7073
value={stepEditorValue}
71-
disabled={elements.length === 1}
74+
disabled={props.elements.length === 1}
7275
placeholder={undefined}
7376
type="number"
7477
onChange={(newValue) => {
@@ -82,7 +85,7 @@ const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
8285
onConfirm={(value) => {
8386
if (value) {
8487
const newStep = parseInt(value);
85-
const clampedStep = clamp(newStep, 1, elements.length);
88+
const clampedStep = clamp(newStep, 1, props.elements.length);
8689
setCurrentStep(clampedStep - 1);
8790
setStepEditorFocused(false);
8891
setStepEditorValue(clampedStep.toString());
@@ -103,7 +106,7 @@ const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
103106
onEdit={() => setStepEditorFocused(true)}
104107
/>
105108
</div>
106-
{stepEditorFocused && <>&nbsp;</>}/{elements.length}
109+
{stepEditorFocused && <>&nbsp;</>}/{props.elements.length}
107110
</div>
108111
</h3>
109112
<Button
@@ -118,7 +121,7 @@ const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
118121
setCurrentStep(currentStep + 1);
119122
setStepEditorValue((currentStep + 2).toString());
120123
}}
121-
disabled={currentStep === elements.length - 1}
124+
disabled={currentStep === props.elements.length - 1}
122125
>
123126
Next
124127
</Button>
@@ -133,7 +136,7 @@ const MultiItemDisplay = ({ elements }: MultiItemDisplayProps) => {
133136
justifyContent: 'center'
134137
}}
135138
>
136-
{elements[currentStep]}
139+
{props.elements[currentStep]}
137140
</div>
138141
</div>
139142
);
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/* [Imports] */
22
import { Icon, type ButtonProps, Tooltip } from '@blueprintjs/core';
33
import { IconNames } from '@blueprintjs/icons';
4-
import React from 'react';
54
import ButtonComponent from './ButtonComponent';
65

76
/* [Exports] */
@@ -11,17 +10,15 @@ export type PlayButtonProps = ButtonProps & {
1110
};
1211

1312
/* [Main] */
14-
export default class PlayButton extends React.Component<PlayButtonProps> {
15-
render() {
16-
return <Tooltip
17-
content={ this.props.isPlaying ? 'Pause' : 'Play' }
18-
placement="top"
19-
>
20-
<ButtonComponent {...this.props} >
21-
<Icon
22-
icon={ this.props.isPlaying ? IconNames.PAUSE : IconNames.PLAY }
23-
/>
24-
</ButtonComponent>
25-
</Tooltip>;
26-
}
13+
export default function PlayButton(props: PlayButtonProps) {
14+
return <Tooltip
15+
content={props.isPlaying ? 'Pause' : 'Play'}
16+
placement="top"
17+
>
18+
<ButtonComponent {...props} >
19+
<Icon
20+
icon={props.isPlaying ? IconNames.PAUSE : IconNames.PLAY}
21+
/>
22+
</ButtonComponent>
23+
</Tooltip>;
2724
}

lib/modules-lib/src/tabs/testUtils.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)