Skip to content

Commit 873054f

Browse files
Added contribution scopes page to compare scopes between languages
1 parent f7f3cb5 commit 873054f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+734
-247
lines changed

packages/common/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ export * from "./util/itertools";
104104
export * from "./util/Notifier";
105105
export * from "./util/object";
106106
export * from "./util/omitByDeep";
107+
export * from "./util/prettifyLanguageName";
107108
export * from "./util/range";
108109
export * from "./util/regex";
109110
export * from "./util/selectionsEqual";
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { capitalize } from "./stringUtils";
2+
3+
export function prettifyLanguageName(name: string): string {
4+
switch (name) {
5+
case "cpp":
6+
return "C++";
7+
case "csharp":
8+
return "C#";
9+
case "javascript":
10+
return "JavaScript";
11+
case "typescript":
12+
return "TypeScript";
13+
case "javascriptreact":
14+
return "JavaScript React";
15+
case "typescriptreact":
16+
return "TypeScript React";
17+
case "jsonl":
18+
return "JSON lines (JSONL)";
19+
case "jsonc":
20+
return "JSON with comments (JSONC)";
21+
case "scm":
22+
return "Tree sitter query language (scm)";
23+
case "css":
24+
case "scss":
25+
case "json":
26+
case "php":
27+
case "html":
28+
case "xml":
29+
return name.toUpperCase();
30+
default:
31+
return capitalize(name);
32+
}
33+
}

packages/common/src/util/serializeScopeType.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { capitalize } from "lodash-es";
12
import type {
23
ScopeType,
34
ScopeTypeType,
45
SimpleScopeTypeType,
56
} from "../types/command/PartialTargetDescriptor.types";
7+
import { camelCaseToAllDown } from "./stringUtils";
68

79
export function serializeScopeType(
810
scopeType: SimpleScopeTypeType | ScopeType,
@@ -12,3 +14,9 @@ export function serializeScopeType(
1214
}
1315
return scopeType.type;
1416
}
17+
18+
export function prettifyScopeType(
19+
scopeType: SimpleScopeTypeType | ScopeType,
20+
): string {
21+
return capitalize(camelCaseToAllDown(serializeScopeType(scopeType)));
22+
}

packages/common/src/util/stringUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*/
1111
export function camelCaseToAllDown(input: string): string {
1212
return input
13-
.replace(/([A-Z])/g, " $1")
13+
.replace(/(?<=[a-z0-9])([A-Z])/g, " $1")
1414
.split(" ")
1515
.map((word) => word.toLowerCase())
1616
.join(" ");

packages/cursorless-org-docs/src/docs/user/languages/components/Code.css renamed to packages/cursorless-org-docs/src/docs/components/Code.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@
2828
counter-reset: line;
2929
}
3030

31+
.code-container .shiki {
32+
/* line-height: 1rem; */
33+
}
34+
3135
.code-container .line {
3236
position: relative;
3337
margin-left: 1.5rem;
38+
/* display: inline-block; */
3439
}
3540

3641
.code-container .line::before {
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React from "react";
33

44
interface Props {
55
className?: string;
6+
value?: string;
67
title?: string;
78
children: string;
89
}
@@ -19,12 +20,16 @@ export function H4(props: Props) {
1920
return renderHeader(4, props);
2021
}
2122

23+
export function H5(props: Props) {
24+
return renderHeader(5, props);
25+
}
26+
2227
function renderHeader(
2328
level: number,
24-
{ className, title, children }: Props,
29+
{ className, value, title, children }: Props,
2530
): React.JSX.Element {
2631
const Tag = `h${level}` as keyof React.JSX.IntrinsicElements;
27-
const href = uriEncodeHashId(children);
32+
const href = uriEncodeHashId(value ?? children);
2833
return (
2934
<Tag
3035
id={href}

0 commit comments

Comments
 (0)