Giter Club home page Giter Club logo

xcomment.io's Introduction

XComment

Table of Contents

Installation

$ pip install XComment

Usage

Use the project's CLI to interact with the script.

Processing files

Say, you are working with the file ./tests/sources/HTML/index.html.

Precondition: virtualenv is activated (of course).

To remove comments (output code without comments to output file) invoke

`shell $ comments_remover ./tests/sources/HTML/input.html HTML ./ ` This will take ./tests/sources/HTML/input.html, designated as HTML file, and put the copy of the former (with HTML-specific comments removed, obviously) to ./ named rc.input.html. The latter is the name of the original file prefixed with rc. by default.

To highlight comments (outputs comments only to output file) invoke

$ comments_remover ./tests/sources/HTML/input.html HTML -p ./

Processing directories

If on start been specified directory path, script will be processing directory recursively with all subdirs for sources by specified language.

Archives

For processing archived sources use option -a

Examples:

$ # remove comments
$ comments_remover ./tmp/test.zip -a Python

$ # highlight comments
$ comments_remover ./tmp/test.zip -a -p Python

Logging

-l option enable logging (in stdout by default)

-f < path > specify path to log file

Example:

$ comments_remover ./tmp/test.py -l -f ./remove.log Python

Get supported language list

For get list supported languages use -i option. Result list will returned in json format

$ comments_remover -i

["PHP", "Python", "CSS", "HTML", "JavaScript", "ActionScript", "Ruby",
"Assembly", "AppleScript", "Bash", "CSharp", "VB", "XML", "SQL", "C"]

To see full CLI specification, run

$ comments_remover

Development

Getting Up-and-Running Locally

Tested with the following configuration:

  • Ubuntu 16.04 / 17
  • Python 3.6.

Note: the below occurences of `./` refer to the project root unless explicitly stated otherwise.

Setting Things Up on Ubuntu

  1. Enter the shell.

  2. Install pyenv via [pyenv-installer](https://github.com/pyenv/pyenv-installer):

    $ curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
    ./docs/images/pyenv-installer.png
  3. Follow the instructions on how to initialize pyenv on shell startup, for instance:

    $ echo 'export PATH="/root/.pyenv/bin:$PATH"' >> ~/.bash_profile
    $ echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
    $ echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bash_profile
    ./docs/images/initialize-pyenv-with-shell.png
  4. Install Python 3.6.x via pyenv, say Python 3.6.2 (latest micro release versions are preferred):

    $ pyenv install 3.6.2
    ./docs/images/pyenv-install-3-6-2.png
  5. Create a virtualenv for the project:

    $ pyenv virtualenv 3.6.2 comments_remover
    ./docs/images/pyenv-virtualenv-3.6.2-comments_remover.pngA
  6. Switch to whatever directory you wish the project to reside in, say ~:

    $ cd ~
    ./docs/images/cd-~.pngA
  7. Clone the project from GitHub:
    • either via SSH (the preferred way):
    $ git clone [email protected]:Singapore-Tech-Entrepreneurs/comments_remover.git
    ./docs/images/git-clone-gitatgithub-com-singapore-tech-entrepreneurs-comments-remover-git.png
    • or via HTTPS:
    $ git clone https://github.com/Singapore-Tech-Entrepreneurs/comments_remover.git
    ./docs/images/git-clone-https-github-com-singapore-tech-entrepreneurs-comments-remover-git.png
  8. Switch to the project directory:

    $ cd comments_remover
    ./docs/images/cd-comments_remover.png
  9. Activate the virtualenv:

    $ pyenv activate comments_remover
    ./docs/images/pyenv-activate-comments_remover.png
  10. Install project dependencies:

    $ pip install -U -r ./requirements.txt
    ./docs/images/pip-install-u-r-requirements-txt.png
  11. Install dependencies for testing:

    $ pip install -U -r ./requirements-test.txt
    ./docs/images/pip-install-u-r-requirements-test-txt.png
  12. (optional) Install [IPython](https://ipython.org/) interactive shell to speed up development:

    $ pip install ipython==6.1.0
    ./docs/images/pip-install-ipython-6-1-0.png

To run tests, simply

$ pytest ./

./docs/images/pytest.png

To also see coverage report,

pytest --cov ./

./docs/images/pytest-cov.png

You should be good to go now.

Deployment

Pip registry

Install dependencies
$ python install -r requirements-deploy.txt
Set pypi credentials
$ export TWINE_USERNAME=<pypi username>
$ export TWINE_PASSWORD=<pypi password>
Create distribution
$ python setup.py sdist bdist_wheel
Upload
$ twine upload dist/XComment-x.y.z.tar.gz

Tips

If you're not using [PyCharm](https://www.jetbrains.com/pycharm/) yet, make sure to at least consider this as an option. Also check out [JetBrains Toolbox](https://www.jetbrains.com/toolbox/), a single tool to rule them all (the JetBrains products). To stay up-to-date, follow [PyCharm Blog](https://blog.jetbrains.com/pycharm/).

Contributors

Design by Filip Todorov @ www.filiptodorov.com

xcomment.io's People

Contributors

webyneter avatar kagondu avatar kpstsp avatar luthienberen avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.