News for hackers. Stuff that matters.
Re:JQuery Annotated Source by pokoleo on Friday April 26, 2013 @12:50PM (#5613904)
This is an old version of jQuery run through docco, with a simple page on top of the docco output.

docco: http://jashkenas.github.io/docco/

I just checked out jquery and built it myself. Here's a newer version:

http://shalecraig.com/docs/manipulation.html

Re:JQuery Annotated Source by ori_b on Friday April 26, 2013 @02:38PM (#5614638)
Is it strange that I found myself mostly ignoring the comments when I was trying to understand this?

The only thing I found the comments useful for understanding was pointing out the IE compatibility behavior.

Re:JQuery Annotated Source by bobfunk on Friday April 26, 2013 @04:38PM (#5615305)
Had the same experience, found it easier to just read the code .
Re:JQuery Annotated Source by qpleple on Friday April 26, 2013 @06:13PM (#5615802)
That's the point: you read the code, and when something is not crystal clear, you glance at the comment.
Re:JQuery Annotated Source by jliechti1 on Friday April 26, 2013 @12:54PM (#5613940)
Hey, this is pretty cool.

Does this style of annotation exist for any other libraries/projects?

I think the left side could be expanded into a pretty good pedagogical tool using mini-examples and explanations to focus on key concepts in the code.

Re:JQuery Annotated Source by muriithi on Friday April 26, 2013 @12:57PM (#5613956)
Re:JQuery Annotated Source by romaniv on Friday April 26, 2013 @01:32PM (#5614207)
Many (around 5) years ago I wrote a library that parsed PHP files and generated logical "anchors" after classes and functions. I combined that with a simple CRUD application that allowed anyone to view source code in the browser and add/change comments dynamically.

No one cared.

Re:JQuery Annotated Source by kristopolous on Friday April 26, 2013 @02:06PM (#5614443)
have the source posted anywhere?
Re:JQuery Annotated Source by romaniv on Friday April 26, 2013 @02:51PM (#5614713)
The main website it was on no longer exists, but there are bits and pieces here and there.

http://code.ohloh.net/project?pid=LOfjD4AHjNo&prevcid=1&...

doc_code2html() takes PHP code as argument, and uses built-in PHP tokenizer to add CSS classes to code. After that, you can use vanilla CSS to color things up. Up to this day this is the simplest and most accurate PHP highlighter I've seen.

doc_getCodeAnchors() takes php code as argument and returns an associative array of anchors. I.e.:

  array(
    'MyClass.methodName' => array('line' => 3, 'type' => 'class', 'name' => "methodName"),
  )
Comments class was a controller that actually displayed files with highlighting and comments, allowing you to add and edit comments.

And yes, I am fully aware of deficiencies of that code, but I still think the core ideas there are pretty cool.

Re:JQuery Annotated Source by emillon on Friday April 26, 2013 @01:32PM (#5614199)
It's similar to literate programming, which consists in exchanging the focus between code and comments. I believe that Coffeescript just got a literate processor, so the community may benefit from this in the near future. Because GHC supports it, it is also very popular in the Haskell community.
Re:JQuery Annotated Source by rossriley on Saturday April 27, 2013 @08:23AM (#5617573)
I did one for PHP a while back.

Not perfect, but here's the project: https://github.com/oneblackbear/phrocco

And here's an example: http://media.oneblackbear.com.s3.amazonaws.com/WaxUrl.html

Re:JQuery Annotated Source by pavel_lishin on Friday April 26, 2013 @01:51PM (#5614338)
One of backbone.js's example apps does this, and it was my favorite thing about their docs: http://backbonejs.org/docs/todos.html
Re:JQuery Annotated Source by malingo on Friday April 26, 2013 @02:28PM (#5614577)
raganwald put together annotated source for his coffeescript implementation of hashlife, also using Docco: http://recursiveuniver.se/docs/cafeaulife.html
Re:JQuery Annotated Source by wh-uws on Friday April 26, 2013 @01:17PM (#5614094)
Looking through jQuery's test suite provides alot of insight also

https://github.com/jquery/jquery/blob/master/test/unit/core....

Re:JQuery Annotated Source by salvadornav on Friday April 26, 2013 @05:15PM (#5615547)
Re:JQuery Annotated Source by leeoniya on Friday April 26, 2013 @01:26PM (#5614156)
i actually find docco-style docs more difficult to read with mostly single-line notes due to the spacing :(

some sort of block folding would help a lot to follow code progression like a story. i'm not certain this is the best display type for all commenting styles.

Re:JQuery Annotated Source by chucknelson on Saturday April 27, 2013 @08:55AM (#5617635)
Agreed - when there is a comment for every line (or so it seems), it's a bit of comment overload, especially when looking at docco output.
Re:JQuery Annotated Source by scottharveyco on Friday April 26, 2013 @11:43PM (#5616722)
If anyone is interested in generating this type of documentation but for larger projects you might want to check out Groc

https://github.com/nevir/groc

It handles multiple languages and keeps your document structure in the navigation.

Re:JQuery Annotated Source by marcamillion on Saturday April 27, 2013 @12:18AM (#5616793)
I absolutely love this.

I would love to see a project (a curated version) like this for Rails.

Re:JQuery Annotated Source by nej on Friday April 26, 2013 @02:18PM (#5614523)
This is great.