8000 Add missing component comments. (#198) · pdg137/python-editor-next@4f35078 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4f35078

Browse files
Add missing component comments. (microbit-foundation#198)
Some re-org. Particularly, colocate AboutDialog with its assets.
1 parent 3d2384b commit 4f35078

23 files changed

+77
-170
lines changed

src/common/FileDropTarget.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ interface FileDropTargetProps extends BoxProps {
1313
onFileDrop: (files: File[]) => void;
1414
}
1515

16+
/**
17+
* An area that handles multiple dropped files.
18+
*/
1619
const FileDropTarget = ({
1720
children,
1821
onFileDrop,

src/common/ProgressDialog.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ interface ProgressDialogProps extends ProgressDialogParameters {
2424
isOpen: boolean;
2525
}
2626

27+
/**
28+
* A progress dialog used for the flashing process.
29+
*/
2730
const ProgressDialog = ({ header, progress }: ProgressDialogProps) => {
2831
return (
2932
<Modal isOpen={progress !== undefined} onClose={doNothing} isCentered>

src/common/Separate.tsx

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

src/common/SplitView/SplitView.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ interface SplitViewProps extends Omit<FlexProps, "children" | "direction"> {
2626
minimums: [number, number];
2727
}
2828

29+
/**
30+
* An adjustable vertical or horizontal split area.
31+
*
32+
* Expects SplitViewSized, SplitViewDivider and SplitViewRemainder
33+
* children. The sized and remainder components can be in either
34+
* order.
35+
*/
2936
export const SplitView = ({
3037
children,
3138
direction,

src/common/use-dialogs.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ export class Dialogs {
107107
}
108108
}
109109

110+
/**
111+
* A hook providing common dialog functionality.
112+
*/
110113
export const useDialogs = () => {
111114
const dialogs = useContext(DialogContext);
112115
if (!dialogs) {

src/common/use-raf-state.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import { Dispatch, SetStateAction, useCallback, useRef, useState } from "react";
77
import useIsUnmounted from "./use-is-unmounted";
88

9+
/**
10+
* State that rate limits changes with request animation frame.
11+
*/
912
const useRafState = <S>(
1013
initialState: S | (() => S)
1114
): [S, Dispatch<SetStateAction<S>>] => {

src/deployment/deployment.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,8 @@
33
*
44
* SPDX-License-Identifier: MIT
55
*/
6+
7+
/**
8+
* See craco.config.js.
9+
*/
610
declare module "@deployment";

src/deployment/misc.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: MIT
55
*/
66

7-
// Miscelaneous items that haven't been properly integrated into the branding.
7+
// Miscellaneous items that haven't been properly integrated into the branding.
88
export const codeFontFamily = "Source Code Pro, monospace";
99
export const backgroundColorTerm = "#333333";
1010
export const defaultCodeFontSizePt = 16;

src/device/device-hooks.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export const DeviceContext = React.createContext<
1414
undefined | MicrobitWebUSBConnection
1515
>(undefined);
1616

17+
/**
18+
* Hook to access the device from UI code.
19+
*
20+
* @returns The device.
21+
*/
1722
export const useDevice = () => {
1823
const device = useContext(DeviceContext);
1924
if (!device) {
@@ -22,6 +27,9 @@ export const useDevice = () => {
2227
return device;
2328
};
2429

30+
/**
31+
* State that tracks the device connections status.
32+
*/
2533
export const useConnectionStatus = () => {
2634
const device = useDevice();
2735
const [status, setStatus] = useState<ConnectionStatus>(device.status);

src/device/device.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,9 @@ export class MicrobitWebUSBConnection extends EventEmitter {
201201
this.logging.log(v);
202202
}
203203

204+
/**
205+
* Initializes the device.
206+
*/
204207
async initialize(): Promise<void> {
205208
if (navigator.usb) {
206209
navigator.usb.addEventListener("disconnect", this.handleDisconnect);
@@ -248,10 +251,22 @@ export class MicrobitWebUSBConnection extends EventEmitter {
248251
});
249252
}
250253

254+
/**
255+
* Flash the micro:bit.
256+
*
257+
* @param dataSource The data to use.
258+
* @param options Flash options and progress callback.
259+
*/
251260
async flash(
252261
dataSource: FlashDataSource,
253262
options: {
263+
/**
264+
* True to use a partial flash where possible, false to force a full flash.
265+
*/
254266
partial: boolean;
267+
/**
268+
* A progress callback. Called with undefined when the process is complete or has failed.
269+
*/
255270
progress: (percentage: number | undefined) => void;
256271
}
257272
): Promise<void> {
@@ -371,7 +386,7 @@ export class MicrobitWebUSBConnection extends EventEmitter {
371386
this.emit(EVENT_STATUS, this.status);
372387
}
373388

374-
async withEnrichedErrors<T>(f: () => Promise<T>): Promise<T> {
389+
private async withEnrichedErrors<T>(f: () => Promise<T>): Promise<T> {
375390
try {
376391
return await f();
377392
} catch (e) {
@@ -405,6 +420,14 @@ export class MicrobitWebUSBConnection extends EventEmitter {
405420
}
406421
}
407422

423+
/**
424+
* Write serial data to the device.
425+
*
426+
* Does nothting if there is no connection.
427+
*
428+
* @param data The data to write.
429+
* @returns A promise that resolves when the write is complete.
430+
*/
408431
serialWrite(data: string): Promise<void> {
409432
return this.withEnrichedErrors(async () => {
410433
if (this.connection) {

0 commit comments

Comments
 (0)
0