-
-
Notifications
You must be signed in to change notification settings - Fork 94
Added references for actions, modifiers, and scopes in docs #3304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
92dc5d2
94eda7a
bc04952
ff5c93c
749fdc1
3039756
3ef2adf
5dbca48
d2d9dbc
ef9705e
f1709ad
4cf3955
973cde1
8fa6e3d
120b322
e88446c
29233f3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,3 +25,8 @@ | |
| .pointer { | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .list-unstyled { | ||
| padding-left: 1rem; | ||
| list-style: none; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import React, { Fragment } from "react"; | ||
| import { | ||
| actionReferences, | ||
| modifierReferences, | ||
| scopeReferences, | ||
| } from "@cursorless/lib-common"; | ||
| import type { ReferenceEntry } from "@cursorless/lib-common"; | ||
|
|
||
| export function ActionReference({ id }: { id: keyof typeof actionReferences }) { | ||
| return <ReferenceEntryComponent id={id} entry={actionReferences[id]} />; | ||
| } | ||
|
|
||
| export function ModifierReference({ | ||
| id, | ||
| }: { | ||
| id: keyof typeof modifierReferences; | ||
| }) { | ||
| return <ReferenceEntryComponent id={id} entry={modifierReferences[id]} />; | ||
| } | ||
|
|
||
| export function ScopeReference({ id }: { id: keyof typeof scopeReferences }) { | ||
| return <ReferenceEntryComponent id={id} entry={scopeReferences[id]} />; | ||
| } | ||
|
|
||
| function ReferenceEntryComponent({ | ||
| id, | ||
| entry, | ||
| }: { | ||
| id: string; | ||
| entry: ReferenceEntry; | ||
| }) { | ||
| return ( | ||
| <> | ||
| {entry.description != null && <p>{entry.description}</p>} | ||
|
|
||
| <p> | ||
| Cursorless ID: <code>{id}</code> | ||
| </p> | ||
|
|
||
| {entry.defaultSpokenForm != null && ( | ||
| <div className="mb-3"> | ||
| <div> | ||
| Default spoken form: <code>{entry.defaultSpokenForm}</code> | ||
| </div> | ||
|
|
||
| {entry.legacySpokenForms != null && ( | ||
| <div> | ||
| Legacy spoken forms:{" "} | ||
| {entry.legacySpokenForms.map((s, i) => ( | ||
| <Fragment key={s}> | ||
| {i > 0 && ", "} | ||
| <code>{s}</code> | ||
| </Fragment> | ||
| ))} | ||
| </div> | ||
| )} | ||
|
|
||
| {entry.disabledByDefault && ( | ||
| <div> | ||
| <strong>Disabled by default</strong> | ||
| </div> | ||
| )} | ||
| </div> | ||
| )} | ||
|
|
||
| {entry.syntaxes.length > 0 && ( | ||
| <div> | ||
| Syntax: | ||
| <ul className="list-unstyled"> | ||
| {entry.syntaxes.map((syntax, index) => ( | ||
| <li key={index}> | ||
| {formatPattern(syntax.pattern, entry.defaultSpokenForm)}:{" "} | ||
| {formatPattern(syntax.description)} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| )} | ||
|
|
||
| {entry.examples.length > 0 && ( | ||
| <div> | ||
| Examples: | ||
| <ul className="list-unstyled"> | ||
| {entry.examples.map((example, index) => ( | ||
| <li key={index}> | ||
| <code> | ||
| " | ||
| {formatPattern(example.spokenForm, entry.defaultSpokenForm)} | ||
| " | ||
| </code> | ||
| : {example.description} | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| function formatPattern( | ||
| pattern: string, | ||
| defaultSpokenForm?: string, | ||
| ): React.ReactNode[] { | ||
| return pattern.split(/(<[\w ]+>)/gu).map((part, index) => { | ||
| if (part.startsWith("<") && part.endsWith(">")) { | ||
| if (part === "<spokenForm>") { | ||
| return defaultSpokenForm ?? "???"; | ||
| } | ||
| return <code key={index}>{part}</code>; | ||
| } | ||
| return part; | ||
| }); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| { | ||
| "label": "Private scopes" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Scopes } from "@site/src/docs/components/Scopes"; | ||
|
|
||
| # Custom regex | ||
|
|
||
| <Scopes scopeTypeType="customRegex" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Scopes } from "@site/src/docs/components/Scopes"; | ||
|
|
||
| # Field access | ||
|
|
||
| <Scopes scopeTypeType="private.fieldAccess" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Scopes } from "@site/src/docs/components/Scopes"; | ||
|
|
||
| # Interior | ||
|
|
||
| <Scopes scopeTypeType="interior" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Scopes } from "@site/src/docs/components/Scopes"; | ||
|
|
||
| # String | ||
|
|
||
| <Scopes scopeTypeType="string" /> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { Scopes } from "@site/src/docs/components/Scopes"; | ||
|
|
||
| # Text fragment | ||
|
|
||
| <Scopes scopeTypeType="textFragment" /> |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.