Skip to content

Commit 37b88ec

Browse files
committed
feat(readme): finish generator
1 parent aa0e4bc commit 37b88ec

File tree

12 files changed

+836
-254
lines changed

12 files changed

+836
-254
lines changed

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
root = true
2+
3+
[*.py]
4+
indent_style = space
5+
indent_size = 4

CONTRIBUTING.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Contributing to the Code of Conduct
2+
3+
> [!NOTE]
4+
> This is a living document, and will grow with time. Please be aware
5+
> that nothing in this document will last forever. Check back whenever
6+
> you want to contribute.
7+
8+
## How the Code of Conduct is created
9+
10+
Rules are made from sections, these sections are in a
11+
`section{index}.toml` that you can find in `code_of_conduct/sections/`.
12+
This is done to standardise the code of conduct format, as well as
13+
making it portable in case it were to be used in our own Tux for
14+
example. There are some quirks with the format due to using Markdown
15+
which will be described in this document.
16+
17+
## How to add new rules
18+
19+
A rule can be added by opening the section you want to add a new rule
20+
to (read [here](#how-to-add-a-new-section) if you want to make a new
21+
section) and add something of the following format:
22+
23+
```toml
24+
[[rule]]
25+
# EXPECTED TO EXIST
26+
title = "My new rule"
27+
description = """
28+
I am describing my new rule.
29+
"""
30+
31+
# OPTIONAL
32+
[[rule.expectations]]
33+
expectation = "Mild"
34+
description = """
35+
Hello world! This is your punishment for doing something bad! Feel the
36+
wrath of the sword!
37+
"""
38+
39+
[[rule.glossary]]
40+
word = "describing"
41+
meaning = "talking about"
42+
```
43+
44+
You are expected to keep every line around 72 characters long for
45+
readability purposes. You also should aim to use listing less as
46+
paragraphs tend to work just about as well without being unmemorable.
47+
Make sure the quotes and the text are separate from each other for
48+
readability.
49+
50+
## How to add a new section
51+
52+
To create a new section, you can create a new file in
53+
`code_of_conduct/sections`. Preferably, you can name it
54+
`section{index}.toml` for consistency. You must write it out like below:
55+
```toml
56+
title = "My section"
57+
58+
[[rule]]
59+
title = "My rule"
60+
description = "Description of my rule."
61+
62+
# fill in the rest
63+
```
64+
65+
## What to do after you made your changes
66+
67+
CI is not setup for this yet. As such, you will have to set up a
68+
development environment for Python **3.11 and higher** to regenerate
69+
the README file. This isn't an annoying process but we will eventually
70+
add CI to make this step irrelevant.
71+
72+
### Setting up your .venv
73+
74+
Before setting up `.venv`, please make sure you are running version
75+
3.11 or above by running `python --version`. After checking and
76+
verifying that you have a high enough version, you can setup a .venv by
77+
running this command in your shell:
78+
```
79+
$ python -m venv .venv
80+
```
81+
This will create a .venv directory which will contain a local
82+
development environment you can access by sourcing `.venv/bin/activate`.
83+
You will want to check for an activation script that supports your shell
84+
however. If you are on PowerShell, you will need to source
85+
`.venv/bin/activate.ps1`, fish users must source `activate.fish` and so
86+
on with other shells.
87+
88+
Once you are in your .venv environment, make sure pip is up to date by
89+
running this command:
90+
```
91+
pip install --upgrade pip
92+
```
93+
This is to prevent any vulnerabilities when installing software via pip,
94+
and therefore it will be safer. We will now need `poetry` as pip doesn't
95+
have a stable lockfile format as of now.
96+
97+
To install `poetry`, you must run this command:
98+
```
99+
$ pip install poetry
100+
```
101+
You will then be able to use poetry to install our package as well as
102+
any dependencies needed for said package. This can be done by running
103+
the following command:
104+
```
105+
$ poetry install
106+
```
107+
108+
You can then generate the README by running the following command:
109+
```
110+
$ python -m code_of_conduct
111+
```
112+
The README will then be modified to include your changed you made. You
113+
can now commit your work and make a pull request.

README.md

Lines changed: 435 additions & 242 deletions
Large diffs are not rendered by default.

code_of_conduct/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import sys
2+
3+
if __name__ == "__main__":
4+
sys.exit(main())

code_of_conduct/__main__.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
import sys
3+
import tomllib
4+
5+
from jinja2 import Environment, PackageLoader, select_autoescape
6+
7+
from pathlib import Path
8+
9+
10+
def read_file(fp: Path) -> str:
11+
with fp.open("r") as f:
12+
return f.read()
13+
14+
15+
def main() -> None:
16+
sections: list[map] = []
17+
env = Environment(
18+
loader=PackageLoader("code_of_conduct"),
19+
autoescape=select_autoescape(),
20+
)
21+
22+
for dirpath, _, filenames in os.walk("./code_of_conduct/sections/"):
23+
filenames.sort()
24+
for filename in filenames:
25+
output = read_file(Path(dirpath) / Path(filename))
26+
sections.append(tomllib.loads(output))
27+
28+
template = env.get_template("README.md.jinja")
29+
30+
with Path("README.md").open("w") as f:
31+
print(template.render(sections=sections), file=f)
32+
33+
34+
if __name__ == "__main__":
35+
sys.exit(main())

code-of-conduct/sections/1.toml renamed to code_of_conduct/sections/section1.toml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,11 @@ and warned.
2424

2525
[[rule.expectations]]
2626
expectation = "Medium"
27-
description = """
28-
Warns, tickets, and timeouts ranging from 1hr-12 hours.
29-
"""
27+
description = "Warns, tickets, and timeouts ranging from 1hr-12 hours."
3028

3129
[[rule.expectations]]
3230
expectation = "Severe"
33-
description = """
34-
Bans are to be expected at this stage.
35-
"""
31+
description = "Bans are to be expected at this stage."
3632

3733
[[rule.glossary]]
3834
word = "Content"
@@ -108,19 +104,25 @@ violent incidents, supporting those who perpetrate violent acts, or
108104
promoting conspiracy theories that may incite violence towards others,
109105
are all prohibited.
110106
111-
Do not share media depicting harmful or offensive language and/or content,
112-
this can include or is not limited to; Offensive jokes or comments with the
113-
intention of causing harm or "drama". This may also include language that
114-
promotes exclusion or marginalization.
107+
Do not share media depicting harmful or offensive language and/or
108+
content, this can include or is not limited to; Offensive jokes or
109+
comments with the intention of causing harm or "drama". This may also
110+
include language that promotes exclusion or marginalization.
115111
"""
116112

117113
[[rule.expectations]]
118114
expectation = "Mild"
119-
description = "Pulling Members into tickets and requesting that they stop this behavior"
115+
description = """
116+
Pulling Members into tickets and requesting that they
117+
stop this behavior
118+
"""
120119

121120
[[rule.expectations]]
122121
expectation = "Medium"
123-
description = "Reprimand within tickets and timeouts ranging from 1hr-12hr"
122+
description = """
123+
Reprimand within tickets and timeouts ranging from
124+
1hr-12hr
125+
"""
124126

125127
[[rule.expectations]]
126128
expectation = "Severe"

code-of-conduct/sections/2.toml renamed to code_of_conduct/sections/section2.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ description = """
1313
Members will be kindly asked in the chat they are spreading non-English
1414
messages to keep it to English
1515
"""
16+
17+
[[rule.expectations]]
1618
expectation = "Medium"
1719
description = """
1820
Repeated offenses may result in Members being pulled into tickets
1921
"""
22+
23+
[[rule.expectations]]
2024
expectation = "Severe"
2125
description = """
2226
If a Member is unwilling to comply, Moderators may act as they see fit.
@@ -36,16 +40,21 @@ This includes "brainrot" which are words or phrases with no substantial
3640
value as well as animal sounds or incoherent strings of letters.
3741
"""
3842

43+
[[rule.expectations]]
3944
expectation = "Mild"
4045
description = """
4146
Members will be kindly asked in the chat to not post
4247
low-effort/low-quality content or bypass automod
4348
"""
49+
50+
[[rule.expectations]]
4451
expectation = "Medium"
4552
description = """
4653
Repeated offenses may result in Members being timed out for a period of
4754
time at the moderators discretion
4855
"""
56+
57+
[[rule.expectations]]
4958
expectation = "Severe"
5059
description = """
5160
If a Member is unwilling to comply, they will be ticketed and warned
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<!-- !!! PLEASE CHECK CONTRIBUTING.MD BEFORE ADDING TO THE CODE OF CONDUCT !!! -->
2+
![Discord Banner 1](https://i.imgur.com/6kxPNlG.png)
3+
<p align="center">
4+
<img src="https://discordapp.com/api/guilds/1172245377395728464/widget.png?style=shield" alt="Discord Shield">
5+
<img src="https://dcbadge.vercel.app/api/server/linux?style=flat&theme=clean" alt="Discord Banner 2">
6+
</p>
7+
8+
9+
<h1 align="center">All Things Linux</h1>
10+
11+
Welcome to "All Things Linux," a vibrant and inclusive community dedicated to exploring the vast and varied world of Linux. Our mission is to provide a friendly and supportive environment where enthusiasts, professionals, hobbyists, and newcomers alike can share their passion, knowledge, and experiences with Linux. Whether it's discussing the newest distributions, offering tips and tricks, troubleshooting, or celebrating the open-source spirit, "All Things Linux" is a place for collaboration, learning, and fostering a deeper appreciation for an operating system that powers much of the digital world. Join us as we navigate the limitless possibilities of Linux together!
12+
13+
---
14+
15+
# Code of Conduct
16+
17+
**Table of Contents**
18+
19+
- [Preface](#preface)
20+
- [Discord Community Guidelines and Terms of Service](#discord-community-guidelines-and-terms-of-service)
21+
{% for section in sections %}- [Section {{ loop.index }}. {{ section.title }}](#section-{{ loop.index }}-{{ section.title | lower | replace(' ', '-') }})
22+
{% set section_loop = loop %}{% for rule in section.rule %} - [{{ section_loop.index }}.{{ loop.index }}. {{ rule.title }}](#{{section_loop.index}}{{loop.index}}-{{ rule.title | lower | replace(' ', '-') | replace(':', '') }})
23+
{% endfor %}{% endfor %}
24+
25+
## Preface
26+
27+
### Discord Community Guidelines and Terms of Service
28+
29+
Your presence in this server implies accepting Discord’s Community Guidelines and Terms of Service, including all further changes. These changes might be done at any time with or without notice, it is your responsibility to consistently review and follow them.
30+
31+
- [Discord Community Guidelines](https://discord.com/guidelines)
32+
- [Discord Terms of Service](https://discord.com/terms)
33+
34+
{% for section in sections %}## Section {{ loop.index }}. {{ section.title }}
35+
{% set section_loop = loop %}
36+
{% for rule in section.rule %}
37+
### {{ section_loop.index }}.{{ loop.index }}. {{ rule.title }}
38+
{{ rule.description }}
39+
{% if rule.expectations %}
40+
#### Examples of moderation expectations
41+
42+
| Expectation | Description |
43+
| --- | --- |
44+
{% for expectation in rule.expectations %}| {{ expectation.expectation}} | {{ expectation.description | replace('\n', ' ') }} |
45+
{% endfor %}
46+
{% endif %}
47+
{% if rule.glossary %}
48+
#### Glossary
49+
50+
| Word | Meaning |
51+
| --- | --- |
52+
{% for word in rule.glossary %}| {{ word.word }} | {{ word.meaning | replace('\n', ' ') }} |
53+
{% endfor %}
54+
{% endif %}
55+
{% endfor %}
56+
{% endfor %}
57+
58+
## Notice
59+
60+
Please note that this article cannot capture all rules and that each situation needs to be assessed individually. Attempting to exploit any "loopholes" within these guidelines is strictly forbidden.
61+
62+
These guidelines are ever-evolving, responding to varied circumstances. Hence, we might take necessary action against members or content that contradicts the core intent of these rules, even if it is not directly mentioned in the current version.
63+
64+
Moderator actions may cite rules from this document. Please be aware that section numbers may change over time and may not be the same when the action was issued. Sections referenced do not imply their respective subsections (e.g. citing 1.2 does not imply 1.2.c).
65+
66+
We aim to keep you updated whenever these guidelines get revised. However, the responsibility lies with you to upkeep the essence of these rules: to maintain the safety of Discord and uphold its inclusivity. Stay informed about server announcements and polls which might induce changes to the rules. We appreciate your contribution in this regard.
67+
68+
Above all, exercise good judgment and common sense.
69+
70+
## Contributors
71+
72+
<sub>Made with [contrib.rocks](https://contrib.rocks).</sub>
73+
74+
[![Contributors](https://contrib.rocks/image?repo=allthingslinux/code-of-conduct)](https://github.com/allthingslinux/code-of-conduct/graphs/contributors)
75+
76+
## License
77+
78+
This work is licensed under the Creative Commons Attribution 4.0 International License.
79+
To view a copy of this license, visit https://creativecommons.org/licenses/by/4.0/
80+
81+
Creative Commons Attribution 4.0 International
82+
© 2025 All Things Linux

0 commit comments

Comments
 (0)