File tree Expand file tree Collapse file tree 7 files changed +36
-22
lines changed
cursorless-org-docs/src/docs/user/languages/components Expand file tree Collapse file tree 7 files changed +36
-22
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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 ) ;
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 44 type ScopeSupportFacet ,
55 type ScopeSupportFacetInfo ,
66} from "@cursorless/common" ;
7+ import { serializeScopeType } from "@cursorless/common/src/util/serializeScopeType" ;
78import React , { useState , type JSX } from "react" ;
8- import { prettifyFacet , prettifyScopeType , serializeScopeType } from "./util" ;
9+ import { prettifyFacet , prettifyScopeType } from "./util" ;
910
1011interface Props {
1112 facets : ScopeSupportFacet [ ] ;
Original file line number Diff line number Diff 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" ;
78import React , { useState } from "react" ;
89import scopeTestsJson from "../../../../../static/scopeTests.json" ;
910import { Code , type Highlight } from "./Code" ;
1011import 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
1814const 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 ) =>
Original file line number Diff line number Diff line change 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-
4837export function prettifyScopeType ( scopeType : string ) : string {
4938 return capitalize ( camelCaseToAllDown ( scopeType ) ) ;
5039}
Original file line number Diff line number Diff line change 1+ import type {
2+ ScopeSupportFacet ,
3+ TextualScopeSupportFacet ,
4+ } from "@cursorless/common" ;
5+ import { getCursorlessRepoRoot } from "@cursorless/node-common" ;
16import * as path from "path" ;
27import { walkFilesSync } from "./walkSync" ;
3- import { getCursorlessRepoRoot } from "@cursorless/node-common" ;
48
59export 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
4448export 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 - z A - Z . ] + ) \d * \. s c o p e / ) ! [ 1 ] ,
58+ facet : path . basename ( p ) . match ( / ( [ a - z A - Z . ] + ) \d * \. s c o p e / ) ! [ 1 ] as
59+ | ScopeSupportFacet
60+ | TextualScopeSupportFacet ,
5561 } ) ) ;
5662}
5763
You can’t perform that action at this time.
0 commit comments