From 7841683d51d1fae3f1646dfebefbd60d39f02d1b Mon Sep 17 00:00:00 2001 From: Eddy Meals Date: Fri, 29 Nov 2024 12:50:32 -0800 Subject: [PATCH] Lint again --- src/renderer/editor/ApiLink.css | 8 +++ src/renderer/editor/ApiLink.tsx | 26 +++++++++ src/renderer/editor/HighlightedCode.tsx | 21 +++++-- src/renderer/editor/addEditorTooltips.tsx | 71 +++++++++++++---------- 4 files changed, 89 insertions(+), 37 deletions(-) create mode 100644 src/renderer/editor/ApiLink.css create mode 100644 src/renderer/editor/ApiLink.tsx diff --git a/src/renderer/editor/ApiLink.css b/src/renderer/editor/ApiLink.css new file mode 100644 index 0000000..8e63aaa --- /dev/null +++ b/src/renderer/editor/ApiLink.css @@ -0,0 +1,8 @@ +.ApiLink { + color: blue; + text-decoration: underline; + background-color: transparent; + border: none; + padding: 0; + cursor: pointer; +} diff --git a/src/renderer/editor/ApiLink.tsx b/src/renderer/editor/ApiLink.tsx new file mode 100644 index 0000000..9573388 --- /dev/null +++ b/src/renderer/editor/ApiLink.tsx @@ -0,0 +1,26 @@ +import './ApiLink.css'; + +/** + * Links to a section of the student API documentation, opening the help window or just jumping to + * the appropriate section if the window is already open. The single text node child of this + * component is used as the link text. + * @param props.dest - the section of the docs to jump to. TODO: figure out format + * @param props.code - whether to display the link text in a monospaced font. + */ +export default function ApiLink({ + dest, + code = false, + children, +}: { + dest: string; + code: boolean; + children: string; +}) { + const text = `(${children})[${dest}]`; + // Placeholder + return ( + + ); +} diff --git a/src/renderer/editor/HighlightedCode.tsx b/src/renderer/editor/HighlightedCode.tsx index 2913bd3..9a7ef41 100644 --- a/src/renderer/editor/HighlightedCode.tsx +++ b/src/renderer/editor/HighlightedCode.tsx @@ -2,6 +2,14 @@ import AceEditor from 'react-ace'; import 'ace-builds/src-noconflict/mode-python'; import './HighlightedCode.css'; +/** + * Uses a read-only AceEditor to display a code block with Python syntax highlighting. The only + * valid children of this component is text containing the code to be displayed. Common indentation + * is removed from each line of code before display. Only spaces are considered indentation; tabs, + * half-width spaces, and nonbreaking spaces are treated as content. + * @param props.indent - number of spaces of indentation to prepend to each line, after common + * indentation is removed. + */ export default function HighlightedCode({ children, indent = 0, @@ -17,16 +25,19 @@ export default function HighlightedCode({ lines.pop(); } // Remove common indent - const minIndent = Math.min(...lines - .filter(line => line.trim().length) - .map(line => line.match(/^ */)[0].length) + const minIndent = Math.min( + ...lines + .filter((line) => line.trim().length) + .map((line) => line.match(/^ */)[0].length), ); - const formatted = lines.map(line => ' '.repeat(indent) + line.slice(minIndent)).join('\n'); + const formatted = lines + .map((line) => ' '.repeat(indent) + line.slice(minIndent)) + .join('\n'); return ( ReactNode; } = { - 'Robot.get_value': () =>
- The get_value function returns the current value of a - specified param on a device with the specified device_id. -
- Parameters: -
    -
  • - device_id: the ID that specifies which PiE device - will be read -
  • -
  • - param: identifies which parameter on the specified - PiE device will be read. Possible param values depend on the specified device. Find a list of - params for each type of device on the lowcar devices page. -
  • -
- The function is useful for checking the current state of devices. For example, getting the - current state of a limit switch using its device_id and - the param "switch0" will return True when pressed down and False if not. - {` - # First segment of code ran in the teleop process - limit_switch = "//INSERT SWITCH ID HERE//" + 'Robot.get_value': () => ( +
+ The get_value function returns the current value of a + specified param on a device with the specified{' '} + device_id. +
+ Parameters: +
    +
  • + device_id: the ID that + specifies which PiE device will be read +
  • +
  • + param: identifies which + parameter on the specified PiE device will be read. Possible param + values depend on the specified device. Find a list of params for each + type of device on the{' '} + lowcar devices page. +
  • +
+ The function is useful for checking the current state of devices. For + example, getting the current state of a limit switch using its{' '} + device_id and the param "switch0" will + return True when pressed down and False if not. + {` + # First segment of code ran in the teleop process + limit_switch = "//INSERT SWITCH ID HERE//" - def teleop_setup(): - print("Tele-operated mode has started!") + def teleop_setup(): + print("Tele-operated mode has started!") - def teleop_main(): - # Example code for getting the value of a limit switch - # First parameter is the limit switch's id - # Second parameter tells which switch to get the value from - # In this case the method will return True or False depending on if the switch is pressed down or not + def teleop_main(): + # Example code for getting the value of a limit switch + # First parameter is the limit switch's id + # Second parameter tells which switch to get the value from + # In this case the method will return True or False depending on if the switch is pressed down or not - Robot.get_value(limit_switch, switch0) - `} -
, + Robot.get_value(limit_switch, switch0) + `}
+
+ ), Robot: () =>
Documentation for Robot object.
, };