Skip to main content

Faint Comments

This repository is my attempt in 100 commits competition.

⚠️ This project is in PoC and still needs to be polished. Always pin version. Do backup or use version control before applying any command.

What it is?

This library keeps your code comments in separate file and allows to put them back on.

Why

Comments are code smell. But sometimes:

  • you just want to have your own note that should never appear in Version Control.
  • you have code that needs some comments but comments must always be removed before deploy on production.
  • you want to give someone instruction on what to do in certain files.

In all this cases it would be handy to keep all comments in separate file that could be potentially git ignored but at the same time applied whenever you want to read them.

Also I thought I can learn some cool algorithms and tools.


Demo

I need to record the example of usage.

How to install

Not installable yet. I need to change name and send to PyPi.

How to use

faint is made of two main subcommands:

  • faint extract <file name> which removes comments from code and place them in separate JSON file.
  • faint join <file name> which applies comments from JSON file (if exists) in corresponding places.

By default (not changeable yet) JSON files are named as comments_<original name>.json. So you can add to .gitignore line like comments_*.json.

Workflow

First use extract on the file. Then you can:

  • Use join and not modify the file
  • Use join and modify the file
  • Continue to modify the file and then use join

Then:

  • If you apply join on file that matches exactly the file after extract it should be fast and simple and you should get all comments back in place.
  • If you apply join and file follows the structure good enough you should also get all comments back in right place.

In both cases the extract should work as at the beginning.

Current version does not allow for:

  • extract on already extracted file (it will discard all comments in JSON)
  • join on already joined file (it will place the comments twice)

So if you want to add any new comments you should first join comments and the extract them.

Supported languages

This tool uses TreeSitter. For every language the AST (Abstract Syntax Tree) has different nodes. For this reason every language needs to be covered separately.

  • Python

TODO

  • Make it pip installable
  • Fix double join
  • When extracting, compare with current JSON
  • Show abandoned comments
  • Show deleted comments
  • When join and comment is abandoned inform user. Then suggest --force flag.
  • Allow for path to subdirectory
  • Figure out how to install TreeSitter per language
  • Add Git hook
  • Handle when there is new comment on already extracted file
  • Create join-extract command

Future plans

Metadata

Release files for faint 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for faint 0.1
File Size Uploaded Provenance Actions
faint-0.1.tar.gz 16.4 kB Without provenance Details for faint-0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for faint 0.1
File Interpreter ABI Platform Actions
faint-0.1-py3-none-any.whl Python 3 none any Details for faint-0.1-py3-none-any.whl

Total release size: 27.6 kB

Release files / faint-0.1.tar.gz

Download URL faint-0.1.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
913357abfbb283effdbb96b6626c6e3fca86d567e5476608c20ebc13cb9cad4a
BLAKE2b-256 checksum
How to use checksums
1e6663a071243d9c7b934011b7624fe39e8161e39ea95e8d14c0972dcba5a43a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Release files / faint-0.1-py3-none-any.whl

Download URL faint-0.1-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9daa1e5c3a9fa46012f561f9a6f7672743f9f5419bfaaae71d3ccb36b009698b
BLAKE2b-256 checksum
How to use checksums
0ca301f019f0c6220fc01c3ff2375ee2048a4a92dbd115f5ebf8f4ed41ee5976
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.32.3

Security for faint 0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page