Skip to content

Commit 43a2d22

Browse files
Document snippet extension (#410)
Document snippet extension
1 parent 24881b8 commit 43a2d22

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

building/configlet/lint.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ The `config.json` file should have the following checks:
109109
- The `"files.example` and `"files.exemplar"` files _can_ overlap
110110
- The `"test_runner.average_run_time"` key is required if `"status.test_runner"` is equal to `true`
111111
- The `"test_runner.average_run_time"` value must be a floating-point number > 0 with one decimal point of precision
112+
- The `"approaches.snippet_extension"` key is required if the track has one or more approaches
113+
- The `"approaches.snippet_extension"` value must be a non-blank string¹
112114
- The `"exercises"` key is required
113115
- The `"exercises.concept"` key is required
114116
- The `"exercises.concept"` value must be an array
@@ -375,10 +377,11 @@ The `config.json` file should have the following checks:
375377
- The Markdown must conform to the [Markdown standards](/docs/building/markdown/markdown)
376378
- Links must be absolute (relative links are not allowed)
377379

378-
### Rule: exercises/{concept|practice}/<slug>/.approaches/<approach-slug>/snippet.txt is valid
380+
### Rule: exercises/{concept|practice}/<slug>/.approaches/<approach-slug>/snippet.<snippet-extension> is valid
379381

380382
- The file's presence is required if a matching `"approaches[].slug"` entry exists in the `.approaches/config.json` file
381383
- The snippet must have at most 8 lines
384+
- The snippet extension is taken from the `approaches.snippet_extension` value in the track's `config.json` file
382385

383386
### Rule: exercises/{concept|practice}/<slug>/.articles/config.json is valid
384387

building/tracks/approaches.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ If you'd like to compare different approaches, please write an [articles](/docs/
4242
In general, [Practice Exercises](/docs/building/tracks/practice-exercises) are more suitable to write approaches for, as they usually can be solved in multiple ways.
4343

4444
For [Concept Exercises](/docs/building/tracks/concept-exercises), discussing the exemplar approach might be interesting. For example, you could show how the concept being taught makes certain code easier to write.
45+
46+
## Configuring
47+
48+
Make sure to set the `approaches.snippet_extension` field in your [track's `config.json` file](/docs/building/tracks/config-json).

building/tracks/config-json.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ The following top-level properties contain general track metadata:
2828
- `editor`: additional read-only editor file(s) patterns (optional)
2929
- `test_runner`: an object describing the track's test runner (if any): (required if `status.test_runner` is `true`)
3030
- `average_run_time`: a `number` value for the number of seconds the test runner takes on average to run, rounded to one decimal point precision (e.g. `1.8`) (required if `status.test_runner` is `true`)
31+
- `approaches`: an object with metadata on the track's approaches: (required if the track has any approaches)
32+
- `snippet_extension`: a string value used for the snippet file's extension (e.g. `rb`) (required if the track has any approaches)
3133

3234
### Files
3335

@@ -70,6 +72,9 @@ Support will be added to [configlet](/docs/building/configlet) to use these patt
7072
},
7173
"test_runner": {
7274
"average_run_time": 2.3
75+
},
76+
"approaches": {
77+
"snippet_extension": "cs"
7378
}
7479
}
7580
```

0 commit comments

Comments
 (0)