gendoc: group commands by category in man page and HTML help
Make Mercurial's man page and HTML help group commands by category, and
present the categories in a helpful order. hg help already does this;
this patch uses the same metadata.
This patch uses the same header level for command categories and for
commands. A subsequent patch will push the command headers down one
Differential Revision: https://phab.mercurial-scm.org/D6326