As per http://drupal.org/node/515870 (and just because it's a good idea), we need to make sure that all hooks in Drupal 7 have documentation before release.

As an aid to doing that, I grepped the source of Drupal 7 and compiled a list of hooks called using module_invoke(), module_invoke_all(), drupal_alter(), node_invoke(), user_invoke(), and via module_implements() loops. I am not sure it is entirely accurate or complete, but it's a lot better than nothing. See attached file.

Note that I made up names for at least one, such as hook_query_TAG_alter. It may be documented under another name.

The next step in this task is to make sure that all of these hooks actually have documentation (header and example) in files modules/whatever/whatever.api.php so that they will appear on api.drupal.org.

My approach will be to compile a list of hooks that are documented (again using a script/grep), and compare to the list of hooks that should be. Then probably will have to verify that they match, and then manually decide what is appropriate to do in cases where they don't.

CommentFileSizeAuthor
#4 tofix.txt2.96 KBjhodgdon
#2 differences.txt2.23 KBjhodgdon
#1 dochooks.txt6.08 KBjhodgdon
allhooks.txt6.14 KBjhodgdon
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jhodgdon’s picture

FileSize
6.08 KB

OK, here's a list of the hooks that have documentation (I grepped in *.api.php files for "function hook_").

jhodgdon’s picture

FileSize
2.23 KB

And here's a diff file between the two.

Anything with a < means I think it's a hook and I think it is NOT currently documented.

Anything with a > means it is currently documented but I am not sure if it's really a hook (but it probably just means I missed it).

Gosh, that's a big list to go through and see what's really happening!!!!!!!!!

Sigh.

jhodgdon’s picture

NOTE: I am making an annotated list of what needs to be done from the differences file - checking through all of them... will report back shortly...

There were a few left-over files in my area (old versions, etc.), so a few of the hooks were bogus... Also, I apparently missed boostrap_invoke() and _field_invoke_*() functions as more ways to invoke hooks. And there are of course a few places where someone didn't use module_invokes() or any of those other things at all, sigh.

jhodgdon’s picture

FileSize
2.96 KB

OK. Phew.

There are about 30 hooks that need documentation.

See attached file for the list, along with notes of where they are invoked. A few separate issues have been filed, as noted. Otherwise, they are open for patches...

jhodgdon’s picture

Issue tags: -Needs documentation

Now that there's a list of hooks that need doc, I guess it's a critical issue. Probably even a critical meta-issue.

I suggest that anyone who wants to help with this issue
a) File a separate issue with a title something like "hook_abc is not documented", with component "documentation", project Drupal, category "bug report", priority "normal" (so as not to clutter up the critical issue queue). You could put a couple of related hooks into the same issue if you want.
b) Comment here, with a link to the issue, explaining which hooks you have taken charge of.
c) This file has all kinds of helpful information on where the hooks are called, etc.: http://drupal.org/files/issues/tofix.txt

Here are the hooks that need doc. As people file issues, I'll update this list with links to the issues.

UPDATE - As of April 23, 2010, all of the issues here at least have patches, except the extra issue at the bottom about hooks that lack function bodies in the Field API! Most patches have been reviewed even; a few still need review. YIPPEE!!!!

hook_ajax_render_alter - FIXED - #713794: hook_ajax_render_alter() is undocumented
hook_archiver_info_alter - FIXED - #708574: hook_archiver_info_alter() is not documented
hook_batch_alter - FIXED - #717602: hook_batch_alter() is undocumented
hook_countries_alter - FIXED - #717666: hook_countries_alter() is undocumented
hook_cron_queue_info_alter - FIXED - #718648: hook_cron_queue_info_alter() is not documented
hook_date_format_types_alter - FIXED - #718894: hook_date_format_types_alter() is not documented
hook_field_attach_purge - FIXED - #776694: hook_field_attach_purge is not documented
hook_field_extra_fields_alter - FIXED - #719432: hook_field_extra_fields_alter() is undcoumented
hook_field_languages - Went away - see #776982: hook_field_languages() is not documented
hook_field_purge_field - FIXED - #777092: Field purge hooks are not documented
hook_field_purge_instance - FIXED - #777092: Field purge hooks are not documented
hook_field_storage_purge - FIXED - #777098: Field storage purge hooks are not documented
hook_field_storage_purge_field - FIXED - #777098: Field storage purge hooks are not documented
hook_field_storage_purge_instance - FIXED - #777098: Field storage purge hooks are not documented
hook_field_storage_update_field - FIXED - #777100: hook_field_storage_update_field is not documented
hook_field_ui_view_modes_tabs - FIXED - #777102: hook_field_ui_view_modes_tabs() is undocumented
hook_field_update_forbid - FIXED - #775936: hook_field_update_forbid() is undocumented
hook_filetransfer_backends - FIXED - #727282: hook_filetransfer_backends() is undocumented
hook_hook_info_alter - FIXED - #777080: hook_hook_info_alter() is not documented
hook_language_init - Someone fixed this one.
hook_language_switch_links_alter - FIXED - #675144: doc header problem in translation_language_switch_links_alter()
hook_process - FIXED - #736326: hook_process() and associated hooks are undocumented
hook_preprocess - FIXED - #736326: hook_process() and associated hooks are undocumented
hook_rdf_namespaces - FIXED - #623684: Improve documentation of rdf module
hook_search_page - FIXED - #171317: hook_search_page not appearing on api.drupal.org
hook_themes_disabled - FIXED - #491214: implement the top level Appearance / Choose Theme admin page
hook_themes_enabled - FIXED - #491214: implement the top level Appearance / Choose Theme admin page
hook_token_info_alter - FIXED - #673462: Complete API documentation for hook_tokens(), hook_token_info(), hook_token_info_alter() needed
hook_trigger_info_alter - FIXED - #776728: hook_trigger_info_alter() is undocumented
hook_updater_info - FIXED - #605270: Document new update manager hooks
hook_updater_info_alter - FIXED - #605270: Document new update manager hooks
hook_verify_update_archive - FIXED - #605270: Document new update manager hooks

See also: #675116: field.api.php hook documentation is incomplete - for several hooks that have doc headers but no function bodies.

webchick’s picture

Category: task » bug

Wow. Thank you for doing this.

jhodgdon’s picture

You're welcome!

Two of the above issues have been patched/committed... So there are now "only" 24 hooks above without issues filed, plus 3 filed issues.

12 of the Completely Undocumented are field hooks. Probably someone who knows about the field API should take care of those, as well as #675116: field.api.php hook documentation is incomplete.

7 of the Undocumented are _alter hooks, where the non_alter hook has been documented, so they should be easy.

The other 5 need someone to research what their inputs/outputs are and write the doc. Hopefully the notes in http://drupal.org/files/issues/tofix.txt will at least provide the starting point for research, and hopefully at least one module in core currently implements them so there will be an example.

Anyone who wants to help on this is most welcome! :)

webchick’s picture

Issue tags: +Needs documentation

Tagging so those working on API documentation fixes can find it.

jhodgdon’s picture

Those working on API doc issues should see this already, because it's in the documentation component. :) I thought Needs Doc was usually for things needing to go into the module/theme upgrade guides?

webchick’s picture

Generally speaking, it is, but tagging it this way makes it really convenient for me to point everyone who wants to help with critical API docs at one tag. It's also related to changes in APIs so I think it's appropriate to re-use the same thing here.

jerdiggity’s picture

Priority: Critical » Normal

Adding issue to this collective list then downgrading the issue's priority as per catch/webchick:

... So, when you see a critical issue which is only open due to upgrade documentation, please downgrade it and point here.

webchick’s picture

Priority: Normal » Critical

No, this one is "special" and deserves its own critical status.

Dave Reid’s picture

Yes, this one definitely needs to stay critical.

gdd’s picture

jhodgdon’s picture

bump!

So all of the hooks at least have issues now (see #5 above). There are still a few that need work or initial patches, but we're getting there -- special thanks to robeano and heyrocker!

catch’s picture

Priority: Critical » Normal

Per discussion with webchick, moving this to the 'release checklist' (also this one gets us under 99 criticals, we can always move it back later). See http://drupal.org/project/drupal

jhodgdon’s picture

Status:
Everything has now been patched, except
#675116: field.api.php hook documentation is incomplete

That issue still needs a considerable amount of work, filling in function bodies for field API hooks.

jhodgdon’s picture

Status update:

OPEN: #675116: field.api.php hook documentation is incomplete
There are still several hooks in there that are missing function bodies. It has been proposed as a Google Code-In project (see that issue for details).

NEEDS WORK: #929208: Path hook api docs are missing function bodies
This issue was reported recently, and has a patch that just needs a little tweaking

jhodgdon’s picture

Issue tags: -Needs documentation

Removing redundant tag. Only #675116: field.api.php hook documentation is incomplete is still open on this issue.

figaro’s picture

jhodgdon’s picture

Status: Active » Closed (duplicate)

Since we're down to just one issue now, I think it's time to close this issue.