One of the sub-tasks from Jeff's great suggestions thread, this task is to cover refactoring hook parsing code so that it no longer relies on a local CVS checkout. Here are some notes:
1. Begin by attempting to retrieve the newest versions of the hooks files from cvs.drupal.org/docs/developer/hooks (there should probably be a constant defined for which version of docs to retrieve so a 4.6 version of this module would append ?only_with_tag=DRUPAL-4-6 and so on.
2. Check files/hooks for existence of hook files.
3. If these files already exist, compare the $Id$ strings to determine if the ones from cvs.drupal.org are newer or older than what already exists locally. If newer, replace what's there.
Since that's quite a bit of logic to do, this probably should not be done on each module_builder page load; instead, maybe just perform rudimentary logic on each page load to determine if files/hooks exists. If it doesn't, initiate an update from cvs.drupal.org, otherwise just use the files. I could add an "Update hook documentation" button somewhere (at the top of the form? in administer >> settings >> module_builder?) that people could press manually to obtain updated information.
Comments
Comment #1
webchickHere's how I decided to implement this:
1. Implemented a new constant MODULE_BUILDER_VERSION to store which version of the hook docs to retrieve. Since at the moment Drupal 4.7 docs haven't been branched/tagged, I've kept this at 'HEAD' now, for the CVS version of this module. Once the docs get branched, I'll also branch this module so there's a 4.7 version and change this in that module to DRUPAL-4-7.
2. Changed the field in the settings hook to store a subdirectory in the files directory where hook documentation should be kept. I used a trick that image.module uses to create a function which automatically create the directory if it doesn't already exist. This same function will also go and automatically retrieve a copy of the files from cvs.drupal.org if you don't have a copy already.
3. Implemented a variable to store last update time (called, surprisingly enough, module_builder_last_update), and created a button to update the docs. This will go out to http://cvs.drupal.org/viewcvs/drupal/contributions/docs/developer/hooks/... and download new copies of the hook documentation files to the directory specified by module_builder's settings. I didn't bother with version checking of old vs. new, just blindly overwrite it with whatever's in CVS since this will never be older, only possibly newer.
I think that was it. It probably could use some additional error-checking (I seem to be pre-destined to only work on this module from like 2am - 6am ;)), and actually I've not tried it sans Internet connection which might screw it up. I'll check this out after I get some sleep.
Comment #2
(not verified) commented