Skip to content

Commit c7abdb7

Browse files
Document customizing snippet extraction (#503)
1 parent dce6f5b commit c7abdb7

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

building/tooling/snippet-extractor.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,27 @@
33
The [Snippet Extractor][snippet-extractor] takes a student's submission and extracts the first ten "interesting" lines of code from it.
44
The extracted snippet is shown on various pages on the website.
55

6-
By default, the first ten lines are shown, ignore leading empty lines.
6+
By default, the first ten lines are shown, ignoring leading empty lines.
77
These first ten lines _could_ include things like comments, which are usually not ideal to be presented in a snippet.
8-
Each track can [customize the snippet extraction][snippet-extractor-customize], for example to remove said comments.
8+
9+
## Customizing snippet extraction
10+
11+
We recommend each track [customizes snippet extraction][snippet-extractor-customize] to at least remove comments from the source code.
12+
To customize snippet extraction, you'll need to:
13+
14+
1. Add a `lib/languages/<track_slug>.txt` file which configures snippet extraction.
15+
This file can use either [basic mode][basic-mode] or [extended mode][extended-mode].
16+
Most tracks use extended mode, as it gives more flexibility.
17+
2. Add one or more test cases to a `tests/<track_slug>/<test_slug>` directory.
18+
Each test directory will need two files:
19+
20+
1. `tests/<track_slug>/<test_slug>/code.<track_extension>`: the code to run the snippet extractor on
21+
2. `tests/<track_slug>/<test_slug>/expected_snippet.<track_extension>`: the expected snippet
22+
23+
See [this example pull request][example-pr] that customizes snippet extraction for the Arturo language.
924

1025
[snippet-extractor]: https://github.com/exercism/snippet-extractor/
11-
[snippet-extractor-customize]: https://github.com/exercism/snippet-extractor/#add-your-language
26+
[snippet-extractor-customize]: https://github.com/exercism/snippet-extractor/?tab=readme-ov-file#customizing-snippet-extraction
27+
[example-pr]: https://github.com/exercism/snippet-extractor/pull/94
28+
[basic-mode]: https://github.com/exercism/snippet-extractor/blob/main/docs/basic.md
29+
[extended-mode]: https://github.com/exercism/snippet-extractor/blob/main/docs/extended.md

0 commit comments

Comments
 (0)