diff --git a/api.module b/api.module
index 48b7d7c..fa3588a 100644
--- a/api.module
+++ b/api.module
@@ -2031,7 +2031,7 @@ function api_cron() {
* Code with function names formatted as links.
*/
function api_link_code($code, $branch, $class_did = NULL) {
- return _api_link_documentation($code, $branch, $class_did, array('code function', 'code string'));
+ return _api_link_documentation($code, $branch, $class_did, array('code hook name', 'code theme hook name', 'code function', 'code string'));
}
/**
@@ -2112,6 +2112,26 @@ function _api_link_documentation($documentation, $branch, $class_did = NULL, $st
// '('.
'function' => '!(?<=^|\s)([a-zA-Z0-9_:]+)\(!',
+ // Find potential hook names in marked-up code inside a module_implements()
+ // or module_invoke_all() call.
+ 'code hook name' => '!
+ # Lookbehind for the invoke function.
+ (?<=
+ module_invoke_all\(
+ |
+ module_implements\(
+ |
+ module_invoke\(\$module,\ # This is to protect the trailing space from whitespace cleanup.
+ )
+ \'
+ # The hook name itself.
+ ([a-zA-Z0-9_]+)
+ \'
+ !x',
+
+ // Find potential theme hook names in marked-up code inside a theme() call.
+ 'code theme hook name' => '!(?<=theme\()\'([a-zA-Z0-9_]+)\'!',
+
// Find function names in marked-up code.
'code function' => '!([a-zA-Z0-9_]+)!',
@@ -2162,6 +2182,22 @@ function _api_link_documentation($documentation, $branch, $class_did = NULL, $st
$prepend_if_not_found = '\'';
$use_php = FALSE;
break;
+
+ case 'code hook name':
+ $prepend = '\'';
+ $append = '\'';
+ $prepend_if_not_found = '\'';
+ $use_php = FALSE;
+ $prefix = 'hook_';
+ break;
+
+ case 'code theme hook name':
+ $prepend = '\'';
+ $append = '\'';
+ $prepend_if_not_found = '\'';
+ $use_php = FALSE;
+ $prefix = 'theme_';
+ break;
}
if (count($stages) > 0) {
@@ -2171,7 +2207,7 @@ function _api_link_documentation($documentation, $branch, $class_did = NULL, $st
$callback = NULL;
}
- return api_split($patterns[$stage], $documentation, $callback_match, array($branch, $prepend, $append, $class_did, NULL, NULL, $use_php, $prepend_if_not_found), $callback, array($branch, $class_did, $stages));
+ return api_split($patterns[$stage], $documentation, $callback_match, array($branch, $prepend, $append, $class_did, NULL, NULL, $use_php, $prepend_if_not_found, NULL, $prefix), $callback, array($branch, $class_did, $stages));
}
/**
@@ -2247,11 +2283,13 @@ function api_split($pattern, $subject, $callback_match = NULL, $callback_match_a
* Text to prepend if object is not found (defaults to $prepend).
* @param $append_if_not_found
* Text to append if object is not found (defaults to $append).
+ * @param $prefix
+ * Prefix for $name when looking for a matching object.
*
* @return
* The text as a link to the object page.
*/
-function api_link_name($name, $branch, $prepend = '', $append = '', $class_did = NULL, $text = NULL, $is_link = FALSE, $use_php = TRUE, $prepend_if_not_found = NULL, $append_if_not_found = NULL) {
+function api_link_name($name, $branch, $prepend = '', $append = '', $class_did = NULL, $text = NULL, $is_link = FALSE, $use_php = TRUE, $prepend_if_not_found = NULL, $append_if_not_found = NULL, $prefix = '') {
static $local_objects = array(), $php_functions;
if (!isset($local_objects[$class_did])) {
@@ -2343,8 +2381,8 @@ function api_link_name($name, $branch, $prepend = '', $append = '', $class_did =
if ($is_link && isset($local_objects[$class_did]['group'][$name])) {
return $prepend . l($text, $local_objects[$class_did]['group'][$name]['url'], $local_objects[$class_did]['group'][$name]['options']) . $append;
}
- elseif (isset($local_objects[$class_did]['item'][$name])) {
- return $prepend . l($text, $local_objects[$class_did]['item'][$name]['url'], $local_objects[$class_did]['item'][$name]['options']) . $append;
+ elseif (isset($local_objects[$class_did]['item'][$prefix . $name])) {
+ return $prepend . l($text, $local_objects[$class_did]['item'][$prefix . $name]['url'], $local_objects[$class_did]['item'][$prefix . $name]['options']) . $append;
}
elseif ($use_php && isset($php_functions[$name])) {
$link = strtr(variable_get('api_php_funcpath', 'http://php.net/!function'), array('!function' => $name));