# Nobs • Share Buttons (juiz-social-post-sharer)

## Hook docblocks

Every `apply_filters()` / `do_action()` has a docblock with an `@hook` tag. These
docblocks generate the public documentation (https://sharebuttons.social/doc/) through
JSDoc + wp-hookdoc (`hookdoc.json`, template in the git-ignored `documentation/` folder).
JSDoc parses them, not a PHP tool, so follow its syntax:

- Types in braces: `@param {string} $name Description.`, `@return {array} Description.`
  A docblock with `@return` is documented as a filter, without it as an action.
- Nested array keys use dots: `@param {array} $opts.key Description.`
- A default value goes after `=`, and **must not contain a space**: JSDoc stops the
  name at the first space, and the rest ends up in the description.
  When the default has a space, wrap the name in brackets:
  `@param {string} [$text="Total: "] The text to be used.`
  (the page then shows the parameter as `<optional>`).
- Inline Markdown is limited to `` `code` `` and `**bold**`. Link another hook with
  `{@link hook_name}` and a tutorial with `{@tutorial name}`.
- New hooks get `@since x.y.z First version`.

Check a docblock change by generating the doc into a temporary folder:
`npx jsdoc inc -c hookdoc.json -d <tmp folder>` (not `npm run doc`, which empties
`../nobs-share-buttons-doc/`).
