Skip to content

Document WordPress filters and actions #45

@remcotolsma

Description

@remcotolsma

WooCoomerce

WooCoomerce is using a PHP script to document their WordPress filters and actions:
https://github.com/woocommerce/code-reference/blob/0.7.0/generate-hook-docs.php

It extends https://www.phpdoc.org/ documentation by replacing the text <!-- hooks --> in the generated phpDocumentor output files: https://github.com/woocommerce/code-reference/blob/0.7.0/generate-hook-docs.php#L333.

https://woocommerce.github.io/code-reference/

ApiGen

Before June 2019, WooCommerce used ApiGen:
https://github.com/woocommerce/woocommerce/pull/24003/files

The ApiGen documentation was removed somewhere between WooCommerce version 3.6.0 and 3.7.0: https://github.com/woocommerce/woocommerce/tree/3.6.0/apigen. This documentation was also extended with the hooks / actions information via a PHP script: https://github.com/woocommerce/woocommerce/blob/3.6.0/apigen/hook-docs.php. It also had a "Direct known implementers" and "Indirect known implementers" sections, which are not yet available in the phpDocumentor documentation: woocommerce/code-reference#11.

WP Parser

The WordPress Code Reference on https://developer.wordpress.org/reference/ is generated using https://github.com/WordPress/phpdoc-parser, more information about this can be found at https://make.wordpress.org/docs/handbook/devhub/. This libary/plugin contains WP-CLI commands to export PHPDoc markup to JSON and convert it into WordPress posts, and insert into DB.

WordPress HookDoc

An alternative is to use https://github.com/matzeeable/wp-hookdoc which uses https://github.com/jsdoc/jsdoc.

GitHub Actions for WordPress

In https://github.com/10up/actions-wordpress#ideas the following idea is described:

Generate hook docs into a Markdown file that can be published into a subfolder, GitHub wiki, and/or gh-pages branch.

This idea was added by @helen almost 2 years ago:
10up/actions-wordpress@556d7a6

Update April 4, 2021

This idea has already been realized, see:
https://github.com/10up/actions-wordpress/blob/stable/hookdocs-workflow.md

Example

Hookster

Thinking about making a developer docs website for your WordPress theme or plugin? For my weekend project, I made a build script for theme/plugin authors to automatically generate data about all the actions and filters of their product.

https://twitter.com/jasonbobich/status/987836700989669376

https://github.com/themeblvd/hookster

Yoast Parser

phpDox

https://phpdox.net/

Other Plugins

There are also many other plugins that have documentation for their filters and actions:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions