The new logic renders the commands belonging to each category in turn.
Commands with an unregistered category are at risk of getting skipped
because their category is not in the list. By comparing the list of all
commands to a log of processed commands, we can detect commands with
unregistered categories and fail with an error message.
Details
- Reviewers
martinvonz - Group Reviewers
hg-reviewers - Commits
- rHG037a97d62625: gendoc: guarantee that all commands were processed
Diff Detail
- Repository
- rHG Mercurial
- Lint
Lint Skipped - Unit
Unit Tests Skipped
Event Timeline
I think this patch will be simpler if you create the dict I suggested on D6326. You could then put the check for debug commands in that initial loop. You could also put the check just after that loop (any categories found that are not in help.CATEGORY_ORDER would be unregistered).
doc/gendoc.py | ||
---|---|---|
200–209 | No need to use exceptions here (KeyError could potentially be raised by something we didn't expect and then we'd misdiagnose it here). I think it's clearer like this: category = helpcategory(cmd) if category in cmdsbycategory: raise ... cmdsbycategory[category].append(cmd) | |
202 | I think a previous version of this patch ignored uncategorized debug commands. Will this version error out? |
doc/gendoc.py | ||
---|---|---|
202 | It doesn't error out, I checked before uploading. Debug commands have CATEGORY_NONE; see also below. The purpose of this patch is to give confidence that no commands got 'lost' as we moved from 'process every command' (which guarantees every commands gets processed) to 'process every registered category' (where commands can get skipped if their category isn't registered). The previous version of this patch compared an expected list of commands to a log of processed commands. Because the main command-rendering loop skipped debug commands, I manually removed them from the expected list, too. That's why it ignored debug commands. The current version of this patch checks at command-sorting time that every command is part of a registered category. Commands with no category (such as debug commands) get sorted into CATEGORY_NONE, which is a known category displayed as "Uncategorized commands". We've guaranteed that the command-rendering loop will see every command, and what it skips or keeps is up to the rendering logic. |
doc/gendoc.py | ||
---|---|---|
202 |
Ah, that makes sense. |
I think a previous version of this patch ignored uncategorized debug commands. Will this version error out?