documentation for function hooks

with drupal, one has to work with function names like "mymodule_foo()",
where the function that is used is named "hook_foo()".
the latter has documentation that can be accessed in the editor (ctrl-j).

Is there any way to get the documentation to show up for the custom implementation of a hook function too?


mymodule.php

/**
* Implements hook_action_info().
*/  
function mymodule_action_info() {
     ...
}




system.api.php

/**
* Declares information about actions.
*
* Any module can define actions, and then call actions_do() to make those
* actions happen in response to events. The trigger module provides a user
* interface for associating actions with module-defined triggers, and it makes
* sure the core triggers fire off actions when their events happen.
*
* An action consists of two or three parts:
* - an action definition (returned by this hook)
* - a function which performs the action (which by convention is named
*   MODULE_description-of-function_action)
* - an optional form definition function that defines a configuration form
*   (which has the name of the action function with '_form' appended to it.)
*
* The action function takes two to four arguments, which come from the input
* arguments to actions_do().
*
* @return
*   An associative array of action descriptions. The keys of the array
*   are the names of the action functions, and each corresponding value
*   is an associative array with the following key-value pairs:
*   - 'type': The type of object this action acts upon. Core actions have types
*     'node', 'user', 'comment', and 'system'.
*   - 'label': The human-readable name of the action, which should be passed
*     through the t() function for translation.
*   - 'configurable': If FALSE, then the action doesn't require any extra
*     configuration. If TRUE, then your module must define a form function with
*     the same name as the action function with '_form' appended (e.g., the
*     form for 'node_assign_owner_action' is 'node_assign_owner_action_form'.)
*     This function takes $context as its only parameter, and is paired with
*     the usual _submit function, and possibly a _validate function.
*   - 'triggers': An array of the events (that is, hooks) that can trigger this
*     action. For example: array('node_insert', 'user_update'). You can also
*     declare support for any trigger by returning array('any') for this value.
*   - 'behavior': (optional) A machine-readable array of behaviors of this
*     action, used to signal additionally required actions that may need to be
*     triggered. Currently recognized behaviors by Trigger module:
*     - 'changes_property': If an action with this behavior is assigned to a
*       trigger other than a "presave" hook, any save actions also assigned to
*       this trigger are moved later in the list. If no save action is present,
*       one will be added.
*       Modules that are processing actions (like Trigger module) should take
*       special care for the "presave" hook, in which case a dependent "save"
*       action should NOT be invoked.
*
* @ingroup actions
*/
function hook_action_info() {
  ...
}

7 comments

Not super clean, but if you just want to see the phpdocs, you could paste the function into the code

hook_action_info()

then click on it and hit alt+q to bring up the phpdocs.  The alt+q functionality doesn't work if the function is commented out.

0

ussher schrieb:

Not super clean, but if you just want to see the phpdocs, you could paste the function into the code

hook_action_info()

then click on it and hit alt+q to bring up the phpdocs.  The alt+q functionality doesn't work if the function is commented out.



thank you michael,
but while this is possible of course, it does not answer my question.
corrupting the code (if only temporary) cannot be a solution - apart from that, it would also be more cumbersome than to stick with the external api documentation.

0

Try @see PHPDoc tag, e.g.

/**
* Implements hook_action_info().
* @see hook_action_info()
*/  
function mymodule_action_info() {

  . . .
}

or even like this:

/**
* Implements @see hook_action_info().
*/  
function mymodule_action_info() {

  . . .
}

So when invoking documentation (Ctrl+Q) for mymodule_action_info(), you will be able to click on the link and display documentation for hook_action_info() in the same popup instead.

0

good enough - thank you very much.

0

Hey, thats cool.  didnt know about that, thanks Andriy :)

0

Starting from next eap @see works right in the editor - so positioning caret on target and pressing ctrl+Q and all other stuff (usages, nav, etc) will work right there.

0

Please sign in to leave a comment.