News for hackers. Stuff that matters.
Re:John Resig annotates original jQuery source code by cryptoz on Tuesday April 07, 2015 @03:23PM (#9336459)
Very neat content, but does it have to be formatted like this? I respect that it preserves the original file, but it makes it very difficult to read. Comments added to the source code would serve much better for the purposes of understanding the code.

This tool makes it impossible to read the annotation and the source code at the same time. Clicking on 'set' for example, about 20-30 lines in, lets you read the annotation, but not the function. You have to hide the annotation to read the code.

Wouldn't inline/multiline comments be so much better than this?

Edit: Citation/example: http://i.imgur.com/CHOFGML.png

Re:John Resig annotates original jQuery source code by maxmcd on Tuesday April 07, 2015 @03:41PM (#9336610)
This formatting style for annotated sources always seems to work so well: http://robflaherty.github.io/jquery-annotated-source/docs/01...
Re:John Resig annotates original jQuery source code by lelandbatey on Tuesday April 07, 2015 @04:55PM (#9337088)
Indeed, that side-by-side annotated style is great. For those who would like to create similar pages, the original program is Docco[0], a Javascript project. However it's been ported over to many other languages and can be found in these projects:

- Pycco[1] Python

- Rocco[2] Ruby

- Shocco[3] POSIX Shell

- Many more, as found here[4]

Note each of these projects support highlighting different languages. For example, the Pycco[1] project uses the Pygments library for language handling, and thus supports many different languages. Others, like Shocco[3] only support one language (Shell in the case of Shocco).

[0] - http://jashkenas.github.io/docco/

[1] - https://github.com/fitzgen/pycco

[2] - http://rtomayko.github.io/rocco/rocco.html

[3] - http://rtomayko.github.io/shocco/

[4] - http://jashkenas.github.io/docco/#partners-in-crime-

Re:John Resig annotates original jQuery source code by nosefrog on Tuesday April 07, 2015 @07:31PM (#9337873)
I agree, Docco-style docs are really easy to read.

I built srcco, a Docco-style doc generator that links every variable, function, etc. within your project to its definition (similar to sourcegraph.com -- full disclosure: I work at Sourcegraph), to demonstrate how to build things on top of our free/open source language analysis framework, srclib[0].

You might find it interesting (the links in the code have white backgrounds): http://sourcegraph.github.io/srcco/srcco.go.html

It only works for Go because the only Go toolchain keeps track of comment ranges (because srcco removes the comments from the source code), but it wouldn't be too hard to add comment ranges to the other toolchains. If you are interested in language analysis for languages like Java, Python, Haskell, or Javascript, I would be happy to help you make your first contribution. Ping me: [email protected].

[0] - https://srclib.org/

Re:John Resig annotates original jQuery source code by moondowner on Wednesday April 08, 2015 @05:50AM (#9339644)
Here's also a Docco 'implementation' for Java code: https://bitbucket.org/doklovic_atlassian/atlassian-docco
Re:John Resig annotates original jQuery source code by gearhart on Tuesday April 07, 2015 @03:58PM (#9336719)
Absolutely agreed - I just had to click 40 times to read 40 comments when I had half a screen's worth of whitespace they could've just been sitting in...
Re:John Resig annotates original jQuery source code by rodw on Tuesday April 07, 2015 @05:05PM (#9337159)
Strangely, the "default" Genius UI seems to be more or less the two column view - e.g., http://genius.com/1258740/Walt-whitman-song-of-myself/I-cele...

Is this intentionally divergent or is it some kind of bug?

Re:John Resig annotates original jQuery source code by asdfaoeu on Tuesday April 07, 2015 @08:23PM (#9338051)
Still just as bad tbh, you still need to click through every annotation.
Re:John Resig annotates original jQuery source code by psm42 on Tuesday April 07, 2015 @08:24PM (#9338055)
I built https://notedcode.com a while ago. It sets comments in any repo on GitHub or Bitbucket alongside the original source, and allows you to add and share further annotations, keeping them alongside the right section of code even when the code changes.
Re:John Resig annotates original jQuery source code by myth_buster on Tuesday April 07, 2015 @05:53PM (#9337431)
I think this wouldn't work for anecdotal comments that John is doing here which runs into paragraphs which would result in lot of whitespace on the right. I think an easier fix would be to highlight the current annotation in a different color while docking the comments to the right while keeping it free for user to move around.

I agree that clicking to go to next is annoying. Perhaps mouse over or scrolling should automatically show the annotation.

Re:John Resig annotates original jQuery source code by Mahn on Tuesday April 07, 2015 @04:11PM (#9336820)
Seconded, if you are going to annotate source code please go for this format.
Re:John Resig annotates original jQuery source code by zkhalique on Tuesday April 07, 2015 @05:43PM (#9337375)
What is the tool that produces this?
Re:John Resig annotates original jQuery source code by cromo on Tuesday April 07, 2015 @05:51PM (#9337413)
The Docco ( http://jashkenas.github.io/docco/ ) family of tools.
Re:John Resig annotates original jQuery source code by jasonlotito on Tuesday April 07, 2015 @03:27PM (#9336496)
Came here to say this. I cannot fathom how this is considered usable at all. There are also times that you click on the block of code to read, and it sends you back to the top of the page.

I'm more interested now in how this application got pushed to production in its current state.

Re:John Resig annotates original jQuery source code by glossybrown on Tuesday April 07, 2015 @04:20PM (#9336887)
Sorry about this bug! We're working on a fix now.

Definitely one of the biggest challenges in building this product is getting the annotation interface to work consistently in a “host page” environment over which we have pretty much no control or advanced knowledge. So for instance, the jump-you-to-the-top bug isn't something we've seen in the general case; we're currently getting to the bottom of why it's happening on this particular page.

Re:John Resig annotates original jQuery source code by pests on Tuesday April 07, 2015 @04:25PM (#9336925)
I noticed it happened on the last annotation that was at the edge of the screen. It looks like you position the annotation box at this height. That might have something to do with it.

Also, after a long piece of annotated text its annoying that the box pops up at the very bottom of the text rather than side by side.

Re:John Resig annotates original jQuery source code by sic1 on Tuesday April 07, 2015 @03:40PM (#9336597)
I just want the comments in a fixed window that is draggable so i can put it where i want. I think that would make everyone happy...or at least be better.

Great content tho, enjoying the read.

Re:John Resig annotates original jQuery source code by hiby007 on Tuesday April 07, 2015 @03:34PM (#9336552)
I am facing the same problem. I am going back to top of the page when I click on the long block of code.
Re:John Resig annotates original jQuery source code by StavrosK on Tuesday April 07, 2015 @04:15PM (#9336858)
This looks like an ad for Genius, though, so that'd be why.
Re:John Resig annotates original jQuery source code by hamburglar on Tuesday April 07, 2015 @04:44PM (#9337017)
If it's supposed to be an ad for Genius, it's a pretty lousy one, in my opinion. Half of the time I click on a highlighted line, it opens the annotation and then scrolls away, so I can't see it. It's pretty frustrating. And the "view on Genius" link redirects to the top-level Genius.com page, which just makes me sigh and close the window.
Re:John Resig annotates original jQuery source code by krick on Tuesday April 07, 2015 @07:16PM (#9337809)
Doesn't matter. People will be like "Oh! John Resig uses Genius! Looks like that's actually real software for the cools guys, not some stuff nobody uses."

Usability is optional for that.

Re:John Resig annotates original jQuery source code by itsbits on Tuesday April 07, 2015 @09:40PM (#9338329)
naah..its only for sometime. Agreed that people surely gonna have a look on it since JOHN RESIG uses it but usability only helps you to keep on using it.
Re:John Resig annotates original jQuery source code by AwesomeTogether on Tuesday April 07, 2015 @09:30PM (#9338288)
genius is based in New York I think, and so is John Resig (at least at lot of the time, he attends JS meetups in New York). He's probably doing them a favor, although the founders of genius are rather obnoxious and John's just the opposite, so it's not whom I'd expect him to help out. Maybe he's going for funding from Horowitz, who also funds genius
Re:John Resig annotates original jQuery source code by nostromo on Tuesday April 07, 2015 @03:36PM (#9336576)
I like it. It almost makes me wish I could comment my code like this somehow.

I often find that long comments can break my flow when reading code -- but of course, commenting is necessary, so perhaps it could be useful to pull them aside in an IDE. Does something like that exist?

Re:John Resig annotates original jQuery source code by OvidNaso on Tuesday April 07, 2015 @06:37PM (#9337641)
Isn't this sort of the original intent and purpose of Literate programming. I just spent a bunch of my time creating my emacs configuartion in org-mode using babel [0] and man, it was a cool experience. You can comment out the wazoo, linking to the web, other files or other parts of the same file all organized in a custom hierarchy or whatever you choose.

Then just C-c C-v t and all the source code is in a clean seperate file. You can even set it up to include the comments, link to the comments, or whatever other way you want the output to be. If I ever pursue programming more seriously, I can't image not seriously trying to do it in this manner.

0. http://orgmode.org/worg/org-contrib/babel/

Re:John Resig annotates original jQuery source code by jostylr on Wednesday April 08, 2015 @07:00AM (#9339903)
I wrote a markdown based version of literate-programming that allows one to write it with lots of comments and organize the code in anyway you wish. But then when compiled, you can see all the code without all the long comments. You can still have normal programming comments in there, of course, but the detailed thinking (the why and an overview of relations to other parts) can be taken away.

https://github.com/jostylr/literate-programming-lib

Re:John Resig annotates original jQuery source code by markm208 on Tuesday April 07, 2015 @05:56PM (#9337450)
There is something that I have been working on:

https://vimeo.com/97711978#t=0m37s

Re:John Resig annotates original jQuery source code by ThrustVectoring on Tuesday April 07, 2015 @04:00PM (#9336744)
There's likely some way to have Vim automatically fold and hide comments. Then, they're one line when not needed, and a `zo` away when you want to read them.
Re:John Resig annotates original jQuery source code by Eyas on Tuesday April 07, 2015 @04:53PM (#9337069)
The main difference between Genius-style annotation and code comments, which I think is important to note (and valuable) is that code comments annotate a point or position in the source, while genius annotations are referring to a span or range in the source.
Re:John Resig annotates original jQuery source code by dragonwriter on Tuesday April 07, 2015 @06:48PM (#9337691)
> The main difference between Genius-style annotation and code comments, which I think is important to note (and valuable) is that code comments annotate a point or position in the source, while genius annotations are referring to a span or range in the source.

I don't think that's necessarily true; code comments very often refer to a range in the source. Because code is generally designed to be accessed as linear text without hyperlinking facilities, the identification of the range is usually something that the reader has to interpret by applying (sometimes language specific) conventions relating to code formatting, indentation, and the precise placement of comments, and there are a limited set of kinds of spans that conventions cover (e.g., a span that starts in one block but extends to include the following part of the containing block doesn't have a good layout convention to indicate that a comment goes with it.)

Genius-style annotations, because they aren't limited to conventions that work in a strict linear text medium, can easily refer to arbitrary spans of content.

Re:John Resig annotates original jQuery source code by darklajid on Tuesday April 07, 2015 @06:33PM (#9337623)
Well, I think the idea is sound. I'm even into Hip-Hop/Rap, so I should like them.

Unfortunately the user interface is a world of pain. It's unusable. It's worse than quora. Good idea, but the execution needs work.

Re:John Resig annotates original jQuery source code by Eyas on Tuesday April 07, 2015 @08:04PM (#9338000)
Agreed. Just separating concept from implementation.
Re:John Resig annotates original jQuery source code by TeMPOraL on Tuesday April 07, 2015 @03:43PM (#9336627)
IMO this is cool, but it would be even better if it was in the right margin, so it wouldn't overlap with and hide the code.
Re:John Resig annotates original jQuery source code by toxican on Tuesday April 07, 2015 @03:40PM (#9336600)
I like the cleanliness of how it is now and I like the preservation of the original file, BUT the annotations seem to pop up wherever they want to without rhyme or reason. Why not just have them pop up on the right side of my screen? Or have a dedicated annotation block that scrolls with me, but well away from the content itself?
Re:John Resig annotates original jQuery source code by metamet on Tuesday April 07, 2015 @03:52PM (#9336683)
Why they did it this way and not like their other branches makes no sense.

See: http://genius.com/Kendrick-lamar-king-kunta-lyrics

Re:John Resig annotates original jQuery source code by stronglikedan on Tuesday April 07, 2015 @05:07PM (#9337167)
It would be nice if you could simply drag the modal once it's rendered. I think that would be the most simple solution.
Re:John Resig annotates original jQuery source code by oneeyedpigeon on Tuesday April 07, 2015 @06:12PM (#9337532)
Exactly what I was thinking. I'm sure there's some kind of cross-browser, front-end javascript library that you could use to achieve this :)