Skip to content

Commit 5f7477a

Browse files
Fix import problems
1 parent edad3e9 commit 5f7477a

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type {
2+
ScopeType,
3+
SimpleScopeTypeType,
4+
} from "../types/command/PartialTargetDescriptor.types";
5+
6+
export function serializeScopeType(
7+
scopeType: SimpleScopeTypeType | ScopeType,
8+
): string {
9+
if (typeof scopeType === "string") {
10+
return scopeType;
11+
}
12+
return scopeType.type;
13+
}

packages/cursorless-org-docs/src/docs/user/languages/components/Language.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ export function Language({ languageId }: Props) {
1010
return (
1111
<>
1212
<h2>Scopes</h2>
13+
1314
<ScopeVisualizer languageId={languageId} />
15+
1416
<ScopeSupport languageId={languageId} />
1517
</>
1618
);

packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function ScopeSupport({ languageId }: Props): React.JSX.Element {
2929
<ScopeSupportForLevel
3030
facets={supportedFacets}
3131
title="Supported facets"
32-
subtitle="These facets are supported"
32+
subtitle="These scope facets are supported"
3333
/>
3434

3535
<ScopeSupportForLevel

packages/cursorless-org-docs/src/docs/user/languages/components/ScopeSupportForLevel.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import {
44
type ScopeSupportFacet,
55
type ScopeSupportFacetInfo,
66
} from "@cursorless/common";
7+
import { serializeScopeType } from "@cursorless/common/src/util/serializeScopeType";
78
import React, { useState, type JSX } from "react";
8-
import { prettifyFacet, prettifyScopeType, serializeScopeType } from "./util";
9+
import { prettifyFacet, prettifyScopeType } from "./util";
910

1011
interface Props {
1112
facets: ScopeSupportFacet[];

packages/cursorless-org-docs/src/docs/user/languages/components/ScopeVisualizer.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,12 @@ import {
44
type ScopeSupportFacetInfo,
55
type TextualScopeSupportFacet,
66
} from "@cursorless/common";
7+
import { serializeScopeType } from "@cursorless/common/src/util/serializeScopeType";
78
import React, { useState } from "react";
89
import scopeTestsJson from "../../../../../static/scopeTests.json";
910
import { Code, type Highlight } from "./Code";
1011
import type { Fixture, ScopeTestsJson } from "./types";
11-
import {
12-
getFacetInfo,
13-
prettifyFacet,
14-
prettifyScopeType,
15-
serializeScopeType,
16-
} from "./util";
12+
import { getFacetInfo, prettifyFacet, prettifyScopeType } from "./util";
1713

1814
const scopeTests = scopeTestsJson as ScopeTestsJson;
1915

@@ -65,6 +61,13 @@ export function ScopeVisualizer({ languageId }: Props) {
6561

6662
return (
6763
<>
64+
<div className="mb-4">
65+
Below are visualizations of all our scope tests for this language. These
66+
were designed primarily as tests rather than documentation. There are
67+
quite a few of them, and they may be a bit overwhelming from a
68+
documentation perspective.
69+
</div>
70+
6871
{renderOptions()}
6972

7073
{scopes.map((scope) =>

packages/cursorless-org-docs/src/docs/user/languages/components/util.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
textualScopeSupportFacetInfos,
66
type ScopeSupportFacet,
77
type ScopeSupportFacetInfo,
8-
type ScopeType,
9-
type SimpleScopeTypeType,
108
type TextualScopeSupportFacet,
119
} from "@cursorless/common";
1210

@@ -36,15 +34,6 @@ export function prettifyFacet(
3634
return name;
3735
}
3836

39-
export function serializeScopeType(
40-
scopeType: SimpleScopeTypeType | ScopeType,
41-
): string {
42-
if (typeof scopeType === "string") {
43-
return scopeType;
44-
}
45-
return scopeType.type;
46-
}
47-
4837
export function prettifyScopeType(scopeType: string): string {
4938
return capitalize(camelCaseToAllDown(scopeType));
5039
}

packages/node-common/src/getFixturePaths.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
import type {
2+
ScopeSupportFacet,
3+
TextualScopeSupportFacet,
4+
} from "@cursorless/common";
5+
import { getCursorlessRepoRoot } from "@cursorless/node-common";
16
import * as path from "path";
27
import { walkFilesSync } from "./walkSync";
3-
import { getCursorlessRepoRoot } from "@cursorless/node-common";
48

59
export function getFixturesPath() {
610
return path.join(getCursorlessRepoRoot(), "data", "fixtures");
@@ -38,7 +42,7 @@ export interface ScopeTestPath {
3842
path: string;
3943
name: string;
4044
languageId: string;
41-
facet: string;
45+
facet: ScopeSupportFacet | TextualScopeSupportFacet;
4246
}
4347

4448
export function getScopeTestPaths(): ScopeTestPath[] {
@@ -51,7 +55,9 @@ export function getScopeTestPaths(): ScopeTestPath[] {
5155
path: p,
5256
name: pathToName(relativeDir, p),
5357
languageId: path.dirname(path.relative(directory, p)).split(path.sep)[0],
54-
facet: path.basename(p).match(/([a-zA-Z.]+)\d*\.scope/)![1],
58+
facet: path.basename(p).match(/([a-zA-Z.]+)\d*\.scope/)![1] as
59+
| ScopeSupportFacet
60+
| TextualScopeSupportFacet,
5561
}));
5662
}
5763

0 commit comments

Comments
 (0)