Skip to content

Commit 80fc519

Browse files
Added examples of good scope fixtures to docs (#3244)
1 parent 0a9caf9 commit 80fc519

2 files changed

Lines changed: 87 additions & 26 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
# AGENTS.md
22

3-
## Documentation Structure
3+
## Documentation structure
44

55
- Main documentation is in `/packages/app-web-docs/src/docs/user/README.md`
66
- Spoken forms are defined in `/cursorless-talon/src/spoken_forms.json`
77
- Contributing documentation is in `/packages/app-web-docs/src/docs/contributing/`
88

9-
## Project Organization
9+
## Project organization
1010

1111
- Main extension code is in `/packages/app-vscode/`
1212
- Engine code is in `/packages/lib-engine/`
1313
- Tests are in `resources/fixtures/recorded` and `resources/fixtures/scopes`
1414
- Language-specific parsing is defined in the `resources/queries/*.scm` files
1515

16-
## Build and Test
16+
## Build and test
1717

1818
- Always run lint when making changes:
1919
- `pnpm run lint`
2020
- Tests can be run with:
2121
- `pnpm test`
2222

23-
## Documentation Conventions
23+
## Documentation conventions
2424

2525
When documenting actions or modifiers:
2626

@@ -30,7 +30,7 @@ When documenting actions or modifiers:
3030
- For versatile actions like `drink`, `pour`, `drop`, `float`, and `puff`, explain their behavior with different scope types
3131
- Always document special behaviors with different scope types
3232

33-
## Implementation Notes
33+
## Implementation notes
3434

3535
- Many actions (`drop`, `float`, `puff`) work with both line and non-line targets
3636
- Always check test fixtures in `/resources/fixtures/recorded` to understand behavior
@@ -41,7 +41,7 @@ When documenting actions or modifiers:
4141

4242
When writing or updating `.scope` files please follow the guidelines in [scope-test-format.md](./packages/app-web-docs/src/docs/contributing/scope-test-format.md)
4343

44-
## Pull Request Guidelines
44+
## Pull Request guidelines
4545

4646
- Any feedback should be addressed in code or replied to
4747
- Tests should be included for new functionality

packages/app-web-docs/src/docs/contributing/scope-test-format.md

Lines changed: 81 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ For ease of readability we want all scope test to follow the recommended style g
8585
### Naming convention and values
8686

8787
- For classes, functions and variables we use the classic: `foo`, `bar`, `baz`, `bongo`. Language specific formatting still applies. eg `Foo` for a class in Java, `IFoo` for an interface in C# etc.
88-
- For arguments and parameters we usually use: `aaa`, `bbb`, `ccc` and so on.
89-
- For data type we usually use `int` or `number`.
90-
- For value we usually use `0`, `1`, `2` and so on.
88+
- For arguments and parameters we use: `aaa`, `bbb`, `ccc` and so on.
89+
- For data type we use `int` or `number`.
90+
- For value we use `0`, `1`, `2` and so on.
9191

9292
Examples:
9393

94-
```
94+
```java
9595
class Foo {}
9696
int foo = 0;
9797
foo(aaa, bbb);
@@ -101,35 +101,96 @@ foo(aaa, bbb);
101101

102102
Don't add more lines than the example actually needs. For example if the test is about the class name, the facet `name.class`: there is no point having a lot of code in the class body or having it span multiple lines. Keep the code single line and with an empty body if possible.
103103

104-
```
105-
>---<
106-
0| class Foo {}
104+
```ts
105+
class Foo {}
107106
```
108107

109108
There are exceptions to this rule:
110109

111110
1. Sometimes we actually need a body, but that doesn't mean that we need it to be multiple lines. The facet `interior.class` can look like this:
112111

113-
```
114-
>-<
115-
0| class Foo { }
112+
```py
113+
class Foo { }
116114
```
117115

118116
2. When testing a facet inside a code block. eg a method in a class or a field in a interface multiple lines are prefered.
119117

120-
```
121-
0| class Foo {
122-
>--------<
123-
1| bar() {}
124-
2| }
118+
```ts
119+
class Foo {
120+
bar() {}
121+
}
125122
```
126123

127124
3. If you're doing a `*.iteration.document` test we want to include a leading and trailing new line. eg:
128125

126+
```java
127+
128+
int foo;
129+
129130
```
130-
>
131-
0|
132-
1| int foo;
133-
2|
134-
<
131+
132+
## Examples of good fixtures
133+
134+
These are examples of scope facets and appropriate source code.
135+
136+
```java
137+
// name.variable.initialized
138+
// value.variable
139+
int foo = 0;
140+
141+
// class
142+
// class.name
143+
// statement.class
144+
class Foo {}
145+
146+
// class
147+
// class.name
148+
// statement.class
149+
@bar
150+
class Foo {}
151+
152+
// interior.class
153+
class Foo { }
154+
155+
// functionCall
156+
// functionCallee
157+
// statement.functionCall
158+
foo();
159+
160+
// argumentList.actual.singleLine
161+
// argument.actual.singleLine
162+
// argument.actual.iteration
163+
foo(aaa, bbb);
164+
165+
// argumentList.formal.multiLine
166+
// argument.formal.multiLine
167+
// argument.formal.iteration
168+
// name.formal.multiLine
169+
// type.formal.multiLine
170+
void bar(
171+
int aaa,
172+
int bbb
173+
) {}
174+
175+
// statement.field.class
176+
// name.field.class
177+
class Foo {
178+
int bar;
179+
int baz = 0;
180+
@An int bongo = 0;
181+
}
182+
183+
// interior.while
184+
while (true) { }
185+
186+
// statement.if
187+
// branch.if.elif.else
188+
if (true) {}
189+
else if (false) {}
190+
else {}
191+
192+
// interior.if
193+
if (true) { }
194+
else if (false) { }
195+
else { }
135196
```

0 commit comments

Comments
 (0)