angular / angular.js

AngularJS - HTML enhanced for web apps!
https://angularjs.org
MIT License
58.8k stars 27.48k forks source link

Decommenting Angular #13643

Closed vitaly-t closed 8 years ago

vitaly-t commented 8 years ago

This is not an issue, rather trying to contribute, and if this isn't the right place, my apologies then.

I am an active user of AngularJS, which I love a lot. And I appreciate how much code documentation is going into this library for automatic API generation. It is the same path with many other large libraries today.

Sometimes code documentation becomes so large, it becomes larger than the code itself, and instead of helping with debugging an application, it may get in the way.

On that sentiment, if you ever consider either distributing or otherwise publishing Angular JS without all the inline documentation, I just wrote a library - decomment, and used Angular JS 1.5 Core as the ultimate test to see that everything looks and works right.

For that particular file, the 29,859 lines are reduced to 13,851 (less than half), after passing it through decomment(text, {trim: true}), which is still the same-formatted code, but easier to navigate through.

Keep up good work, guys!

Delapouite commented 8 years ago

An alternative can be to turn on automatic comment-folding in your text editor.

Narretz commented 8 years ago

Cool library! I agree that inline docs can be a bit overwhelming. Personally, if I wanted to see a file without comments, I would either use editor comment folding, or run uglifyJS so that it only removes comments, and otherwise doesn't touch the code.

vitaly-t commented 8 years ago

I mostly meant it for easier and faster debugging within browsers. Plus you end up with less than half the file size, which is good when you don't care about inline documentation, which is again what happens in most cases.

@Narretz uglifyJS is not very good for this, because its support for ES6 is still far from ready, whereas esprima is 100% ES6-compliant, and this is the library I'm using for parsing JavaScript, to assure correct comment removal even when mixed up with ES6 template strings.