Skip to content

Commit 95ef30f

Browse files
Adding new snippet guidelines
1 parent b5fd7c7 commit 95ef30f

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

.github/pull_request_template.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
<!-- **ANY PULL REQUEST NOT FOLLOWING GUIDELINES OR NOT INCLUDING A DESCRIPTION WILL BE CLOSED !** -->
2+
13
# Description
24

3-
<!-- Please include a summary of your changes. -->
5+
<!-- Include a summary of your changes. -->
46

57
## Type of Change
68

CONTRIBUTING.md

Lines changed: 38 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,28 +18,59 @@ If you have a feature request or want to fix a bug, feel free to:
1818

1919
---
2020

21+
## Snippets Guidelines
22+
23+
### Snippet Format
24+
25+
**All** snippets should follow the following structure:
26+
- A `code` segment, containing a function with the actual snippet functionnality
27+
- An `example` segement, containing one or more examples of use
28+
29+
Example in javascript:
30+
```js
31+
function example(x) {
32+
return x * 2;
33+
}
34+
35+
// Usage:
36+
example(5) // Returns: 10
37+
```
38+
If your function doesn't return anything just show how to use it. \
39+
If the result of your function is too complicated to be expressed in a single comment, your snippet is probably too complex to begin with.
40+
41+
### Snippet boundaries
42+
43+
To **check if your snippet will not get refused** ask yourself those questions:
44+
- **Does the standard library of my language provide an easy way of doing this ?**
45+
- **Does that snippet have a real, and practical use case ?**
46+
- **Could it be split into separate parts to be better understood ?**
47+
48+
If one of question is true, then your snippet will most likely get refused !
49+
50+
---
51+
2152
## Adding Snippets
2253

2354
### Adding a New Snippet
2455

25-
To add a new code snippet:
56+
1. **Ensure your snippet match [guidelines](#snippets-guidelines)**
2657

27-
1. **Navigate to the relevant folder:**
58+
2. **Navigate to the relevant folder:**
2859

2960
- Go to the `/snippets` folder in the root directory.
3061
- Locate the folder for the programming language of your snippet, such as `javascript` or `python`.
3162

32-
2. **Choose the correct category:**
63+
3. **Choose the correct category:**
3364

3465
- Within the language folder, find the relevant category folder for your snippet.
3566
- If no suitable category exists, refer to [Adding a New Category](#adding-a-new-category).
3667

37-
3. **Create a markdown file:**
68+
4. **Create a markdown file:**
3869

3970
- Create a new file with a `.md` extension.
4071
- Name the file appropriately, keeping it descriptive and concise.
4172

42-
4. **Add your snippet:**
73+
5. **Add your snippet:**
4374

4475
- Use the following format to structure your snippet:
4576

@@ -74,11 +105,11 @@ console.log(formatDate(new Date())); // Output: '2024-12-10'
74105
```
75106
````
76107

77-
5. **Use syntax highlighting:**
108+
6. **Use syntax highlighting:**
78109
- Enclose your code with triple backticks (```).
79110
- Specify the language after the first set of backticks for syntax highlighting.
80111

81-
6. **Test your snippet:**
112+
7. **Test your snippet:**
82113
- Ensure your code runs as expected. \
83114
To test that your snippets are formatted correctly use the `snippets:check` script:
84115
```

0 commit comments

Comments
 (0)