Skip to main content

A Python library to extract comments and source code out of your file(s)

Project description

Nirjas ~ নির্যাস

A Python library for Comments and Source Code Extraction

✨ 🍰 ✨

python version status HitCount License LGPL-2.1 release Slack Channel stars

Description

A source code file usually contains various vital information such as license text, function/class documentation, code/logic explanation, etc in the form of comments (block & line).

Nirjas is a fully dedicated python library to extract the comments and source code out of your file(s). The extracted comments can be processed in various ways to detect licenses, generate documentation, process info, etc.

Apart from that the library serves you with all the required metdata about your Code, Comments and File(s)

Requirements

  • Python 3

Installing Python on Linux machines:

$ sudo apt-get install python3 python3-pip 

For macOS and Windows, packages are available at Python.org

Supported Languages

We Support almost all the major programming languages. If you want any other language to be added, feel free to raise an issue.

The Languages we support till now:

  • C
  • C#
  • C++
  • CSS
  • Go
  • Haskell
  • HTML
  • Java
  • JavaScript
  • Kotlin
  • MATLAB
  • Perl
  • PHP
  • Python
  • R
  • Ruby
  • Rust
  • Scala
  • Shell
  • Swift

Installation

Install using pip

You’ll need to make sure you have pip available. You can check this by running:

pip --version

If you installed Python from source, with an installer from python.org, you should already have pip. If you’re on Linux and installed using your OS package manager, you may have to install pip separately.

Haven’t installed pip? Visit: https://pip.pypa.io/en/stable/installing/

Install the latest official release via pip. This is the best approach for most users. It will provide a stable version and are available for most platforms.

  • Update pip to the latest stable version
pip3 install --upgrade pip
  • Install Nirjas
pip3 install nirjas
  • Upgrading Nirjas

Upgrade already installed Nirjas library to the latest version from PyPI.

pip3 install --upgrade Nirjas

Install using source

If you are interested in contributing to Nirjas development, running the latest source code, or just like to build everything yourself, it is not difficult to install & build Nirjas from the source.

  • Fork the repo

  • Clone on your local system

git clone https://github.com/fossology/Nirjas.git 
  • Change directory
cd Nirjas/
  • Install the package
pip3 install .

This will install Nirjas on your system.

  • Check if Nirjas is installed correctly or get help, Run:

    nirjas -h or nirjas --help

Example Usage

  • For help
nirjas -h
  • To extract comments from a single file
nirjas -p <path to file>
  • To extract comments from all the files in directory/sub-directory
nirjas -p <path to directory>
  • To extract only source code (excludes commented part) out of a file
nirjas -i <target file> <new file name including extension>

or for default file generation (default file: source.txt)

nirjas -i <target file>

Tests

To run a test for Nirjas, go to the /extractor folder and use the command:

python3 testscript.py

This will download all the test files into languages/tests/TestFiles folder and will run the tests as well.

Documentation

We maintain our entire documentation at GitHub wiki. Feel free to switch from code to wiki or just click here - Nirjas Documentation

Contributing

All contributions, bug reports, bug fixes, documentation improvements, enhancements, and ideas are welcome.

A detailed overview on how to contribute can be found in the contributing guide.

Feel free to ask questions or discuss suggestions on Slack

License

This repository is licensed under the terms of LGPL-2.1. Check the LICENSE file for more details.

Project details


Download files

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

Source Distribution

Nirjas-0.0.2.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

Nirjas-0.0.2-py3-none-any.whl (65.1 kB view details)

Uploaded Python 3

File details

Details for the file Nirjas-0.0.2.tar.gz.

File metadata

  • Download URL: Nirjas-0.0.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for Nirjas-0.0.2.tar.gz
Algorithm Hash digest
SHA256 6f17250cc2fd9b43295d929e979f816ea4caa8503242ef1278cd89f6ecc6c021
MD5 8a92fc000be79b3d7ad39dcb307cedec
BLAKE2b-256 8153165f23586d5bc6fd8f2a409d1c0163a6d2e56a5857ea248f1b134ddbf47e

See more details on using hashes here.

File details

Details for the file Nirjas-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: Nirjas-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 65.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.6.9

File hashes

Hashes for Nirjas-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dded58d23be44441187bb030e7a92434c8c2978cc4f0ce8f5cef83b1e7d92020
MD5 7772be88dd0ca7ba1949ee51fc8cb72a
BLAKE2b-256 fa0b14c1b58ec417a2bd800b6e2cd2374ae0ccba8a885bb7cf232055174b90b5

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