Skip to content

Commit 293115d

Browse files
authored
Merge pull request #5 from Tracks12/dev
doc(global): add contrubiting rules & code policy & add string docume…
2 parents 3996a00 + 7214d7e commit 293115d

File tree

3 files changed

+127
-5
lines changed

3 files changed

+127
-5
lines changed

CONTRIBUTING.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# CONTRIBUTING
2+
3+
## Coding Guidelines – toolsManager.py
4+
5+
This document defines the best development practices to follow when contributing to the project.
6+
7+
---
8+
9+
### 📁 Project Structure
10+
11+
- `main.py`: Main entry point.
12+
- `setup.py`: Installer for project-specific dependencies (`.rar` file).
13+
- `core/`: Contains the core modules (configuration, tool management, etc.).
14+
- `tools/`: Contains each tool, 1 `.py` file per tool.
15+
- `dev`: Continuous development branch.
16+
- `master`: Stable branch only.
17+
18+
---
19+
20+
### 🧱 Tool Writing Convention
21+
22+
- Each tool must:
23+
- be in a separate file under tools/,
24+
- have the same name as the class (in PascalCase),
25+
- inherit from core.tool.Tool,
26+
- must implement the run() method.
27+
28+
- Inheriting from Tool ensures consistent behavior and facilitates the overall management of tool modules.
29+
30+
#### ✅ Minimum valid example:
31+
32+
```python
33+
#!/usr/bin/env python3
34+
# -*- coding: utf-8 -*-
35+
36+
# tools/hello.py
37+
38+
from core.tool import Tool
39+
40+
class Hello(Tool):
41+
""" Say hello to the user
42+
"""
43+
44+
command = (("hello", "hel"), "(hel)lo")
45+
name = "Hello"
46+
path = __file__
47+
version = "0.1a"
48+
49+
def __init__(self, args: list[str]):
50+
super().__init__()
51+
52+
self._args = [
53+
(("-s", "--say-hello", "<user>"), "Say hello to the user")
54+
] + self._args[:]
55+
56+
self._execs = [
57+
lambda x:self._sayHello(x)
58+
] + self._execs[:]
59+
60+
self._run(args)
61+
62+
def _sayHello(user: str) -> bool:
63+
print(f"Hello {user} ! :D")
64+
return(True)
65+
```
66+
67+
#### 🚨 Non-compliant example:
68+
69+
```python
70+
# tools/hello.py
71+
72+
# ❌ Missing inheritance from Tool
73+
class Hello:
74+
def run(self):
75+
...
76+
```
77+
78+
## 🧪 Tests
79+
80+
- Tests are currently manual.
81+
- Adding a tool must be followed by a test in main.py or CLI.
82+
- Errors must be handled properly via try/except.
83+
84+
## 🧰 Coding Conventions
85+
86+
- Follow PEP8 conventions.
87+
- Strong typing is recommended (str, bool, etc.).
88+
- Each public method must have a clear docstring. - Preferred use of logging over print() (if applicable).
89+
90+
## 🔁 GitFlow
91+
92+
- Each new tool or feature must start from a dedicated branch from dev.
93+
- Branches must be named feature/tool-name or fix/issue.
94+
- Always rebase before merging to dev.
95+
- The master branch should only receive tested and stable code.
96+
- Each merge to master must be accompanied by a versioned tag (v1.2.0, etc.).
97+
98+
## 🚀 Release
99+
100+
- When merging to master, add a Git tag and a GitHub release if possible.
101+
- Releases must contain:
102+
- a brief changelog,
103+
- a list of added/modified tools,
104+
- a version number.
105+
106+
## 🤝 Contribution
107+
108+
- Forks, pull requests, and issues welcome.
109+
- Please respect the structure and naming, and keep the code readable.

core/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
Constants:
1111
- INFO: Contains application information such as version, git commit hash, and other metadata.
1212
- REGEX_ARGS: A regular expression pattern used to parse and split argument strings into lists.
13-
- UNITS: Units of measurement for bytes, including KB, MB, GB, TB, etc., to facilitate size conversions.
13+
- UNITS: Units of measurement for bytes, including b, Kb, Mb, Gb, Tb, etc., to facilitate size conversions.
1414
1515
"""
1616

@@ -28,9 +28,16 @@
2828
"name": "toolsManager.py",
2929
"version": "0.1",
3030
})
31+
""" Contains application information such as version, git commit hash, and other metadata
32+
"""
33+
34+
REGEX_ARGS = str("\\s(?=(?:[^\"'`]*[\"'`][^\"'`]*[\"'`])*[^\"'`]*$)")
35+
""" A regular expression pattern used to parse and split argument strings into lists
36+
"""
3137

32-
REGEX_ARGS = str("\\s(?=(?:[^\"'`]*[\"'`][^\"'`]*[\"'`])*[^\"'`]*$)")
33-
UNITS = tuple[str](("o", "ko", "Mo", "Go", "To"))
38+
UNITS = tuple[str](("b", "Kb", "Mb", "Gb", "Tb"))
39+
""" Units of measurement for bytes, including b, Kb, Mb, Gb, Tb, etc., to facilitate size conversions
40+
"""
3441

3542
def helper(commands: tuple) -> None:
3643
colors = tuple[str]((Colors.cyan, Colors.yellow, Colors.red))

core/config.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
for the proper operation of tools. It supports various configuration formats and allows centralized
88
management of settings.
99
10+
Constants:
11+
- ACCEPT_ENCODING: Contains application encoding, including "ascii", "utf-8", "utf-16", "utf-32".
12+
1013
"""
1114

1215
from json import JSONDecodeError, dump, load
@@ -16,6 +19,8 @@
1619
from core.icons import Icons
1720

1821
ACCEPT_ENCODING : tuple[str] = ("ascii", "utf-8", "utf-16", "utf-32")
22+
""" Contains application encoding, including "ascii", "utf-8", "utf-16", "utf-32"
23+
"""
1924

2025
class Config:
2126
""" Configuration manager object for the program.
@@ -34,6 +39,7 @@ class Config:
3439
__splash (bool): Whether the splash screen is enabled at startup.
3540
3641
Methods:
42+
3743
getColors() -> bool:
3844
Returns the current state of CLI color output.
3945
@@ -53,8 +59,8 @@ class Config:
5359
Updates the splash screen setting and saves the configuration.
5460
5561
Notes:
56-
- The configuration file must be in JSON format with the keys: "colors", "encoding", and "splash".
57-
- Accepted encodings are defined in the module-level constant `ACCEPT_ENCODING`.
62+
- The configuration file must be in JSON format with the keys: "colors", "encoding", and "splash".
63+
- Accepted encodings are defined in the module-level constant `ACCEPT_ENCODING`.
5864
5965
"""
6066

0 commit comments

Comments
 (0)