Access to Package Documentation Expanded to Include Classes

Yesterday I posted a blog entry about a new feature that I added to that made it easy to look up package documentation. Within minutes of posting I had a feature request to extend this to classes. In a few minutes today I added that feature to the script on the server, so you now have easy access to class documentation as well. The class documentation is dependent on proper cases for package and class names, so you’ll need to be careful about your upper and lower cases. But, heading to will now send you to the proper documentation page on Adobe’s LiveDocs.

For those of you interested, here’s the PHP code that does this. Its pretty simple – just 29 lines. Improvements are appreciated – just add them to the comments. This PHP script gets run on any 404 error for<?php$ArrayOfRequest = explode(".", $_SERVER["REQUEST_URI"]);$URL = "";$Package = "";$Class = FALSE;$firstchar = substr(end($ArrayOfRequest),0,1);if( ord( $firstchar) > 64 && ord($firstchar) < 91 )$Class = TRUE;if( $Class === FALSE ){foreach( $ArrayOfRequest as $Package ){$URL .= $Package."/";}header("Location: ".$URL."package-detail.html");}else{$ClassName = array_pop( $ArrayOfRequest );foreach( $ArrayOfRequest as $Package ){$URL .= $Package."/";}header( "Location: ".$URL.$ClassName.".html" );}?>

2 Responses to Access to Package Documentation Expanded to Include Classes

  1. senocular says:

    There’s also the issue around namespace and function definitions (like setInterval) whose names, like packages, are lowercase. I thought about this when I first suggested identifying classes, but the inclusion of class recognition makes it no better or worse for these other definitions.I guess the next thing to do would be to actually have a lookup for definitions to be able to try and identify a term and retrieve its full location rather than just using the term as the location itself.

  2. Mark says:

    Hey Mike,Thanks for adding that… and you’re oh so close to perfection. I’m not sure how hard this would be, but it would be great if you didn’t have to know the full package to get results for classes. One of the great things about the php site that makes it so helpful is that you don’t have to know too much about what you’re searching to get results. You can just type the function name you’re looking for and voilĂ . It would be nice if you could just type in the class name on and pull up the documentation (non-case-sensitive) in that same vain.Thanks again for your work on this!I think if you could add this feature everyone will use it.