Skip to content

Commit 2a178d9

Browse files
Describe representer docs (#384)
* Document exercises/shared/.docs/representations.md file * Describe REPRESENTER_NORMALIZATIONS.md document
1 parent ba3eba3 commit 2a178d9

File tree

3 files changed

+150
-7
lines changed

3 files changed

+150
-7
lines changed

building/tracks/docs.md

Lines changed: 121 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
# Docs
22

3-
Each track must have a `docs` directory with the following (required) files:
3+
Each track must have a `docs` directory with the following files:
44

55
```
66
docs
7-
├── ABOUT.md
8-
├── INSTALLATION.md
9-
├── LEARNING.md
10-
├── SNIPPET.txt
11-
├── RESOURCES.md
12-
└── TESTS.md
7+
├── ABOUT.md (required)
8+
├── INSTALLATION.md (required)
9+
├── LEARNING.md (required)
10+
├── SNIPPET.txt (required)
11+
├── REPRESENTER_NORMALIZATIONS.md (optional)
12+
├── RESOURCES.md (required)
13+
└── TESTS.md (required)
1314
```
1415

1516
---
@@ -132,6 +133,119 @@ let hello = "Hello, World!"
132133

133134
Check [this page](https://exercism.org/tracks/fsharp) to see what this looks like when rendered (note: you must not have already joined the track).
134135

136+
## File: `REPRESENTER_NORMALIZATIONS.md`
137+
138+
**Purpose:** List the normalizations the representer applies to a solution.
139+
140+
**Displayed on:**
141+
142+
(not displayed)
143+
144+
### Example
145+
146+
````markdown
147+
# Representer normalizations
148+
149+
The representer applies the following normalizations:
150+
151+
## Remove comments
152+
153+
All comments are removed.
154+
155+
### Before
156+
157+
```fsharp
158+
module Fake
159+
(* Block comment
160+
on multiple lines *)
161+
let message = "Hi" (* Block comment after code *)
162+
// Double-slash comment on single line
163+
let reply = "Yo" // Double-slash comment after code
164+
/// <summary>This function adds two numbers</summary>
165+
/// <param name="x">The first number</param>
166+
/// <param name="y">The second number</param>
167+
/// <returns>The first number added to the second number</param>
168+
let add x y = x + y
169+
```
170+
171+
### After
172+
173+
```fsharp
174+
module Fake
175+
let message = "Hi"
176+
let reply = "Yo"
177+
let add x y = x + y
178+
```
179+
180+
## Remove import declarations
181+
182+
All import declarations are removed.
183+
184+
### Before
185+
186+
```fsharp
187+
module Fake
188+
open System
189+
open System.IO
190+
let message = "Hi"
191+
```
192+
193+
### After
194+
195+
```fsharp
196+
module Fake
197+
let message = "Hi"
198+
```
199+
200+
## Format code
201+
202+
The code is formatted using the [fantomas library](https://fsprojects.github.io/fantomas/docs/index.html).
203+
This formats the code according to the F# style guide.
204+
The full list of transformations that are applied by fantomas can be found [here](https://fsprojects.github.io/fantomas/docs/end-users/Configuration.html).
205+
206+
### Before
207+
208+
```fsharp
209+
module Fake
210+
let add ( birthDate : DateTime) =
211+
birthDate.Add ( 2.0)
212+
type Volume =
213+
| Liter of float
214+
| USPint of float
215+
| ImperialPint of float
216+
```
217+
218+
### After
219+
220+
```fsharp
221+
module Fake
222+
let add (birthDate: DateTime) =
223+
birthDate.Add(2.0)
224+
type Volume =
225+
| Liter of float
226+
| USPint of float
227+
| ImperialPint of float
228+
```
229+
230+
## Normalize identifiers
231+
232+
Identifiers are normalized to a placeholder value.
233+
234+
### Before
235+
236+
```fsharp
237+
module Fake
238+
let foo x = x + 1
239+
```
240+
241+
### After
242+
243+
```fsharp
244+
module PLACEHOLDER_1
245+
let PLACEHOLDER_3 PLACEHOLDER_2 = PLACEHOLDER_2 + 1
246+
```
247+
````
248+
135249
## File: `RESOURCES.md`
136250

137251
**Purpose:** Links to useful resources.

building/tracks/presentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ These file are shared between all exercises:
2525

2626
- `debug.md`: explains how a student that is coding in the browser can still do "debugging" (optional)
2727
- `help.md`: contains track-specific instructions on how to get help (required)
28+
- `representations.md`: explains which normalizations are applied to a solution to create its representation (optional)
2829
- `tests.md`: contains track-specific instructions on how to run the tests (required)
2930

3031
See the [shared files documentation](/docs/building/tracks/shared-files) for more information.

building/tracks/shared-files.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Some documentation files apply to both [Concept Exercises](/docs/building/tracks
44

55
- `debug.md`: explains how a student that is coding in the browser can still do "debugging" (optional)
66
- `help.md`: contains track-specific instructions on how to get help (required)
7+
- `representations.md`: explains which normalizations are applied to a solution to create its representation (optional)
78
- `tests.md`: contains track-specific instructions on how to run the tests (required)
89

910
The [Presentation document](/docs/building/tracks/presentation) describes how these files are used to present content to the student.
@@ -58,6 +59,33 @@ This document should **not** link to Exercism-wide (track-agnostic) help resourc
5859
If you're having trouble, feel free to ask help in the C# track's [gitter channel](https://gitter.im/exercism/csharp).
5960
```
6061

62+
## File: `representations.md`
63+
64+
**Purpose:** Explains which normalizations are applied to a solution to create its representation
65+
66+
**Presence:** Optional
67+
68+
When a track has implemented a [representer](/docs/building/product/representers), each submitted solution will have a representation created for it.
69+
70+
This document should list all the normalizations the representer applies to a solution.
71+
72+
This helps a mentor while adding representation comments.
73+
74+
### Example
75+
76+
```markdown
77+
# Representations
78+
79+
The representer applies the following normalizations:
80+
81+
- All comments are removed
82+
- All import declarations are removed
83+
- The code is formatted
84+
- Identifiers are normalized to a placeholder value
85+
```
86+
87+
If your track has a `docs/REPRESENTER_NORMALIZATIONS.md` file, we recommend to link the normalizations to the corresponding section in that file.
88+
6189
## File: `tests.md`
6290

6391
**Purpose:** Contains track-specific instructions on how to run the tests

0 commit comments

Comments
 (0)