Skip to content

Commit 13ab4c0

Browse files
Move style guide to standards documents (exercism#73)
1 parent 16bb105 commit 13ab4c0

File tree

4 files changed

+105
-110
lines changed

4 files changed

+105
-110
lines changed

anatomy/tracks/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Some parts of the track can be displayed in [widgets](./widgets.md), such as [co
3535

3636
## Style guide
3737

38-
The [style guide](./style-guide.md) records how documents should be written and formatted.
38+
All documents should adhere to the [style guide](../../contributing/standards/style-guide.md). Markdown documents should also adhere to our [Markdown standards](../../contributing/standards/markdown.md).
3939

4040
## Example
4141

anatomy/tracks/style-guide.md

Lines changed: 0 additions & 103 deletions
This file was deleted.

contributing/standards/markdown.md

Lines changed: 94 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The following is the way that all Markdown files within Exercism should be structured.
44

5-
Some of the rules in this document are not yet implemented across all of Exercism.
5+
Some of the rules in this document are not yet implemented across all of Exercism.
66
We welcome PRs to fix them.
77
All rules are being added to our CI and linting tools, and should be adhered to for new changes.
88

@@ -14,13 +14,93 @@ All rules are being added to our CI and linting tools, and should be adhered to
1414
- No heading may decend a level greater than one below the previous (e.g. `##` may only be followed by `###`, not `####`).
1515
- Beyond the single level-1 (`#`) heading, only level-2 (`##`), level-3 (`###`) and level-4 (`####`) headings may be used.
1616

17+
## Links
18+
19+
Please use [reference links](https://spec.commonmark.org/0.29/#reference-link), which are defined at the bottom of the Markdown file, mapped to a reference slug, and referenced by that slug in the text.
20+
21+
This method makes maintenance easier, since link only have to be updated in a single location.
22+
23+
Example:
24+
25+
```
26+
I have a paragraph of text that links to the same page twice.
27+
28+
The [first link][indirect-reference] in one sentence.
29+
30+
Then, another sentence with the [link repeated][indirect-reference].
31+
32+
[indirect-reference]: https://example.com/link-to-page
33+
```
34+
35+
Links should always have anchor text, instead of putting the URL itself into the text. For example, the following does not use anchor text, and is harder to read.
36+
37+
```
38+
If you want some more information, please visit https://google.com.
39+
```
40+
41+
Using anchor text and linking it is easier to understand and contextualize.
42+
43+
```
44+
If you want some more information, [Google][google-search-link] is a useful resource.
45+
46+
[google-link]: https://google.com
47+
```
48+
49+
Which renders as, "If you want some more information, [Google](https://google.com)".
50+
51+
## Code
52+
53+
Whenever one refers to code elements (e.g. functions or keywords), the code should be wrapped in backticks:
54+
55+
```
56+
- The `printf()` function writes to the console.
57+
```
58+
59+
Which renders as:
60+
61+
- The `printf()` function writes to the console.
62+
63+
More complex code (e.g. multiline code) should be wrapped in triple backticks. A [language identifier](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml) should be specified after the opening triple backticks to enable syntax highlighting:
64+
65+
````python
66+
```python
67+
# Define a variable
68+
album = "Abbey Road"
69+
```
70+
````
71+
72+
When possible, format code in a way that is most relevant to the environment it is being presented in. If available, please reference the docs for your language.
73+
74+
For example, Python has the REPL (read-eval-print loop), which allows a programmer to type code directly into a terminal. If a user was debugging some code, or running a function locally to test/observe how it works, they are more likely to use a REPL to do so, since it is more convenient to type interactively there. In this situation, we prefer formatting example code as if it was being typed into the REPL, with a leading `>>>`:
75+
76+
```python
77+
# This is the expected output a student would see while testing a function they wrote.
78+
>>> print(extract_message("[INFO] Logline message"))
79+
'Logline message'
80+
```
81+
82+
In other cases, it makes more sense to leave code formatted as if it was in a `.py` file. Here, the student benefits by being presented with something that mimics how they would write the code themselves.
83+
84+
```python
85+
# presenting how functions are defined in Python:
86+
def sample_func(argument1):
87+
pass
88+
```
89+
90+
A quick way to distinguish between the two cases when it's unclear - if this is code the student can run in a terminal, format it that way. If it's code that Exercism might run (in tests, library code the student will write, etc), default to formatting it as runnable code.
91+
92+
## Language Code Style
93+
94+
Please consult each language's docs folder for more information on the preferred style conventions for that language. All exercises of a language should use a consistent coding style.
95+
1796
## Layout
1897

1998
### One sentence per line
2099

21100
Paragraphs should be laid at using one sentence per line. The [Ascii Doctor docs][asciidoctor] explain the logic of this clearly.
22101

23102
For example, a single paragraph should be laid out as follows:
103+
24104
```
25105
Exercism has been designed, engineered and built by thousands of very talented individuals.
26106
Nearly everything with Exercism has been debated, discussed and rewritten many times.
@@ -35,12 +115,24 @@ Exercism is a very intentional product - things are there because they've been d
35115
## Linters
36116

37117
There are various rules you can use to configure linters to meet this spec:
118+
38119
- Enable [MD001](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md001---header-levels-should-only-increment-by-one-level-at-a-time)
39120
- Enable [MD002](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md002---first-header-should-be-a-top-level-header)
40121
- Use `atx` for [MD003](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md003---header-style)
41122
- Disable [MD013](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md013---line-length)
42123
- Disable [MD033](https://github.com/markdownlint/markdownlint/blob/master/docs/RULES.md#md033---inline-html)
43124

125+
## Auto formatting
126+
127+
Some repositories use [prettier](https://prettier.io/) to ensure that all Markdown is formatted consistently. This can result in the following benefits:
128+
129+
- No formatting discussions.
130+
- Great editor/IDE integration so files can be formatted on save.
131+
- Easy to add CI checks for formatting.
132+
- Easy to automatically format files using a script.
133+
134+
All the above can greatly help reduce churn in reviews, whch is frustrating for both the reviewer and the reviewee.
135+
44136
---
45137

46-
[asciidoctor]: https://asciidoctor.org/docs/asciidoc-recommended-practices/#one-sentence-per-line
138+
[asciidoctor]: https://asciidoctor.org/docs/asciidoc-recommended-practices/#one-sentence-per-line

contributing/standards/style-guide.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,48 @@ This document acts as a Style Guide for the language and wording used in exercis
44

55
## Application
66

7-
These rules should be followed in all exercises.
7+
These rules should be followed in all exercises.
88
Existing descriptions and test-cases can be updated to adhere to them without requiring "replacement" test cases.
99

1010
### Consistency within an exercise.
1111

12-
There are some terms that have multiple valid spellings (e.g. "lower case" vs "lowercase").
12+
There are some terms that have multiple valid spellings (e.g. "lower case" vs "lowercase").
1313
Where a consistent style has not been agreed within this document, these must be consistent within an exercise.
1414

1515
### Exceptions
1616

17-
Exercises may vary from these rules if there is general consensus across maintainers that this is reasonable.
17+
Exercises may vary from these rules if there is general consensus across maintainers that this is reasonable.
1818
For example, an exercise about converting between different units might choose not to use SI measurements.
1919

2020
## Language
2121

22-
All content should be written in US English. In the future other translations may occur, but the "official" Exercism language is US English.
22+
All content should be written in US English, which differs from UK English in a [variety of ways](https://en.wikipedia.org/wiki/Comparison_of_American_and_British_English). In the future other translations may occur, but the "official" Exercism language is US English.
2323

2424
### Measurements
25+
2526
All units of measurement must be [SI](https://en.wikipedia.org/wiki/International_System_of_Units) or [SI-derived](https://en.wikipedia.org/wiki/SI_derived_unit) units.
2627

2728
### Abbreviations, acronyms and initialisms
2829

2930
Abbreviations, acronyms and initialisms are often more difficult to understand than other phrasing options, and can alienate people trying to learn.
3031

3132
Many abbreviations are jargon. Avoid jargon where possible by using alternative language. Don't use abbreviations unless either:
33+
3234
- The abbreviated term is better known than the unabbreviated term
3335
- The text will be excessively verbose without abbreviation
3436

3537
When using abbreviations always explain what the term means on its first use. This will often, but not always, include expanding the abbreviation. It will rarely be sufficient to only expand the abbreviation.
3638

3739
Here are some example rules:
40+
3841
- Prefer "if I recall correctly" to "IIRC"
3942
- Prefer "as far as I know" to "AFAIK"
4043
- Prefer "queue" to "FIFO" and "stack" to "FILO"
4144
- Instead of describing an interface as "RESTful", describe it's specific properties
4245
- If you must use "CRUD", explain that it stands for Create, Read, Update, Delete and that these are the basic actions in standard databases
4346

4447
An some examples of good usage:
48+
4549
- "HyperText Markup Language (HTML) is the language used to describe document structure and content on the web" _(expanded and explained)_
4650
- "DNA, a set of chemical instructions that influence how our bodies are constructed" _(DNA is not expanded because "deoxyribonucleic acid" is unlikely to help explain what DNA is to our audience)_
4751
- "NASA, the United States' space agency, launched the Mariner 2 space probe in..." _(NASA is not expanded because the "National Aerospace and Space Administration" is much better known by its acronym than by its expanded name)_
@@ -56,6 +60,7 @@ Use the "[Oxford Comma](https://en.wikipedia.org/wiki/Serial_comma)" (also known
5660
#### Exceptions
5761

5862
Some abbreviations are considered common, useful, and non-technical enough that we have decided to permit them:
63+
5964
- `e.g.` or `eg`
6065
- `i.e.` or `ie`
6166
- `etc.` or `etc`
@@ -70,6 +75,7 @@ Contractions (e.g. "won't", "I'm", "that's") should be used sparingly if at all
7075
In any place that mathematical terms are used they should be explained or substituted out for terms that require less domain knowledge.
7176

7277
Examples:
78+
7379
- Rather than using "natural numbers", we should use "positive whole numbers".
7480
- If we want to use the phrase "rational numbers", it must be explained in the introduction to the exercise.
7581
- Rather than using the word range (which can have different meanings in different contexts) use "x < ? < y (greater than x and less than y)".

0 commit comments

Comments
 (0)