|
1 | | -# EmacsComStrip |
2 | | -CLI Based Comment Stripper Using Emacs |
| 1 | +## ComStrip |
3 | 2 |
|
| 3 | +Universal Code Comment Stripper and Diff Analysis tools leveraging Emacs Language support |
4 | 4 |
|
5 | | -Emacs has excelent language scemantics processing and also has a batch mode to allow execution of lisp code in a headless fashion. |
| 5 | +### Installation |
6 | 6 |
|
7 | | -This tool allows the user to use emacs to strip source code comments from any source langage. |
| 7 | +``` |
| 8 | +python3 -m pip install commstrip |
| 9 | +``` |
8 | 10 |
|
9 | | -## usage: |
10 | | -``` emacs --file=<path_to_source_code> --quick --batch --eval '(load "./comstrip.lisp")' ``` |
11 | | - |
12 | | -This tool will read in <source_code>, use emacs to strip comments out and the write to /tmp/<file_name>_comstrip |
13 | | - |
14 | | -## Requirements: |
15 | | -* emacs |
| 11 | +### Requirements |
| 12 | +* emacs 28.1+ |
16 | 13 | * language files for languages that need processing |
17 | 14 |
|
18 | | -Note: This code is presently written for *nix but can easily be updated to be x-platform. This is my first `lisp` program so still in the early stages. |
19 | | - |
| 15 | +Note: This code is presently written for Linux and shoudl work out of the box on MacOS and Cygwin. Windows support is planned. |
| 16 | + |
| 17 | +### Create Alias - Add to ~/.bashrc |
| 18 | +``` |
| 19 | +function __comstrip { |
| 20 | + python3 /dpool/vcmain/dev/lisp/comstrip/src/comstrip/comstrip.py "$@" |
| 21 | +} |
| 22 | +alias comstrip='__comstrip' |
| 23 | +``` |
| 24 | + |
| 25 | +### CLI Usage: |
| 26 | + |
| 27 | +#### 3-way meld compare |
| 28 | +Compare /r1/src1.py to /r2/src2.py and /r2/src3.py, strip comments, blank lines and trailing spaces and launch in meld |
| 29 | +``` |
| 30 | +comstrip --basedir /dpool/vcmain/dev/lisp/comstrip/test/data --noblank --notrail --meld --file /r1/src1.py /r2/src2.py /r3/src3.py |
| 31 | +``` |
| 32 | + |
| 33 | +## Stats only |
| 34 | +Compare /r1/src1.py to /r3/src1.py, strip comments, blank lines and trailing spaces and show stats |
| 35 | +``` |
| 36 | +comstrip --basedir /dpool/vcmain/dev/lisp/comstrip/test/data --noblank --notrail --stats --file /r1/src1.py /r3/src2.py |
| 37 | +``` |
| 38 | + |
| 39 | +Output: |
| 40 | +``` |
| 41 | +Stats: /r1/src1.py <-> /r3/src1.py (/dpool/vcmain/dev/lisp/comstrip/test/data): |
| 42 | + add_l | mod_l | rem_l | tot_l | tot_chars |
| 43 | + 161 | 25 | 28 | 109 | 7310 |
| 44 | +
|
| 45 | + Orig Src | Clean Src | Ok | Note |
| 46 | +/r1/vtscan.py | /tmp/cs_zz_cs_220420-211346.451785_vtscan_211347211.py | True | - |
| 47 | +/r3/vtscan.py | /tmp/cs_zz_cs_220420-211346.452998_vtscan_211347429.py | True | - |
| 48 | +``` |
| 49 | + |
| 50 | +### Python API Usage: |
| 51 | +See `test/comstrip_test.py` for API examples |
| 52 | + |
| 53 | + |
| 54 | +### TODO: |
| 55 | +[.] Make proper installer for system to get comstrip command working without alias |
| 56 | +[.] Port to Windows |
| 57 | +[.] Verify in Cygwin and MacOs |
| 58 | +[.] Build out proper testing |
| 59 | +[.] Implement leading tab handling |
0 commit comments