From LuaTeXWiki

Suggested guidelines to document callbacks:

  • Have an article for each callback, with a minimal example.
  • Let a page's title be the name of the callback it describes, so it is automatically linked to this page, meant as a general introduction. If the page title differs, change the link here from
  • Link all pages on callbacks to this general introduction, which should gather general information about callbacks (e.g. no need to reexplain callback.register() on each page).
  • Make code low-level, which means: no format-specific tricks, and nothing but callback.register() (we can redirect to the general introduction for discussion about the limitations of callback.register()). Basically, this means avoiding things like \documentclass{article} or even plain TeX's \bye. The code should be pure Lua and pure TeX (probably we can allow allocation macros like \newif and \newbox, though, since they are common to all formats), so the reader can simply paste it and process it as s/he prefers.
  • Commented code is better than pure code, although pure code is better than no code.