The other answers are the standard open-source legal disclaimer stuff that you see everywhere.
You need that.
But that is not all. Doing only the legal stuff is what drives me crazy with so much open source development.
Also put into the HEADER AT THE TOP OF THE FILE a description:
- What this thing is (a short name)
- Its purpose (a long description, the hows and whys of why this thing exists, pretend you are explaining to 6 year olds.)
Without those 2 things anybody looking at it has to read your mind to figure out what this stuff is, and if they are interested in it.
NEXT, you ask about commenting.
You should actually have been commenting as you wrote it, not post-fixing it in after the event.
But nevertheless, comments at the micro level just serve to waste everbodies time, and infuriate.
fred = fred + 1; // increment fred
So, don't do that.
Instead, place a comment of substance before a chunk of code (not inside it!), setting out what the next thing does, being as general or specific as you need to be:
// This implements the fast integer line drawing algorithm originally by
// Fred Nurke (see http://www.nurkesoft.com/fild), with the following
// modifications for speed:
// - Frangle the nurgulator before decrementing the frobber;
// - Update the decrementer pointer once only.
// Having done that, dispatch it to the ice-age thread where it can sit and
// grow moss for a couple of decades.
<neat code comes here for perhaps 10 - 20 lines>
As a ROUGH generalisation, a lump of code running for more than about 20-30 lines is getting a bit too big - so this is the approximate size for a chunk that needs an explanatory leading comment. Almost all code will have chunks that are around 5 - 30 lines in a block with a comment suitable for that block. (That block performs some function or has some purpose that you can describe.)
And finally, comments should be nicely laid out, they should not use excessive or obscure acronyms, they should read as normal English, they should be grammatically correct and properly punctuated.