Skip to content

Commit 9986301

Browse files
authored
Update CONTRIBUTING.md
1 parent aeeac92 commit 9986301

File tree

1 file changed

+102
-126
lines changed

1 file changed

+102
-126
lines changed

CONTRIBUTING.md

Lines changed: 102 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -1,193 +1,169 @@
1-
---
2-
search:
3-
exclude: true
4-
---
51
# How to Contribute
62

7-
## General information
3+
Thank you for your interest in contributing to the cp-algorithms project! Whether you want to fix a typo, improve an article, or add new content, your help is welcome. All you need is a [GitHub account](https://github.com). Contributions are managed through our [GitHub repository](https://github.com/cp-algorithms/cp-algorithms), where you can directly submit changes or propose improvements.
84

9-
This website (articles, design, ...) is developed via [Github](https://github.com/cp-algorithms/cp-algorithms). And everybody is welcome to help out. All you need is a Github account.
5+
The pages are compiled and published at [https://cp-algorithms.com](https://cp-algorithms.com).
106

11-
Generated pages are compiled and published at [https://cp-algorithms.com](https://cp-algorithms.com).
7+
## Steps to Contribute
128

13-
In order to make contribution consider the following steps:
9+
Follow these steps to start contributing:
1410

15-
1. Go to an article that you want to change, and click the pencil icon :material-pencil: next to the article title.
16-
2. Fork the repository if requested.
17-
3. Modify the article.
18-
4. Use the [preview page](preview.md) to check if you are satisfied with the result.
19-
5. Make a commit by clicking the _Propose changes_ button.
20-
6. Create a pull-request by clicking the _Compare & pull request_ button.
21-
7. Somebody from the core team will look over the changes. This might take a few hours/days.
11+
1. **Find the article you want to improve**. Click the pencil icon (:material-pencil:) next to the article title.
12+
2. **Fork the repository** if prompted. This creates a copy of the repository in your GitHub account.
13+
3. **Make your changes** directly in the GitHub editor or clone the repository to work locally.
14+
4. **Preview your changes** using the [preview page](preview.md) to ensure they look correct.
15+
5. **Commit your changes** by clicking the _Propose changes_ button.
16+
6. **Create a Pull Request (PR)** by clicking _Compare & pull request_.
17+
7. **Review process**: Someone from the core team will review your changes. This may take a few hours to a few days.
2218

23-
In case you want to make some bigger changes, like adding a new article, or edit multiple files, you should fork the project in the traditional way, create a branch, modify the files in the Github UI or locally on your computer, and create a pull-request.
24-
If you are unfamiliar with the workflow, read [Step-by-step guide to contributing on GitHub](https://www.dataschool.io/how-to-contribute-on-github/).
19+
### Making Larger Changes
2520

26-
If you're making a new article or moving existing one to a different place, please make sure that your changes are reflected in
21+
If youre planning to make more significant changes, such as adding new articles or modifying multiple files:
2722

28-
- The list of all articles in [navigation.md](https://github.com/cp-algorithms/cp-algorithms/blob/main/src/navigation.md);
29-
- The list of new articles in [README.md](https://github.com/cp-algorithms/cp-algorithms/blob/main/README.md) (if it is a new article).
23+
- **Fork the project** using the traditional Git workflow (create a branch for your changes).
24+
- **Edit files locally or in the GitHub UI**.
25+
- **Submit a pull request** with your updates.
3026

31-
## Syntax
27+
For help with this workflow, check out this helpful guide: [Step-by-step guide to contributing on GitHub](https://www.dataschool.io/how-to-contribute-on-github/).
3228

33-
We use [Markdown](https://daringfireball.net/projects/markdown) for the articles, and use the [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) to render the Markdown articles into HTML.
29+
### Updating Indexes
3430

35-
For advanced Markdown features of Material for MkDocs see their [reference pages](https://squidfunk.github.io/mkdocs-material/reference/formatting), like:
31+
When you add new articles or reorganize existing ones, be sure to update the following files:
3632

37-
- [Math formulas with MathJax](https://squidfunk.github.io/mkdocs-material/reference/mathjax/#usage)
38-
Notice that you need to have an empty line before and after a `$$` math block.
39-
- [Code blocks](https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#usage) for code snippets.
40-
- [Admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/#usage) (e.g. to decor theorems, proofs, problem examples).
41-
- [Content tabs](https://squidfunk.github.io/mkdocs-material/reference/content-tabs/#usage) (e.g. for code examples in several languages).
42-
- [Data tables](https://squidfunk.github.io/mkdocs-material/reference/data-tables/#usage).
33+
- **[navigation.md](https://github.com/cp-algorithms/cp-algorithms/blob/main/src/navigation.md)**: Update the list of all articles.
34+
- **[README.md](https://github.com/cp-algorithms/cp-algorithms/blob/main/README.md)**: Add new articles to the main project overview.
4335

44-
However not everything of the features should be used, and some of the features are not enabled or require a paid subscription.
36+
## Article Syntax
4537

46-
By default the first header (`# header`) will be also the HTML title of the article. In case the header contains a math formula, you can define a different HTML title with:
38+
We use [Markdown](https://daringfireball.net/projects/markdown) to format articles. Articles are rendered using [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/), which provides a lot of flexibility. Here are some key features:
4739

48-
```markdown
49-
---
50-
tags:
51-
- ...
52-
title: Alternative HTML title
53-
---
54-
# Proof of $a^2 + b^2 = c^2$
40+
- **Math formulas**: Use [MathJax](https://squidfunk.github.io/mkdocs-material/reference/mathjax/#usage) for equations. Make sure to leave an empty line before and after any `$$` math blocks.
41+
- **Code blocks**: [Code blocks](https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#usage) are great for adding code snippets in articles.
42+
- **Admonitions**: Use [admonitions](https://squidfunk.github.io/mkdocs-material/reference/admonitions/#usage) for special content, such as theorems or examples.
43+
- **Tabs**: Organize content with [content tabs](https://squidfunk.github.io/mkdocs-material/reference/content-tabs/#usage).
44+
- **Tables**: Use [data tables](https://squidfunk.github.io/mkdocs-material/reference/data-tables/#usage) for organizing information.
5545

56-
remaining article
57-
```
46+
Some advanced features may not be enabled or require a paid subscription. Keep this in mind when experimenting with formatting.
5847

59-
### Redirects
48+
### Setting the HTML Title
6049

61-
Files should not be moved or renamed without making redirects. A redirect page should generally look as follows:
50+
By default, the first header (`# header`) of your article will be used as the HTML title. If your header contains a formula or complex text, you can manually set the title:
6251

63-
```md
64-
<meta http-equiv="refresh" content="0; url=https://cp-algorithms.com/<new section>/<new name>.html">
65-
# <Article name>
66-
Article was moved (renamed). <a href="<new section>/<new name>.html">new URL</a>.
52+
```markdown
53+
---
54+
title: Alternative HTML Title
55+
---
56+
# Proof of $a^2 + b^2 = c^2$
6757
```
6858

69-
### Linking to a section with anchors
59+
### Handling Redirects
7060

71-
Also it's kind of problematic when renaming a section of an article.
72-
The section title is used for linking.
73-
E.g. a section on the page `article.md` with
61+
If you move or rename an article, make sure to set up a redirect. A redirect file should look like this:
7462

7563
```md
76-
## Some title
64+
<meta http-equiv="refresh" content="0; url=https://cp-algorithms.com/<new-section>/<new-article>.html">
65+
# Article Name
66+
This article has been moved to a [new location](<new-section>/<new-article>.html).
7767
```
7868

79-
can be linked to with `/article.html#some-title`.
80-
If the title is changed, the link doesn't work any more, and this breaks links from other articles or other websites.
69+
### Maintaining Anchor Links
8170

82-
If you rename an article, insert an anchor so that the old link still works:
71+
If you rename a section, the link to that section might break. To avoid this, add an anchor manually:
8372

8473
```html
85-
<div id="some-title"></div>
74+
<div id="old-section-title"></div>
8675
```
8776

88-
### Tags
77+
This will allow existing links to continue working even after the section title is changed.
8978

90-
To distinguish original and translatory articles, they should be marked with corresponding tags. For original articles, it's
79+
### Article Tags
9180

92-
```md
93-
---
94-
tags:
95-
- Original
96-
---
97-
```
81+
We use tags to differentiate between original content and translated articles. Add the appropriate tag at the top of your article:
9882

99-
And for translated articles, it's
83+
- **For original articles**:
10084

101-
```md
102-
---
103-
tags:
104-
- Translated
105-
e_maxx_link: ...
106-
---
107-
```
108-
109-
Here, instead of `...` one should place the last part of the link to the original article. E.g. for [Euler function article](http://e-maxx.ru/algo/euler_function) it should be
85+
```md
86+
---
87+
tags:
88+
- Original
89+
---
90+
```
11091

92+
- **For translated articles**:
11193

112-
```md
113-
---
114-
tags:
115-
- Translated
116-
e_maxx_link: euler_function
117-
---
118-
```
94+
```md
95+
---
96+
tags:
97+
- Translated
98+
e_maxx_link: <original-link>
99+
---
100+
```
119101

102+
Replace `<original-link>` with the URL to the source article.
120103

121-
## Some conventions
104+
## Conventions
122105

123-
* We have agreed as of issue [#83](https://github.com/cp-algorithms/cp-algorithms/issues/83) to express binomial coefficients with `\binom{n}{k}` instead of `C_n^k`. The first one renders as $\binom{n}{k}$ and is a more universal convention. The second would render as $C_n^k$.
106+
We follow certain conventions across the project. For example, we agreed to use the `\binom{n}{k}` notation for binomial coefficients instead of `C_n^k` as outlined in [issue #83](https://github.com/cp-algorithms/cp-algorithms/issues/83).
124107

125108
## Adding Problems
126109

127-
Try to add problems in ascending order of their difficulty. If you don't have enough time to do so, still add the problem. Lets hope that the next person will sort them accordingly.
110+
When adding problems, try to arrange them by difficulty. If you're unable to, don't worry—just add the problem, and someone else can adjust the order later.
128111

129-
## Local development
112+
## Local Development Setup
130113

131-
You can render the pages locally. All you need is Python, with the installed `mkdocs-material` package.
114+
You can preview changes locally before pushing them to GitHub. To do this:
132115

133-
```console
134-
$ git clone --recursive https://github.com/cp-algorithms/cp-algorithms.git && cd cp-algorithms
135-
$ scripts/install-mkdocs.sh # requires pip installation
136-
$ mkdocs serve
137-
```
116+
1. Clone the repository:
138117

139-
Note that some features are disabled by default for local builds.
118+
```console
119+
$ git clone --recursive https://github.com/cp-algorithms/cp-algorithms.git && cd cp-algorithms
120+
```
140121

141-
### Git revision date plugin
122+
2. Install dependencies and serve the site:
142123

143-
Disabled because it might produce errors when there are uncommitted changes in the working tree.
124+
```console
125+
$ scripts/install-mkdocs.sh # requires pip
126+
$ mkdocs serve
127+
```
144128

145-
To enable it, set the environment variable `MKDOCS_ENABLE_GIT_REVISION_DATE` to `True`:
129+
This will run the site locally so you can preview your changes. Note that some features are disabled in local builds.
146130

147-
```console
148-
$ export MKDOCS_ENABLE_GIT_REVISION_DATE=True
149-
```
131+
### Optional Plugins
150132

151-
### Git committers plugin
133+
- **Git Revision Date Plugin**: Disabled by default but can be enabled with:
152134

153-
Disabled because it takes a while to prepare and also requires Github personal access token to work with Github APIs.
135+
```console
136+
$ export MKDOCS_ENABLE_GIT_REVISION_DATE=True
137+
```
154138

155-
To enable it, set the environment variable `MKDOCS_ENABLE_GIT_COMMITTERS` to `True` and store your personal access token in the environment variable `MKDOCS_GIT_COMMITTERS_APIKEY`. You can generate the token [here](https://github.com/settings/tokens). Note that you only need the public access, so you shouldn't give the token any permissions.
139+
- **Git Committers Plugin**: Disabled by default, as it requires a GitHub personal access token. Enable it like this:
156140

157-
```console
158-
$ export MKDOCS_ENABLE_GIT_COMMITTERS=True
159-
$ export MKDOCS_GIT_COMMITTERS_APIKEY= # put your PAT here
160-
```
141+
```console
142+
$ export MKDOCS_ENABLE_GIT_COMMITTERS=True
143+
$ export MKDOCS_GIT_COMMITTERS_APIKEY=your_token_here
144+
```
145+
146+
You can generate your token [here](https://github.com/settings/tokens). Only public access permissions are needed.
161147

162-
## Tests
148+
## Testing Code Snippets
163149

164-
If your article involves code snippets, then it would be great you also contribute tests for them.
165-
This way we can make sure that the snippets actually work, and don't contain any bugs.
150+
If your article includes code snippets, it’s helpful to include tests to ensure that they run correctly.
166151

167-
Creating tests works like this:
168-
You have to name each snippet that you want to test in the markdown article:
152+
1. Name the code snippet:
169153

170154
```{.cpp file=snippet-name}
171-
// some code
155+
// code here
172156
```
173157

174-
In the directory `test` you find a script `extract_snippets.py` that you can run.
175-
This script extracts from every article all named snippets, and puts them in C++ header files: `snippet-name.h`
176-
In the folder you can create a cpp file, that includes these snippets headers, and tests their behaviour.
177-
If the snippets don't work, the test program should return 1 instead of 0.
158+
2. Run `extract_snippets.py` from the `test` directory to extract snippets into header files. Create a test file that includes these headers and checks their behavior.
178159

179-
You can run all tests with the script `test.sh`.
160+
3. You can run all tests with the `test.sh` script:
180161

181-
```console
182-
$ cd test
183-
$ ./test.sh
184-
Running test_aho_corasick.cpp - Passed in 635 ms
185-
Running test_balanced_brackets.cpp - Passed in 1390 ms
186-
Running test_burnside_tori.cpp - Passed in 378 ms
187-
...
188-
Running test_vertical_decomposition.cpp - Passed in 2397 ms
162+
```console
163+
$ cd test
164+
$ ./test.sh
165+
```
189166

190-
51 PASSED in 49.00 seconds
191-
```
167+
This script will run tests and display the results.
192168

193-
Also, every pull-request will automatically tested via [Github Actions](https://github.com/cp-algorithms/cp-algorithms/actions).
169+
Additionally, all pull requests will be automatically tested via [GitHub Actions](https://github.com/cp-algorithms/cp-algorithms/actions).

0 commit comments

Comments
 (0)