Skip to content
Snippets Groups Projects
Commit 29b9d0a0 authored by mickadoo's avatar mickadoo
Browse files

Add python script to generate hook list summary, add info for alterSettingsMetaData hook

parent 45270eaf
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python
import yaml
import re
from os.path import dirname, abspath, join
PROJECT_ROOT = dirname(dirname(abspath(__file__)))
DOCS_ROOT = join(PROJECT_ROOT, 'docs/')
MKDOCS_YAML_FILE = join(PROJECT_ROOT, 'mkdocs.yml')
OUTPUT_FILE = join(DOCS_ROOT, 'hooks/', 'list.md')
HEADER = """# All hooks
<!--
-- DO NOT EDIT
--
-- This entire page is auto-generated by the following command:
-- ./bin/tools generate:hooks-list
--
-->
This is an overview list of all available hooks, listed by category.
"""
def findBetween( s, first, last ):
start = s.index( first ) + len( first )
end = s.index( last, start )
return s[start:end]
def getSummary(hookFile):
content = open(join(DOCS_ROOT + hookFile), 'r').read()
summary = findBetween(content, '## Summary', '##')
summary = re.sub('This hook (is)?(was)?', '', summary)
summary = re.sub('\s+', ' ', summary).strip()
if not (summary.endswith('.')):
summary = summary + '.'
return summary
output = f = open(OUTPUT_FILE, 'w')
with open(MKDOCS_YAML_FILE, 'r') as f:
doc = yaml.load(f)
pages = doc["pages"]
for section in pages:
if "Hooks" in section:
hookSection = section.get("Hooks")
output.write(HEADER)
for section in hookSection:
categoryHooks = list()
category, hookList = section.popitem()
if isinstance(hookList, list):
for hookDetails in hookList:
hookName = hookDetails.iterkeys().next()
if re.match("^(<del>)?hook_civicrm_*", hookName):
categoryHooks.append(hookDetails)
if len(categoryHooks) > 0:
output.write('\n## {}\n\n'.format(category))
for hookDetails in categoryHooks:
hookName, hookFile = hookDetails.popitem()
summary = getSummary(hookFile)
output.write('* **[{}](/{})** - {}\n'.format(hookName, hookFile, summary))
# hook_civicrm_alterSettingsMetaData
hook_civicrm_alterSettingsMetaData($settingsMetadata, $domainID,
$profile);
## Summary
This hook is called when Settings have been loaded from the xml.
It is an opportunity for hooks to alter the data.
## Definition
This describes available settings
\ No newline at end of file
alterSettingsMetaData(&$settingsMetaData, $domainID, $profile)
## Parameters
- @param array $settingsMetaData Settings Metadata.
- @param int $domainID
- @param mixed $profile
# All hooks
<!--
-- DO NOT EDIT
--
-- This entire page is auto-generated by the following command:
-- ./bin/tools generate:hooks-list
--
-->
-- DO NOT EDIT
--
-- This entire page is auto-generated by the following command:
-- ./bin/tools generate:hooks-list
--
-->
This is an overview list of all available hooks, listed by category.
......@@ -14,7 +14,7 @@ This is an overview list of all available hooks, listed by category.
## Batch hooks
* **[hook_civicrm_batchItems](/hooks/hook_civicrm_batchItems.md)** - called when a CSV batch export file is about to be generated.
* **[hook_civicrm_batchQuery](/hooks/hook_civicrm_batchQuery.md)** - called when the query of CSV batch export is generated
* **[hook_civicrm_batchQuery](/hooks/hook_civicrm_batchQuery.md)** - called when the query of CSV batch export is generated.
## Case hooks
......@@ -60,7 +60,7 @@ This is an overview list of all available hooks, listed by category.
## GUI hooks
* **[hook_civicrm_alterMenu](/hooks/hook_civicrm_alterMenu.md)** - called when building CiviCRM&#039;s list of HTTP routes and should be used when you want to register custom paths or URLS.
* **[hook_civicrm_alterMenu](/hooks/hook_civicrm_alterMenu.md)** - called when building CiviCRM's list of HTTP routes and should be used when you want to register custom paths or URLS.
* **[hook_civicrm_buildAmount](/hooks/hook_civicrm_buildAmount.md)** - called when building the amount structure for a Contribution or Event Page, allowing you to modify the set of radio buttons representing amounts for contribution levels and event registration fees.
* **[hook_civicrm_caseSummary](/hooks/hook_civicrm_caseSummary.md)** - called when the manage case screen is displayed, and it allows the injection of label/value pairs which are rendered inside divs underneath the existing summary table.
* **[hook_civicrm_contact_get_displayname](/hooks/hook_civicrm_contact_get_displayname.md)** - called to retrieve the display name of a contact, allowing you to return a custom display name.
......@@ -77,7 +77,7 @@ This is an overview list of all available hooks, listed by category.
* **[hook_civicrm_summaryActions](/hooks/hook_civicrm_summaryActions.md)** - allows you to customize the context menu actions on the Contact Summary Page.
* **[<del>hook_civicrm_tabs</del>](/hooks/hook_civicrm_tabs.md)** - deprecated in 4.7 in favor of [hook_civicrm_tabset](/hooks/hook_civicrm_tabset.md).
* **[hook_civicrm_tabset](/hooks/hook_civicrm_tabset.md)** - called when composing the tabs interface used for contacts, contributions and events.
* **[hook_civicrm_xmlMenu](/hooks/hook_civicrm_xmlMenu.md)** - called when building CiviCRM&#039;s menu structure, which is used to render urls in CiviCRM.
* **[hook_civicrm_xmlMenu](/hooks/hook_civicrm_xmlMenu.md)** - called when building CiviCRM's menu structure, which is used to render urls in CiviCRM.
## Mail hooks
......@@ -122,7 +122,7 @@ This is an overview list of all available hooks, listed by category.
* **[hook_civicrm_alterMailingLabelParams](/hooks/hook_civicrm_alterMailingLabelParams.md)** - called to alter the parameters used to generate mailing labels.
* **[hook_civicrm_alterPaymentProcessorParams](/hooks/hook_civicrm_alterPaymentProcessorParams.md)** - allows you to modify parameters passed to the payment processor.
* **[hook_civicrm_alterSettingsFolders](/hooks/hook_civicrm_alterSettingsFolders.md)** - allows modules and extensions to scan for settings in additional folders.
* **[hook_civicrm_alterSettingsMetaData](/hooks/hook_civicrm_alterSettingsMetaData.md)**
* **[hook_civicrm_alterSettingsMetaData](/hooks/hook_civicrm_alterSettingsMetaData.md)** - called when Settings have been loaded from the xml. It is an opportunity for hooks to alter the data.
* **[hook_civicrm_angularModules](/hooks/hook_civicrm_angularModules.md)** - generates a list of AngularJS modules and allows you to register additional AngularJS modules. It is currently **experimental**.
* **[hook_civicrm_apiWrappers](/hooks/hook_civicrm_apiWrappers.md)** - allows you to add, override, or remove methods to be called before and after api calls &mdash; and to modify either the parameters or the result of the call.
* **[hook_civicrm_buildAsset](/hooks/hook_civicrm_buildAsset.md)** - fires whenever the system builds a semi-dynamic asset.
......@@ -138,7 +138,7 @@ This is an overview list of all available hooks, listed by category.
* **[hook_civicrm_eventDiscount](/hooks/hook_civicrm_eventDiscount.md)** - allows you to apply a customized discount to an event registration.
* **[hook_civicrm_export](/hooks/hook_civicrm_export.md)** - allows to manipulate or change the output of CSV during export.
* **[hook_civicrm_fileSearches](/hooks/hook_civicrm_fileSearches.md)** - allows you to add a reference to a file search service (e.g. Solr).
* **[hook_civicrm_geocoderFormat](/hooks/hook_civicrm_geocoderFormat.md)** - allows you to manipulate the Address object during geocoding, for instance to extract additional fields from the geocoder&#039;s returned XML.
* **[hook_civicrm_geocoderFormat](/hooks/hook_civicrm_geocoderFormat.md)** - allows you to manipulate the Address object during geocoding, for instance to extract additional fields from the geocoder's returned XML.
* **[hook_civicrm_import](/hooks/hook_civicrm_import.md)** - called after contacts have been imported into the system, and before the temp import table has been destroyed.
* **[hook_civicrm_membershipTypeValues](/hooks/hook_civicrm_membershipTypeValues.md)** - called when composing the array of membership types and their costs during a membership registration (new or renewal).
* **[hook_civicrm_notePrivacy](/hooks/hook_civicrm_notePrivacy.md)** - provides a way to override the default privacy behavior for notes.
......@@ -148,5 +148,3 @@ This is an overview list of all available hooks, listed by category.
* **[hook_civicrm_tokens](/hooks/hook_civicrm_tokens.md)** - called to allow custom tokens to be defined.
* **[hook_civicrm_tokenValues](/hooks/hook_civicrm_tokenValues.md)** - called to get all the values for the tokens registered.
* **[hook_civicrm_unhandledException](/hooks/hook_civicrm_unhandledException.md)** - fires when an unhandled exception (fatal error) occurs.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment