Git Product home page Git Product logo

source-marking-system's Introduction

Contributors Forks Stargazers Issues MIT License


Logo

Code Marking System

Mark your source code with copyright/license claims
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents

About The Project

Write a license or copyright and specify your source code. It will then write your data to the top of the source code. This way every file will be marked correctly and is error prone.

Getting Started

To get a local copy up and running follow these simple steps.

Prerequisites

Have python3 installed

Installation

  1. Clone the source-marking-system
git clone https://github.com/F0xedb/source-marking-system.git
  1. Install packages
pacman -Syu python
  1. give executable permissions
chmod +x source-notate

Speed

Here is a statistic of speed of adding source files. We have executed this program on the UnrealEngine source directory.

Here is some information

Python 3 version
$ python -v 
Python 3.7.4
Size of Unreal Engine source including git information (release branch)
$ du -h Engine/Source | tail -n1
897M    Engine/Source
Information cloc provides (count lines of code) (release branch)
$ cloc Engine/Source
    69461 text files.
   50617 unique files.
   22822 files ignored.

github.com/AlDanial/cloc v 1.84  T=138.15 s (337.7 files/s, 104124.8 lines/s)
---------------------------------------------------------------------------------------
Language                             files          blank        comment           code
---------------------------------------------------------------------------------------
C++                                  11003         957588         506815        4287471
C/C++ Header                         27598         902023        1528039        3765135
C                                     1866         141670         136754         685664
C#                                    1647          56770          87592         353941
XML                                   1086           2813           3532         216014
HTML                                   985           9377           1500         153411
MSBuild script                         200              4            460         112243
Bourne Shell                           180           9377          13360          59596
JSON                                    66              8              0          57374
Objective C                            343          11844          14889          56150
Objective C++                          120           5836           3987          29147
CMake                                  458           6498           7024          26407
CSS                                     19           1986            338          19382
Windows Module Definition              128           1884            395          19002
Python                                  86           3946          13867          15769
make                                   411           5202           7551          12654
Markdown                                76           3087              0          10150
Perl                                    37           1215            968           6609
Pascal                                  19            651           5811           6589
JavaScript                              33           1352           1495           5877
HLSL                                    59           1178            615           5075
Java                                    29            730            285           3281
DOS Batch                              128            923            504           2988
Windows Resource File                   48            821           1125           2892
XAML                                     8            174             83           2523
GLSL                                     6            490            451           2203
ASP.NET                                  6            259              0           1072
Ant                                      2             27            108            391
Expect                                   7             47             44            149
SAS                                      1             14             22             32
Bourne Again Shell                       1              0              0              9
---------------------------------------------------------------------------------------
SUM:                                 46656        2127794        2337614        9919200
---------------------------------------------------------------------------------------

As we can see there are over 50000 files! and almost 10 million lines of code. This project is the ideal test for this tool. We see that cloc took 140 seconds to do this on my computer. Lets test this project. I ran the following command

$ time source-notate -c LICENSE.md Engine/Source
source-notate -c LICENSE.md Engine/Source  41.19s user 1.87s system 99% cpu 43.182 total

As we can see the tool is relative quick. Lets see howmuch comments we have generated.

$ cloc Engine/Source
   69471 text files.
   50619 unique files.
   22820 files ignored.

github.com/AlDanial/cloc v 1.84  T=161.07 s (289.7 files/s, 90343.0 lines/s)
---------------------------------------------------------------------------------------
Language                             files          blank        comment           code
---------------------------------------------------------------------------------------
C++                                  11003         967465         537574        4286455
C/C++ Header                         27599         929418        1610142        3765193
C                                     1866         143511         142265         685707
C#                                    1647          58408          91227         355241
XML                                   1086           2813           3532         216014
HTML                                   985           9377           4440         153411
MSBuild script                         200              4            460         112243
Bourne Shell                           180           9697          13530          59596
JSON                                    66              8              0          57374
Objective C                            343          11844          14889          56150
Objective C++                          120           5836           3987          29147
CMake                                  458           6498           7024          26407
CSS                                     19           1986            395          19382
Windows Module Definition              128           1884            395          19002
Python                                  87           4060          13954          15769
make                                   411           5202           7551          12654
Markdown                                76           3087              0          10150
Perl                                    37           1215            968           6609
Pascal                                  19            651           5811           6589
JavaScript                              33           1385           1594           5877
HLSL                                    59           1178            615           5075
Java                                    29            759            372           3281
DOS Batch                              128            923            504           2988
Windows Resource File                   48            821           1125           2892
XAML                                     8            174             83           2523
GLSL                                     6            490            451           2203
ASP.NET                                  6            259              0           1072
Ant                                      2             27            108            391
Expect                                   7             47             44            149
SAS                                      1             14             22             32
Bourne Again Shell                       1              0              0              9
---------------------------------------------------------------------------------------
SUM:                                 46658        2169041        2463062        9919585
---------------------------------------------------------------------------------------

As you can see we went from 2337614 comments to 2463062 comments. That is a difference of 125448 comments. Since the Unreal Engine License is only 3 comment +- We have inserted Licenses to 41816 files in 41.19s This is an average of 1000 files/s which is rather good.

source-marking-system is the way of adding license to your projects!

Usage

Create a file called LICENSE that contains your copyright information. All other parameters are directories/files to annotate.

python source-notate --claim LICENSE . 
# or
source-notate -c LICENSE file1.py file2.py file.sh class.java
# LICENSE is the default license so you can leave that black
source-notate file1.py file2.py file.sh class.java

You can also add Licenses to files that the tools fails to detect the language of.

source-notate --language py file1 file2.py file3.npy  # treat all files as python code
source-notate --language c file1 file2.py file3.npy  # treat all files as c code
source-notate -l asm file1 file2.py file3.npy  # treat all files as assembler

There is also the posibility to change the license to a newer version. All you need are 2 files (one containing the old license and one containing the new license) Here is how you change the license of a file or directory

source-notate --modify old_license new_license file1.py # find the old license in the file and replace it with the new one
source-notate --m old_license new_license file1.py # find the old license in the file and replace it with the new one
source-notate --modify old_license new_license . # This also works with directories
source-notate --modify old_license new_license --language file1 # or other options

Supported languages are:

  • shell
  • python
  • java
  • c#
  • c
  • c++
  • javascript
  • typescript
  • Lua
  • HTML
  • CSS
  • Rust
  • Go
  • Assembly
  • Dockerfile
  • yaml
  • dart

More languages should be supported in the future

For more examples, please refer to the Documentation

Roadmap

See the open issues for a list of proposed features (and known issues).

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

F0xedb - [email protected]

Project Link: https://github.com/F0xedb/source-marking-system

Acknowledgements

source-marking-system's People

Contributors

f0xedb avatar

Watchers

 avatar  avatar

source-marking-system's Issues

Add command line options for each language

We should have a command line option to force a certain language eg
source-notate -l py source-notate
This would treat all files supplied as python files.
The -l option stands for --language and we supply the file extention with it.

Exclude all svn's dirs

We never need to add our licenses to these type of directories. Thus we can exclude them. Currently we only exclude the .git directory but more should be added.

Add option to alter outdated copyright claims.

There should be an option to alter copyright claims.
Imaging the following file

#!/usr/bin/env python

# MIT License
# version 1

print("hello world")

Lets presume the following copyright claim is outdated.
You then should remove the claim manually for every file (which is time consuming)
I propose we add a command line option to automate this behaviour.

for example source-notate --modify old.txt LICENSE . The modify option accepts 2 parameters
The first parameter is the old claim to modify
The second parameter is the new claim to add.

This way we can mass change the LICENSE to a newer version.

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.