Skip to content

Usage Guide

Ayush Bhardwaj edited this page Jul 5, 2020 · 4 revisions

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 metadata about your Code, Comments and File(s)

You can use Nirjas for the following tasks:

  1. To extract comments out of a source file.
  2. To extract comments out of a whole project directory (Each and every source files one by one).
  3. To get all the metadata regarding comments (Single line and Multiline) and file.

The metadata includes comments line number(start & end), file name, language, blank lines, sloc, total lines, etc

  1. To extract only the source code from a file(leaving all the comments)

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>

Clone this wiki locally