Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/app-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1219,7 +1219,7 @@
}
},
"cursorless.experimental.hatStability": {
"markdownDescription": "As you scroll, edit, and move your cursor, this setting determines how much Cursorless will move hats around to ensure that the best hats are near the cursor. See https://www.cursorless.org/docs/user/hatAssignment/",
"markdownDescription": "As you scroll, edit, and move your cursor, this setting determines how much Cursorless will move hats around to ensure that the best hats are near the cursor. See https://www.cursorless.org/docs/user/hat-assignment/",
"type": "string",
"default": "balanced",
"enum": [
Expand Down
2 changes: 2 additions & 0 deletions packages/app-web-docs/docusaurus.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { Root } from "mdast";
import { themes } from "prism-react-renderer";
import type { Transformer } from "unified";
import { visit } from "unist-util-visit";
import { sidebarItemsGenerator } from "./sidebarItemsGenerator.ts";

// oxlint-disable-next-line unicorn/prefer-import-meta-properties
const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down Expand Up @@ -152,6 +153,7 @@ const config: Config = {
editUrl:
"https://github.com/cursorless-dev/cursorless/edit/main/packages/app-web-docs/",
sidebarPath: require.resolve("./sidebar.js"),
sidebarItemsGenerator,
Comment thread
AndreasArvidsson marked this conversation as resolved.
beforeDefaultRemarkPlugins: [
remarkPluginFixLinksToRepositoryArtifacts,
],
Expand Down
118 changes: 118 additions & 0 deletions packages/app-web-docs/sidebarItemsGenerator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import type * as ClassicPreset from "@docusaurus/preset-classic";

type DocsOptions = Exclude<ClassicPreset.Options["docs"], false | undefined>;
type SidebarItemsGenerator = NonNullable<DocsOptions["sidebarItemsGenerator"]>;

interface Group {
label: string;
items: string[];
}

const items: (Group | string)[] = [
"Cursorless",
{
label: "Getting started",
items: ["Installation", "How-to guides"],
},
{
label: "Reference",
items: ["Actions", "Modifiers", "Scopes", "Destinations"],
},
"Supported languages",
{
label: "Customization",
items: ["Customization", "Hat assignment", "Visual Accessibility"],
},
{
label: "Tools",
items: ["Cursorless sidebar", "Scope visualizer", "Local command history"],
},
{
label: "Advanced",
items: ["Unicode support", "Experimental features"],
},
{
label: "Project",
items: ["Updating", "Glossary", "Release notes"],
},
];

export const sidebarItemsGenerator: SidebarItemsGenerator = async ({
defaultSidebarItemsGenerator,
...args
}) => {
const generatedItems = await defaultSidebarItemsGenerator(args);

type NormalizedSidebarItem = (typeof generatedItems)[number];

if (args.item.dirName !== "user") {
return generatedItems;
}

const docsById = new Map(args.docs.map((doc) => [doc.id, doc]));
const remainingItems = generatedItems.slice();

function getLabel(item: (typeof generatedItems)[number]) {
if (item.type === "doc" || item.type === "ref") {
const doc = docsById.get(item.id);
return doc?.frontMatter.sidebar_label ?? doc?.title;
}
if ("label" in item) {
return item.label;
}
throw new Error(`Unexpected sidebar item type: ${item.type}`);
}

function takeItem(label: string): NormalizedSidebarItem {
const index = remainingItems.findIndex(
(item) => getLabel(item)?.toLowerCase() === label.toLowerCase(),
);
const item = remainingItems[index];
if (item == null) {
throw new Error(`Missing generated sidebar item '${label}'`);
}
remainingItems.splice(index, 1);
return item;
}

function createGroup(group: Group): NormalizedSidebarItem {
const items = group.items.map(takeItem);
const linkIndex = items.findIndex(
(item) => item.type === "doc" && getLabel(item) === group.label,
);
const [link] = linkIndex === -1 ? [] : items.splice(linkIndex, 1);

return {
type: "category",
label: group.label,
collapsible: false,
collapsed: false,
...(link?.type === "doc" ? { link: { type: "doc", id: link.id } } : {}),
items,
};
}

const groupedItems = items.map((item): NormalizedSidebarItem => {
if (typeof item === "string") {
return takeItem(item);
}
return createGroup(item);
});

if (remainingItems.length > 0) {
const remainingJson = remainingItems
.map((item) => {
if (item.type === "category") {
const { items, ...rest } = item;
return JSON.stringify(rest);
}
return JSON.stringify(item);
})
.join(", ");
throw new Error(
`Unassigned generated user sidebar items: ${remainingJson}`,
);
}

return groupedItems;
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { DynamicTOC } from "../../../components/DynamicTOC";
import { ScopeVisualizer } from "../../../components/ScopeVisualizer";
import { ScrollToHashId } from "../../../components/ScrollToHashId";
import { DynamicTOC } from "./DynamicTOC";
import { ScopeVisualizer } from "./ScopeVisualizer";
import { ScrollToHashId } from "./ScrollToHashId";

interface Props {
languageId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Follow the instructions in [Adding a new scope](./adding-a-new-scope.md) to defi
Create a `.mdx` file in [`languages`](../user/languages) with the `Language` react component. The file should be named after your language, eg `java.mdx`

```md
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Java

Expand Down
5 changes: 2 additions & 3 deletions packages/app-web-docs/src/docs/user/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
---
slug: /
sidebar_position: 1
---

# Cursorless documentation
# Cursorless

Welcome to Cursorless! You may find it helpful to start with the [tutorial videos](https://www.youtube.com/watch?v=5mAzHGM2M0k&list=PLXv2sppxeoQZz49evjy4T0QJRIgc_JPqs).

Expand Down Expand Up @@ -69,7 +68,7 @@ The following colors are supported. Note that to target the default (gray) hat y

You can enable or disable colors in your VSCode settings, by searching for [`cursorless.hatEnablement.colors`](vscode://settings/cursorless.hatEnablement.colors) and checking the box next to the internal ID for the given shape as listed above. To navigate to your VSCode settings, either say "show settings", or go to File --> Preferences --> Settings.

You can also tweak the visible colors for any of these colors in your VSCode settings, by searching for [`cursorless.colors`](vscode://settings/cursorless.colors) and changing the hex color code next to the internal ID for the given shape as listed above. Note that you can configure different colors for dark and light themes. See our [visual accessibility guide](visualAccessibility.md) for more on visual accessibility.
You can also tweak the visible colors for any of these colors in your VSCode settings, by searching for [`cursorless.colors`](vscode://settings/cursorless.colors) and changing the hex color code next to the internal ID for the given shape as listed above. Note that you can configure different colors for dark and light themes. See our [visual accessibility guide](visual-accessibility.md) for more on visual accessibility.

If you find these color names unintuitive / tough to remember, their
spoken forms can be [customized](customization.md) like any other spoken form
Expand Down
3 changes: 3 additions & 0 deletions packages/app-web-docs/src/docs/user/actions/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"label": "Actions"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"label": "Experimental features"
}
4 changes: 2 additions & 2 deletions packages/app-web-docs/src/docs/user/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ To replace a target with the contents of the clipboard, say `"paste to <target>"

:::info

`"to <target>"` is an example of a Destination. See [Destinations](reference/destinations.md) for more information.
`"to <target>"` is an example of a Destination. See [Destinations](destinations.md) for more information.

:::

Expand Down Expand Up @@ -84,6 +84,6 @@ See the [Talon-side api docs](./customization.md#cursorless-public-api) for more

:::info

Notice how we use `cursorless_create_destination` to create a destination for the result of the transformation. The `cursorless_insert` action expects a destination, so that it knows whether to replace, insert before, or insert after the target. See [Destinations](reference/destinations.md) for more information.
Notice how we use `cursorless_create_destination` to create a destination for the result of the transformation. The `cursorless_insert` action expects a destination, so that it knows whether to replace, insert before, or insert after the target. See [Destinations](destinations.md) for more information.

:::
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Languages
# Supported languages

Cursorless supports a wide range of languages, though our level of support varies a bit
from language to language. See the sidebar for information about how well we support various
Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/c.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# C

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Clojure

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/cpp.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# C++

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/csharp.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_label: C#
---

import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# C#

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/css.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# CSS

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/dart.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Dart

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/go.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Go

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/html.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# HTML

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/java.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Java

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# JavaScript

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# JavaScript React

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/json.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# JSON

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/jsonc.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_label: JSONC
---

import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# JSON with comments (JSONC)

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/jsonl.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_label: JSONL
---

import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# JSON lines (JSONL)

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/kotlin.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Kotlin

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/latex.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Latex

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/lua.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Lua

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Markdown

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/php.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# PHP

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Plaintext

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Properties

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/python.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Python

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/r.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# R

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/ruby.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Ruby

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/rust.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Rust

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/scala.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Scala

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/scm.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
sidebar_label: Tree sitter query
---

import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# Tree sitter query (SCM)

Expand Down
2 changes: 1 addition & 1 deletion packages/app-web-docs/src/docs/user/languages/scss.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Language } from "./components/Language";
import { Language } from "@site/src/docs/components/Language";

# SCSS

Expand Down
Loading
Loading