Skip to content

Commit c188670

Browse files
committed
Merge remote-tracking branch 'upstream/main' into snippets-c++
2 parents d76dbfd + ef1eb88 commit c188670

File tree

257 files changed

+3572
-1939
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+3572
-1939
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
text eol=lf

.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

.github/workflows/check-snippets.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@ jobs:
99
check-snippets:
1010
runs-on: ubuntu-latest
1111

12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
1216
steps:
1317
- name: Checkout repository
14-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1519

1620
- name: Set up Node.js
17-
uses: actions/setup-node@v3
21+
uses: actions/setup-node@v4
1822
with:
19-
node-version: "16"
23+
node-version: 22
2024

2125
- name: Check if snippets are formated correctly
22-
run: |
23-
node utils/checkSnippetFormatting.js # Run the script located in the utils/ folder
26+
uses: int128/comment-action@v1
27+
with:
28+
run: node utils/checkSnippetFormatting.js # Run the script located in the utils/ folder
29+
post-on-failure: |
30+
## :x: Snippet Format Error
31+
${run.output}

.github/workflows/consolidate-snippets.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ jobs:
1414

1515
steps:
1616
- name: Checkout repository
17-
uses: actions/checkout@v3
17+
uses: actions/checkout@v4
1818

1919
- name: Set up Node.js
20-
uses: actions/setup-node@v3
20+
uses: actions/setup-node@v4
2121
with:
22-
node-version: "16"
22+
node-version: 22
2323

2424
- name: Install dependencies
2525
run: |
@@ -34,5 +34,6 @@ jobs:
3434
git config --global user.name "GitHub Action"
3535
git config --global user.email "[email protected]"
3636
git add public/consolidated/*
37-
git commit -m "Update consolidated snippets"
37+
git add public/icons/*
38+
git diff-index --quiet HEAD || git commit -m "Update consolidated snippets"
3839
git push
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Pre-commit checks
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- '**'
7+
8+
jobs:
9+
pre-commit-checks:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v4
15+
16+
- name: Set up Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 22
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Run cspell
25+
run: npm run cspell
26+
27+
- name: Run lint
28+
run: npm run lint
29+
30+
- name: Run build
31+
run: npm run build

.husky/pre-commit

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
npm run cspell
12
npm run lint
23
npm run build

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
node_modules
22
dist
3+
snippets
4+
public
35
.vite
46
coverage
57
package-lock.json

CODE_OF_CONDUCT.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
## QuickSnip Code of Conduct
2+
3+
QuickSnip is a welcoming and collaborative community for developers to organize, share, and discover code snippets. By participating in QuickSnip, you agree to uphold this code of conduct to maintain a friendly and inclusive environment.
4+
5+
### Short Version
6+
7+
- Be respectful to everyone in the community.
8+
- Avoid harassment, trolling, or spamming.
9+
- Ensure QuickSnip remains a safe and productive space for all.
10+
- Report any inappropriate behavior to [me](mailto:[email protected]), the owner of QuickSnip, or our [Discord team](https://discord.gg/UtJJcnsN).
11+
- No unauthorized bots without prior permission.
12+
13+
---
14+
15+
### Long Version
16+
17+
#### Harassment-Free Environment
18+
19+
We are committed to providing a harassment-free experience for everyone, regardless of gender, gender identity and expression, age, sexual orientation, disability, physical appearance, body size, race, ethnicity, national origin, or religion (or lack thereof). Examples of unacceptable behavior include:
20+
21+
- **Harassment:** Includes sexual language or imagery, deliberate intimidation, stalking, name-calling, unwelcome attention, libel, and malicious hacking or social engineering.
22+
- **Trolling:** Posting inflammatory comments to provoke an emotional response or disrupt discussions.
23+
- **Spamming:** Posting off-topic messages, promoting unrelated products, soliciting donations, advertising jobs or gigs, or flooding discussions with files or text.
24+
25+
#### Reporting Issues
26+
27+
If you experience or witness harassment, trolling, spamming, or any other inappropriate behavior, please report it to [me](mailto:[email protected]), the owner of QuickSnip, or our QuickSnip [Discord team](https://discord.gg/UtJJcnsN). Include details like screenshots and URLs, if possible, to help us address the issue effectively.
28+
29+
I, or the QuickSnip team will review all reports and take appropriate actions, which may include warnings, temporary bans, or permanent removal from the community.
30+
31+
#### Respectful Use of Bots
32+
33+
No bots are allowed within the QuickSnip community without prior written permission from the QuickSnip team. Unauthorized bots will be removed.
34+
35+
#### Final Notes
36+
37+
This code of conduct is inspired by [FreeCodeCamp’s approach](https://www.freecodecamp.org/news/code-of-conduct), emphasizing clarity and friendliness. Let’s work together to make QuickSnip a supportive and productive space for all developers!
38+

CONTRIBUTING.md

Lines changed: 78 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,76 +18,129 @@ If you have a feature request or want to fix a bug, feel free to:
1818

1919
---
2020

21+
## Snippets Guidelines
22+
23+
### Snippet Tags
24+
25+
Tags must describe the snippet with simple word. \
26+
For example a snippet that capitalize a word would have `string` and `capitalize` as tags. \
27+
**! Do not add the language you are using as a tag, nor some generic keyword like `utility` !**
28+
29+
### Snippet Format
30+
31+
**All** snippets should follow the following structure:
32+
- A `code` segment, containing a function with the actual snippet functionnality
33+
- An `example` segement, containing one or more examples of use
34+
35+
Example in javascript:
36+
```js
37+
function example(x) {
38+
return x * 2;
39+
}
40+
41+
// Usage:
42+
example(5) // Returns: 10
43+
```
44+
If your function doesn't return anything just show how to use it. \
45+
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.
46+
47+
### Snippet boundaries
48+
49+
To **check if your snippet will not get refused** ask yourself those questions:
50+
- **Does the standard library of my language provide an easy way of doing this ?**
51+
- **Does that snippet have a real, and practical use case ?**
52+
- **Could it be split into separate parts to be better understood ?**
53+
54+
If one of question is true, then your snippet will most likely get refused !
55+
56+
---
57+
2158
## Adding Snippets
2259

2360
### Adding a New Snippet
2461

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

27-
1. **Navigate to the relevant folder:**
64+
2. **Navigate to the relevant folder:**
2865

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

32-
2. **Choose the correct category:**
69+
3. **Choose the correct category:**
3370

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

37-
3. **Create a markdown file:**
74+
4. **Create a markdown file:**
3875

3976
- Create a new file with a `.md` extension.
4077
- Name the file appropriately, keeping it descriptive and concise.
4178

42-
4. **Add your snippet:**
79+
5. **Add your snippet:**
4380

4481
- Use the following format to structure your snippet:
4582

46-
```md
83+
````md
4784
---
4885
title: Name of the snippet
4986
description: A short explanation of what the snippet does
5087
tags: tag1, tag2, tag3
5188
author: your-github-username
5289
---
5390

91+
```lang
5492
// Your code here
5593
```
94+
````
5695

5796
Here’s an example for JavaScript:
5897

59-
```
98+
````md
6099
---
61100
title: Format Date
62101
description: Formats a date in 'YYYY-MM-DD' format.
63102
author: dostonnabotov
64-
tags: javascript,date,format,utility
103+
tags: javascript,date,format
65104
---
66105

106+
```js
67107
const formatDate = (date) => date.toISOString().split('T')[0];
68108

69109
// Usage:
70110
console.log(formatDate(new Date())); // Output: '2024-12-10'
71111
```
112+
````
72113

73-
5. **Use syntax highlighting:**
114+
6. **Use syntax highlighting:**
74115
- Enclose your code with triple backticks (```).
75116
- Specify the language after the first set of backticks for syntax highlighting.
76117

77-
![snippet code example in markdown file](https://github.com/user-attachments/assets/be650cfe-fd17-49e7-ae82-e1c88e30d4c9)
118+
7. **Test your snippet:**
119+
- Ensure your code runs as expected. \
120+
To test that your snippets are formatted correctly use the `snippets:check` script:
121+
```
122+
$ npm run snippets:check
123+
```
124+
It will return nothing if they are well formatted, otherwise it will tell you what the error is.
78125
79-
6. **Test your snippet:**
80-
- Ensure your code runs as expected.
126+
---
127+
To preview the snippets, you need to consolidate them, use the `snippets:consolidate` script:
128+
```
129+
$ npm run snippets:consolidate
130+
```
131+
It will update the snippets in the `/public` folder, making them available to the frontend.
81132
82-
Expected structure:
133+
Expected file structure:
83134
84-
```txt
85-
snippets
135+
```md
136+
/snippets
86137
|- language
87-
|- category
138+
|- category-name
88139
|- your-snippet-here.md
89140
```
90141

142+
> Please do **NOT** add or edit anything in `/public` folder. It will be used for consolidating snippets.
143+
91144
### Editing a Existing Snippet
92145

93146
If you’d like to refine or improve an existing snippet:
@@ -96,7 +149,7 @@ If you’d like to refine or improve an existing snippet:
96149

97150
- Include your GitHub username under the `contributors` field in the metadata section.
98151

99-
```md
152+
````md
100153
---
101154
title: Name of the snippet
102155
description: A short explanation of what the snippet does
@@ -105,8 +158,10 @@ author: original-author
105158
contributors: your-github-username
106159
---
107160

161+
```
108162
Updated code here
109163
```
164+
````
110165

111166
2. **Credit all contributors:**
112167

@@ -118,9 +173,9 @@ contributors: contributor1, contributor2, your-github-username
118173

119174
3. **Document changes:**
120175

121-
Clearly indicate what you updated and why in your pull request description.
176+
- Clearly indicate what you updated and why in your pull request description.
122177

123-
We want to make sure that original author and contributor(s) are credited for their work.
178+
> We want to make sure that original author and contributor(s) are credited for their work.
124179
125180

126181
### Adding a New Category
@@ -141,10 +196,10 @@ Example structure:
141196

142197
```md
143198
/snippets
144-
|_ python
145-
|_ file-handling
146-
|_ list-manipulation
147-
|_ ....
199+
|- python
200+
|- file-handling
201+
|- list-manipulation
202+
|- ....
148203
```
149204

150205
### Adding a New Language

0 commit comments

Comments
 (0)