The Source for Java Technology Collaboration
User: Password:



Kirill Grouchnikov

Kirill Grouchnikov's Blog

This little HTML renderer in my head

Posted by kirillcool on May 23, 2006 at 02:01 PM | Comments (5)

Back in 1995 when i finally joined the Internet wave (i know, kinda late), i was somewhat puzzled by the seeming simplicity of HTML (compared to the nice layout it was able to produce). This wasn't the first time that i had to learn a layout language (the first one was circa 1988 when i learned a custom printer syntax for making fancy ads on selling my sister's apartment). So, i printed out the HTML specification (and back in the days of HTML 3.0 it was pretty straightforward), came back to the dorms, wrote (and rewrote) quite a few pages by hand (on paper) and went back the following morning to the computer lab feeling like a budding HTML guru.

Back in the day it was fun feeling like that, when the Netscape composer first came out and totally screwed my perfectly aligned HTML pages. Not to speak of the horrors of the first versions of FrontPage and long-deceased (is it?) HotDog (i think that's the name). But i digress.

One of the major points that set Java apart from C++ was Javadocs. You know, you comment your code (or at least you're supposed to), run this clunky command and it spits hundreds of thousands of HTML pages, all interlinked to create a falsehood of well-documented project. Not only that, it can also take any (valid or invalid) HTML in it. It just doesn't care. So, instead of writing a nice documentation in Word (the fearsome), HTML (the tiresome) or even LATEX (the cumbersome), you just stick the "This function returns the value of XXX attribute" in all your getters and your manager is satisfied (as time goes by you don't even have to type it yourself, just let the IDEs do it). But what about code samples, formatting and such? Don't worry, just stick HTML in it and it'll be fine...

Fine for whom exactly? I don't know about you, but i only read (actually read, not dismiss the annoying IDE popups every time i accidentally pause with the cursor over some damn method invocation) Javadocs on JDK classes. When i write Javadocs for my side projects, i don't really go and explore the entire web of generated HTML. It's enough for me that the javadoc generator didn't issue any warnings. But i digress once again.

So when i come to comment some function and provide a nice explanation about what it does and perhaps throw in some code sample, i need to start thinking in HTML (instead of thinking about the content). It gets even worse when i need to modify existing Javadoc section. That little HTML parser we all have in our heads for the past 10+ years start chewing on some (hopefully valid) markup and humming "Hey, look here, what does this ul do here in the middle of the table?"I have to admit that the HTML parser in my head gets better and better every year. You know, when you learn a foreign language and you know that you've suddenly become good at it? It's when you read something and don't translate it to your native language, when instead it goes straight to the images and associations in your head? The same with HTML for me. You know, like Cypher says about Matrix code, "All I see now is blonde, brunette, redhead."

And this is not good. We're not supposed to be HTML renderers. We need to focus on the code. If we need to write documentation inside the code, the IDE should provide us with WYSIWYG in-place editors (something like this is planned for Fortress). I hope we will be there in 10-15 years. I think by that time the keyboard and the mouse will be replaced by something more "human", like hand-writing recognition fused with touch-pads and eyeball tracking devices. When you want to add a diagram (like in JAXB architecture document), you just draw it inside the code and let the IDE translate it to a IDE-independent format that can be easily processed and converted to great-looking documentation. If i want to change the in-code documentation, i just start dragging stuff around, erasing bits that i don't like and adding pieces that are missing.

And last, but not the least. I don't get this "Wiki-boom". I mean, is the syntax supposed to be simpler than HTML? Here, any sequence of prime-Mersenne dashes followed by matching number of plus signs is interpreted as a heading. Right guys, so more flexible than <h2>. At least with LATEX you get real low-level control. We all laughed when Brooke Shields' character was fooled to believe that Drake has an evil twin named Hans. This is just another syntax for the same thing, just one more renderer to stuff in your skull.

Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • Funny article, i think anybody working regulary with HTML (like all Java developers that write documentation) have this little parser in head.
    I dream to see in Eclipse an HTML editor inside Java code to edit comment.Perhaps a plug-in already exist ?

    Posted by: alois_cochard on May 23, 2006 at 10:51 PM

  • We've taken a slightly different approach. By adding tags to the source code we can extract snippets of the code for inclusion in regular html documentation. A post processor then runs and merges the code and the html documentation. We also have a primitive editor to assist in inserting the custom tags into html.

    An example of the generated docuemntation can be found here

    Extending the approach a little further it would be possible to extend the process and embed it in the build process so that the examples are always up-to-date.

    If anyone's interested we could open source the tool, even in its current basic state. Ultimately we would like to have support for the tags in a good html editor -we've looked at some Java based editors and they may even fit the bill.

    Posted by: luano on May 25, 2006 at 07:05 AM


  • Hey Kirill :) I agree with you that it would be really great if tools rendered javadocs live. It's usually most convenient for me to Alt-G into standard libraries and read JDK javadocs there, rather than whatever way you meant to it (maybe F1?) Problem is there is usually major HTML markup in those javadocs that i gotta filter out...

    In the meantime, I wish that Netbeans was better at javadoc'ing, eg. had autocompletion and refactoring of @see like Eclipse

    Ps. My favourite HTML viewer is Alt Tab F5 ;)

    Posted by: evanx on May 25, 2006 at 07:07 AM

  • Luan, you may wish to see this Javalobby discussion that mentions some tool that sounds like what you're having (or is it the same)? If it's not the same, perhaps you can join forces and work on it together - just a suggestion.

    PS - i took a liberty and added some formatting to your comment. Note that unlike some other sites, the comment section of java.net blogs is completely HTML-based so you need to use <br>'s and can most certainly use <a>'s

    Posted by: kirillcool on May 25, 2006 at 07:16 AM

  • Evan,
    Actually, Eclipse does a pretty good job showing the javadoc for the element under mouse in a tooltip window. If you click F2, you go inside that window and can scroll and resize it - no live-HTML editing yet :( I would just prefer having (at least for the first stage) an option for switching between text view and the HTML read-only view for the javadoc sections in the IDEs. This can be really powerful, at least for checking that you wrote all your doc sections correctly (instead of hovering with the mouse or running the generator and checking in the browser).
    First IDE that does this - respect.

    Posted by: kirillcool on May 25, 2006 at 07:20 AM





Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds