At lunch one day at the OSCMS conference in Vancouver, a few of us were sitting around the lunch table, sort of lamenting the fact that there was so much work needed to create new modules. First you have to remember, "What are the hooks I need again?" Then you have to remember, "What are the arguments for the such-and-such hook again?" and so on and so on. Wouldn't it be cool if there was a tool that would let you pick what kind of module you wanted to make, would automatically select the hooks you needed, and then generate the code for you?

Well, Module Builder is intended to be such a tool, as well as a tool to help new developers get on their feet with module development and learn how hooks work and so on. I've been kind of toiling away on it in my spare time for about a month now, have shown it to the developers' list a few weeks back, and now I think it's maybe ready to show it to a broader audience.

In a nutshell, here's how it works:

1. You enable the module just like any other module.
2. You go to the "module builder" menu (which is tied to an "access module builder" permission)
3. You fill in details about your module, such as the name, description, and so on.
4. You can select from either pre-defined hook groups, and/or expand the fieldsets to select specific hooks you need.
5. Click "Submit" and receive a textarea with the code to your module inside. Simply copy/paste into a .module file, save it to your modules directory, and you're good to go!

It has a couple kind of nifty features, including:

1. The hook list is parsed directly from the hook documentation in CVS. The first time you hit either the settings page or the form, it will grab these files for you. Afterwards, you can keep them updated by hitting the "Update" button in the settings page (thanks to jjeff for this suggestion).
2. If you don't like the default output of the hooks, or you want to define your own custom hook groupings, you can! Just copy the .template files and rename them to XXXX-custom.template, and then your custom template will override the defaults.
3. It has an option to turn off the comments directed to newbies if you're an advanced developer and only want to use the tool for generating skeleton code (thanks to hunmonk for this suggestion).

Anyway, please give it a shot and let me know what you think! :) Note that there is only a CVS version available right now, because there will probably be bugs, and I *know* there will be improvements that can be made. ;) Please use the issue tracker to log any bugs or feature requests (and patches! :D).

I'm especially interested in anything that will help usability-wise and documentation-wise to get new developers up to speed faster, and ways in which to make this a more useful tool to seasoned developers as well. If you have some ideas of better/additional hook groupings, or comments on the architecture, please let me know that as well.

Thanks, and enjoy!

Comments

kae’s picture

fantastic!

sameersingh’s picture

I was just about to create something similar. It worked like a charm....

ckclarke’s picture

twohills’s picture

Way cool, coulda used this three months ago :=D Still could use it big time, but I'm drupal 4.6. This may be a dumb newbie question, but because it is CVS that means 4.7 only, right? Something for me to look forward to ;-)

webchick’s picture

It wouldn't be too hard to back-port this though. Would just need to re-do:

1. The forms stuff (of course :\)
2. A few of the example hooks will have changed from 4.6 to 4.7 so the templates would need to be updated for those
3. Some minor stuff like getting rid of calls to drupal_add_js and such.

Otherwise, the module's not using any fancy 4.7 features that I can think of. I might get around to back-porting it one of these days, if people think that would be helpful.

twohills’s picture

I'm guessing that most people doing development of modules will be newer sites. Your main target audience is newbies I think?? I would think most of those are still choosing to use 4.6 but for how much longer?
So my opinion would be stick to working on the CVS version and the rest of us will just have to wait until we upgrade. On the other hand, what do i know about the profile of the community. How could we find out where the demand really lies?
And how many other *new* modules are coming out with 4.6 versions?

Dublin Drupaller’s picture

Hey Webchick..

Just had a quick look at your new module...wow! what a blinking great idea and it appears to work a charm.

incidentally, I love the way it tells you the last time you updated your hook documentation. inspired idea.

I was looking for something similar to tell me - on one settings page - which enabled & core modules had been updated since I had them installed.

Could that be adapted to do the same?

either way..great work with the module.

Dub

Currently in Switzerland working as an Application Developer with UBS Investment Bank...using Drupal 7 and lots of swiss chocolate