Skip to content

Commit

Permalink
fix and generate schema, run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp committed Jun 30, 2024
1 parent 6a82051 commit 5218998
Show file tree
Hide file tree
Showing 34 changed files with 9,928 additions and 23,255 deletions.
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.mdx
generated-assets
multi-reporter-config.json
4 changes: 2 additions & 2 deletions packages/codemirror/src/extensions/lsp/tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
padding: 0px 2px;
}
.cm-lint-body p {
margin: .25em 0;
margin: 0.25em 0;
}
.cm-lint-body p:last-child {
margin-bottom: 0;
}
.cm-lint-body p:first-child {
margin-top: 0;
}
}
9 changes: 7 additions & 2 deletions packages/codemirror/src/extensions/syntax-highlighting.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { LRLanguage, LanguageSupport, foldNodeProp, indentNodeProp } from "@codemirror/language";
import {
LRLanguage,
LanguageSupport,
foldNodeProp,
indentNodeProp,
} from "@codemirror/language";
import { parser } from "@doenet/parser";
import { styleTags, tags as t } from "@lezer/highlight";

Expand Down Expand Up @@ -57,4 +62,4 @@ const doenetLanguage = LRLanguage.define({
},
});

export const syntaxHighlightingExtension = new LanguageSupport(doenetLanguage);
export const syntaxHighlightingExtension = new LanguageSupport(doenetLanguage);
2 changes: 1 addition & 1 deletion packages/codemirror/src/extensions/tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Command, keymap } from "@codemirror/view";
//tabs = 2 spaces
const tab = " ";
const tabCommand: Command = ({ state, dispatch }) => {
console.log("running")
console.log("running");
dispatch(
state.update(state.replaceSelection(tab), {
scrollIntoView: true,
Expand Down
34 changes: 34 additions & 0 deletions packages/doenetml-worker/src/components/abstract/BaseComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,40 @@ export default class BaseComponent {
.numDimensions,
);
}
let numDim =
stateVariableDescriptions[varName].numDimensions;
if (theStateDef.arrayVarNameFromPropIndex) {
stateVariableDescriptions[
varName
].arrayVarNameFromPropIndex =
theStateDef.arrayVarNameFromPropIndex;
} else if (numDim > 1) {
stateVariableDescriptions[
varName
].arrayVarNameFromPropIndex = function (
propIndex,
varName,
) {
return (
entryPrefixes[0] +
[
...propIndex.map((x) =>
Math.round(Number(x)),
),
...Array(numDim - propIndex.length).fill(1),
].join("_")
);
};
} else {
stateVariableDescriptions[
varName
].arrayVarNameFromPropIndex = function (
propIndex,
varName,
) {
return entryPrefixes[0] + propIndex[0];
};
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/doenetml/src/DoenetML.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ url(OpenSansRegularWoff) format('woff'); */
src:
url("./fonts/files/open-sans-v18-latin-light-italic.woff2")
format("woff2"),
url("./fonts/files/open-sans-v18-latin-light-italic.woff") format("woff");
url("./fonts/files/open-sans-v18-latin-light-italic.woff")
format("woff");
}

@font-face {
Expand Down
20 changes: 14 additions & 6 deletions packages/doenetml/src/Viewer/renderers/booleanInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
} */

/* Hide the browser's default checkbox */
.doenetml-boolean-container input[type='checkbox'] {
.doenetml-boolean-container input[type="checkbox"] {
position: absolute;
opacity: 0;
cursor: pointer;
Expand Down Expand Up @@ -59,22 +59,28 @@
}

/* On mouse-over, add a light blue background color */
.doenetml-boolean-container:hover input[type='checkbox'] ~ .doenetml-checkmark {
.doenetml-boolean-container:hover input[type="checkbox"] ~ .doenetml-checkmark {
background-color: var(--lightBlue);
}

/* On mouse-over of disabled, keep the grey background color */
.doenetml-boolean-container:hover input[type='checkbox'] ~ .doenetml-checkmark-disabled {
.doenetml-boolean-container:hover
input[type="checkbox"]
~ .doenetml-checkmark-disabled {
background-color: var(--mainGray);
}

/* When the checkbox is checked, add a dark blue background */
.doenetml-boolean-container input[type='checkbox']:checked ~ .doenetml-checkmark {
.doenetml-boolean-container
input[type="checkbox"]:checked
~ .doenetml-checkmark {
background-color: var(--mainBlue);
}

/* When a checkbox has focus, add a dark blue outline */
.doenetml-boolean-container:focus-within input[type='checkbox'] ~ .doenetml-checkmark {
.doenetml-boolean-container:focus-within
input[type="checkbox"]
~ .doenetml-checkmark {
outline: 2px solid var(--canvastext);
outline-offset: 2px;
}
Expand All @@ -87,7 +93,9 @@
}

/* Show the checkmark when checked */
.doenetml-boolean-container input[type='checkbox']:checked ~ .doenetml-checkmark:after {
.doenetml-boolean-container
input[type="checkbox"]:checked
~ .doenetml-checkmark:after {
display: block;
}

Expand Down
3 changes: 2 additions & 1 deletion packages/lsp-tools/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LSP Viewer</title>
<style>
html, body {
html,
body {
margin: 0;
padding: 0;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { AutoCompleter } from "..";

export type CompletionContext =
| { cursorPos: "body" }
| { cursorPos: "element"; complete: boolean; }
| { cursorPos: "macro"; complete: boolean;node: DastMacro | null };
| { cursorPos: "element"; complete: boolean }
| { cursorPos: "macro"; complete: boolean; node: DastMacro | null };

/**
* Get context about the current cursor position to determine whether completions should be offered or not,
Expand Down Expand Up @@ -34,14 +34,18 @@ export function getCompletionContext(
prevNonWhitespaceCharOffset,
);

const leftNode = this.sourceObj.nodeAtOffset(offset, {side:"left"});
const leftNode = this.sourceObj.nodeAtOffset(offset, { side: "left" });

// Check for status inside a macro
let macro = this.sourceObj.nodeAtOffset(offset, {
type: "macro",
side: "left",
});
if (!macro && (prevChar === "." || prevChar === "[") && prevPrevChar !== ")") {
if (
!macro &&
(prevChar === "." || prevChar === "[") &&
prevPrevChar !== ")"
) {
macro = this.sourceObj.nodeAtOffset(offset - 1, {
type: "macro",
side: "left",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function nodeAtOffset<const T extends DastNodes["type"]>(
if (offset > 0 && offset === this.source.length && side === "left") {
// If we ask for a node at the "end" of the file, we probably want
// the last node, not null; walk back one character.
side = "right"
side = "right";
offset -= 1;
}

Expand Down
42 changes: 28 additions & 14 deletions packages/lsp-tools/test/doenet-source-object.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,45 +130,53 @@ describe("DoenetSourceObject", () => {
source = `<a><b foo="bar"> <c>hi</c></b></a>`;
sourceObj = new DoenetSourceObject(source);
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(4);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(4);
expect(cursorPosition).toEqual("openTagName");
expect(node).toMatchObject({ type: "element", name: "b" });
}
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(6);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(6);
expect(cursorPosition).toEqual("attributeName");
expect(node).toMatchObject({ type: "element", name: "b" });
}
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(11);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(11);
expect(cursorPosition).toEqual("attributeValue");
expect(node).toMatchObject({ type: "element", name: "b" });
}
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(17);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(17);
expect(cursorPosition).toEqual("body");
expect(node).toMatchObject({ type: "element", name: "b" });
}

source = `<a > </a >`;
sourceObj = new DoenetSourceObject(source);
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(3);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(3);
expect(cursorPosition).toEqual("openTag");
expect(node).toMatchObject({ type: "element", name: "a" });
}
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(5);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(5);
expect(cursorPosition).toEqual("body");
expect(node).toMatchObject({ type: "element", name: "a" });
}
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(9);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(9);
expect(cursorPosition).toEqual("unknown");
expect(node).toMatchObject({ type: "element", name: "a" });
}
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(11);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(11);
expect(cursorPosition).toEqual("unknown");
expect(node).toMatchObject({ type: "element", name: "a" });
}
Expand All @@ -177,7 +185,8 @@ describe("DoenetSourceObject", () => {
sourceObj = new DoenetSourceObject(source);
{
const offset = source.indexOf("</a>") - 1;
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(offset);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(offset);
expect(cursorPosition).toEqual("body");
expect(node).toMatchObject({ type: "element", name: "b" });
}
Expand All @@ -186,7 +195,8 @@ describe("DoenetSourceObject", () => {
// is a non-closed element inside, we should claim to be inside the body
// of the non-closed element.
const offset = source.indexOf("</a>");
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(offset);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(offset);
expect(cursorPosition).toEqual("body");
expect(node).toMatchObject({ type: "element", name: "b" });
}
Expand All @@ -196,7 +206,8 @@ describe("DoenetSourceObject", () => {
sourceObj = new DoenetSourceObject(source);
{
const offset = source.indexOf("</a>");
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(offset);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(offset);
expect(cursorPosition).toEqual("body");
expect(node).toMatchObject({ type: "element", name: "b" });
}
Expand Down Expand Up @@ -225,23 +236,26 @@ describe("DoenetSourceObject", () => {
source = `<a `;
sourceObj = new DoenetSourceObject(source);
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(3);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(3);
expect(cursorPosition).toEqual("openTag");
expect(node).toMatchObject({ type: "element", name: "a" });
}

source = `<p><a </p>`;
sourceObj = new DoenetSourceObject(source);
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(7);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(7);
expect(cursorPosition).toEqual("openTag");
expect(node).toMatchObject({ type: "element", name: "a" });
}

source = `<`;
sourceObj = new DoenetSourceObject(source);
{
let { cursorPosition, node } = sourceObj.elementAtOffsetWithContext(1);
let { cursorPosition, node } =
sourceObj.elementAtOffsetWithContext(1);
expect(cursorPosition).toEqual("unknown");
expect(node).toEqual(null);
}
Expand Down
5 changes: 1 addition & 4 deletions packages/lsp-tools/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"rootDir": "../"
},
"include": ["../**/*.ts", "../**/*.tsx"],
"exclude": [
"node_modules",
"./vite.config.ts"
],
"exclude": ["node_modules", "./vite.config.ts"],
"references": []
}
5 changes: 1 addition & 4 deletions packages/lsp/test/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
"rootDir": "../"
},
"include": ["../**/*.ts", "../**/*.tsx"],
"exclude": [
"node_modules",
"./vite.config.ts"
],
"exclude": ["node_modules", "./vite.config.ts"],
"references": []
}
3 changes: 2 additions & 1 deletion packages/parser/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Parser Viewer</title>
<style>
html, body {
html,
body {
margin: 0;
padding: 0;
width: 100%;
Expand Down
9 changes: 7 additions & 2 deletions packages/parser/src/lezer-to-dast/lezer-to-dast-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { DastAbstractNode, DastNodes, LezerSyntaxNodeName, Position } from "../types";
import {
DastAbstractNode,
DastNodes,
LezerSyntaxNodeName,
Position,
} from "../types";
import { SyntaxNode } from "@lezer/common";
import { entityStringToRawString } from "./entity-to-string";
import { Root } from "xast";
Expand Down Expand Up @@ -306,4 +311,4 @@ export function updateNodePositionData(
}
nodeToUpdate.position.end.line += line;
nodeToUpdate.position.end.column += column;
}
}
2 changes: 1 addition & 1 deletion packages/parser/src/macros-v6/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## DoenetML v0.6 Macro Parser

DoenetML v0.6 used a different macro format. This parser parses that older macro format.
It is used by lsp-tools to convert macros to the newer format.
It is used by lsp-tools to convert macros to the newer format.
6 changes: 1 addition & 5 deletions packages/parser/src/macros-v6/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
DastText,
DastMacroV6,
DastFunctionMacroV6,
} from "../types";
import { DastText, DastMacroV6, DastFunctionMacroV6 } from "../types";
import { MacroParser } from "./parser";

/**
Expand Down
Loading

0 comments on commit 5218998

Please sign in to comment.