https://github.com/thetrueender/decommenter
Automatically decomment code, for use cases including minimization, removal of PII, and cleanup. Support for recommenting the decommented code is included.
https://github.com/thetrueender/decommenter
code comment decomment python recomment
Last synced: 8 months ago
JSON representation
Automatically decomment code, for use cases including minimization, removal of PII, and cleanup. Support for recommenting the decommented code is included.
- Host: GitHub
- URL: https://github.com/thetrueender/decommenter
- Owner: theTrueEnder
- License: mit
- Created: 2024-08-13T03:53:16.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-08-20T17:48:48.000Z (over 1 year ago)
- Last Synced: 2025-03-24T01:40:59.250Z (10 months ago)
- Topics: code, comment, decomment, python, recomment
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# decommenter
Automatically decomment code, for use cases including minimization, removal of PII, and cleanup.
Additionally, `decommenter` supports recommenting the decommented code by exporting the extracted comments to a separate file. Using the `recomment` mode, those comments can be reinserted.
## Usage
**Requires Python 3.8+ to be installed**
> It is possible older versions work, but I cannot guarantee functionality. `decommenter` was developed in 3.12.
```c
python cli.py [-h] [--mode {decomment,recomment}] [--file [FILE]]
options:
-h, --help show this help message and exit
-m, --mode {decomment,recomment}
select mode of operation (decomment or recomment)
f, --file [FILENAME]
filename or path to the target file
```
## Supported Languages:
- [X] Python-style comments*
- [X] C-style comments: UNSTABLE (see below)
### Python-Style Comments
This program assumes that comments adhere to the [PEP8](https://peps.python.org/pep-0008/#comments) standard for Python comments. This means that comments should follow the `# .*` pattern. Technically, inline comments should have two spaces between the `#` and the end of the code, but the `decommenter` regex does adjust for inlines that do not follow this (the recommenter follows the two-space pattern).
Docstring removal is not implemented at this time. Block comments using `'''` or `"""` is not in adherence to PEP8 (see above) and will not be removed.
> *Python-style comments in other languages (e.g. Ruby, Perl, and R) are allowed to run but have not been tested and are therefore not guaranteed to work.
### C-Style Comments
Inline and newline C-style comments (i.e. non-block comments) work fine with the code on `dev`. There is a tenative processor for block comments, but it is unstable and inconsistent. A fix will arrive in the near future (this requires restructuring the entire processor from a line-by-line regex logic to multiline regex logic). If you want to try it out, clone the code on the `dev` branch.