Skip to content

Commit c57dacd

Browse files
committed
Updated documentation
1 parent 4d2cb0d commit c57dacd

File tree

7 files changed

+93
-125
lines changed

7 files changed

+93
-125
lines changed

.github/copilot-instructions.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,12 @@ Copilot MUST:
1010
- Avoid stylistic or formatting changes
1111

1212
## Context
13-
This project extends Python's codecs with many encoding/decoding schemes and CLI tools.
13+
This project extends Python's codecs with many encoding/decoding schemes and a CLI tool.
1414
It already includes a wide variety of bases, ciphers, compression, and niche encodings.
1515

1616
## Enhancement Guidelines
17+
When adding a new encoding, follow the guideline in the documentation at `docs/pages/howto.md`.
1718

18-
When adding a new encoding:
19-
1. Check if it already exists in the project
20-
2. Follow the existing codec structure and naming conventions
21-
3. Provide:
22-
- `encode()` implementation
23-
- `decode()` implementation
24-
- Registration into the codec registry
25-
4. Ensure CLI compatibility (if applicable)
2619

2720
## Implementation Constraints
2821

@@ -33,28 +26,56 @@ When adding a new encoding:
3326

3427
## Testing
3528

36-
Every new codec MUST include:
37-
- Unit tests (encode/decode roundtrip)
38-
- Edge cases (empty input, binary data if applicable)
29+
Every new codec:
30+
- SHOULD include a list of `__examples__` that tells the automated tests what encoding/decoding transformations need to be verified ; it this cannot be made, unit tests (encode/decode roundtrip) SHALL be provided in `tests/test_manual.py`
31+
- Edge cases (empty input, binary data if applicable), either in the `__examples__` list or in the explicit tests in `tests/test_manual.py`
3932

4033
## Documentation
4134

42-
Each codec must include:
43-
- Short description
44-
- Reference (standard, RFC, or algorithm source)
45-
- Example usage
35+
Each codec SHALL comply with the following structure:
36+
37+
```python
38+
# -*- coding: UTF-8 -*-
39+
"""{{codec_long_name}} Codec - {{codec_short_name}} content encoding.
40+
41+
{{codec_description}}
42+
43+
This codec:
44+
- en/decodes strings from str to str
45+
- en/decodes strings from bytes to bytes
46+
- decodes file content to str (read)
47+
- encodes file content from str to bytes (write)
48+
49+
Reference: {{codec_source_hyperlink}}
50+
"""
51+
from ..__common__ import *
52+
53+
54+
__examples__ = {<<dictionary of examples with, as keys, a special format detailed hereafter and, as values, a dictionary mapping source to destination values (see sectino _Self-generated tests_)>>}
55+
<<optional list of valid codec names to be used with the guessing mode (see _Codec names for the guessing mode_), in format "__guess__ = [...]">>]
56+
57+
58+
<<constants here, including ENCMAP if the codec is a simple mapping (see section _Case 2: Encoding map_)>>
59+
<<functions here, if the codec requires some additional logic, i.e. when it is not a mapping (see section _Case 1: Generic encoding definition_)>>
60+
61+
62+
<<put the right add function (see section _Which `add` function ?_) here with its relevant parameters (see section _Generic arguments_)>>
63+
```
64+
65+
In this template, `{{ ... }}` enclosures indicate codec's properties and `<< ... >>``enclosures indicate placeholder actions referring to steps from the documentation about how to make a codec at `docs/pages/howto.md`.
4666

4767
## Output Format (IMPORTANT)
4868

4969
When asked to add a codec, Copilot should:
5070
1. Briefly justify the encoding (1–2 lines)
51-
2. Provide full implementation
52-
3. Provide tests
53-
4. Provide documentation snippet
71+
2. Provide full implementation (according to section _Adding a new codec to `codext`_ of the documentation at `docs/pages/howto.md`)
72+
3. Provide tests (according to section _Self-generated tests_)
73+
4. Add it to the `README.md` of the repository
74+
5. Propose the update of the documentation (under the relevant page for the category of codec)
5475

5576
## Explicit Non-Goals
5677

5778
- No refactoring
5879
- No performance optimization passes
5980
- No linting-only changes
60-
- No CI/CD changes
81+
- No CI/CD changes

.github/pull_request_template.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
## Type
2-
- [ ] New encoding (required)
3-
41
## Checklist
52
- [ ] No unrelated changes
63
- [ ] Codec is new (not already implemented)
74
- [ ] Tests included (if cannot be automated with `tests/test_generated`)
85
- [ ] Documentation (included in the right page in `docs/pages/enc`)
96

107
## Description
11-
Explain the encoding and its source.
8+
Explain the encoding and its source.

.github/workflows/python-package.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ on:
1010
branches: [ "main" ]
1111

1212
permissions:
13-
actions: write
14-
id-token: write # for OIDC
13+
id-token: write
1514
contents: read
1615

1716
jobs:
@@ -53,6 +52,8 @@ jobs:
5352
pytest --cov=$package
5453
coverage:
5554
needs: [prepare, build]
55+
permissions:
56+
contents: write
5657
runs-on: ubuntu-latest
5758
env:
5859
cov_badge_path: docs/coverage.svg

docs/ADDING_CODECS.md

Lines changed: 0 additions & 69 deletions
This file was deleted.

docs/mkdocs.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
site_author: dhondta
22
site_name: "Codext - Extension of native codecs for Python"
33
repo_url: https://github.com/dhondta/python-codext
4-
copyright: Copyright &copy; 2021-2023 Alexandre D'Hondt
4+
copyright: Copyright &copy; 2021-2026 Alexandre D'Hondt
55
docs_dir: pages
66
nav:
77
- Introduction: index.md
@@ -37,6 +37,8 @@ extra:
3737
name: Alex on Twitter
3838
extra_css:
3939
- css/extra.css
40+
plugins:
41+
- search
4042
theme:
4143
name: material
4244
palette:
@@ -50,7 +52,6 @@ theme:
5052
name: Switch to light mode
5153
logo: img/logo.png
5254
favicon: img/icon.png
53-
use_directory_urls: false
5455
markdown_extensions:
5556
- toc:
5657
permalink: true

0 commit comments

Comments
 (0)