Wednesday, March 23, 2011

Using links in your comments

Ever find that you had to read a set of online documentation or specifications in order to implement something and thought it would be really nice to put a reference to that material in your code just in case you or someone who maintained the code might need it later?

One handy feature in the IDE is that if you put a full URL in a comment the IDE will actually recognize it as a URL and highlight it so it's clickable.

And it works with several URL schemes
In a code editor, if you put in code like:

// this came from code at http://developer.apple.com/

the URL for developer.apple.com highlights and appears as a clickable URL

Or you can use mailto if you've sent source code to others so they can easily mail you back

// mailto:blah@example.com

And yes, you can add subject lines as follows:

// mailto:blah@example.com?subject=Hey%20there

If you click on a mailto link, like above that is in your RB code, it starts your email client & addresses it to "blah@example.com" with a subject if you had one.

This is really handy when you need to refer to documentation from Apple, GTK, MSDN, etc. so you or the person who comes along later can see where you got the reference material from.

2 comments:

Terry said...

Nice! Thanks Norman!

Ricounet said...

And it also works with Feedback URLs.