Skip to main content

Tool to manage your comments in code!

Project description

Faint Comments

This repository is my attempt in 100 commits competition.

:warning: 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

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

faint-0.1.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

faint-0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file faint-0.1.tar.gz.

File metadata

  • Download URL: faint-0.1.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for faint-0.1.tar.gz
Algorithm Hash digest
SHA256 913357abfbb283effdbb96b6626c6e3fca86d567e5476608c20ebc13cb9cad4a
MD5 680863757d290d044052197cfeb9bcd4
BLAKE2b-256 1e6663a071243d9c7b934011b7624fe39e8161e39ea95e8d14c0972dcba5a43a

See more details on using hashes here.

File details

Details for the file faint-0.1-py3-none-any.whl.

File metadata

  • Download URL: faint-0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.32.3

File hashes

Hashes for faint-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9daa1e5c3a9fa46012f561f9a6f7672743f9f5419bfaaae71d3ccb36b009698b
MD5 bd02c5fe0e9cd9098b135127509c8f25
BLAKE2b-256 0ca301f019f0c6220fc01c3ff2375ee2048a4a92dbd115f5ebf8f4ed41ee5976

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page