This is an archive of the discontinued Mercurial Phabricator instance.

help: assigning categories to existing commands
ClosedPublic

Authored by rdamazio on Oct 13 2018, 6:19 AM.

Details

Summary

I'm separating this into its own commit so people can bikeshed over the actual
categorization (vs the support for categories). These categories are based on
the help implementation we've been using internally at Google, and have had
zero complaints.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

rdamazio created this revision.Oct 13 2018, 6:19 AM
rdamazio updated this revision to Diff 12041.Oct 13 2018, 6:44 AM
rdamazio updated this revision to Diff 12062.Oct 13 2018, 8:44 AM
yuja added a subscriber: yuja.Oct 14 2018, 4:42 AM
  1. Command categories.

+CATEGORY_REPO_CREATION = _('Repository creation')
+CATEGORY_REMOTE_REPO_MANAGEMENT = _('Remote repository management')
+CATEGORY_COMMITTING = _('Change creation')
+CATEGORY_CHANGE_NAVIGATION = _('Change navigation')
+CATEGORY_CHANGE_MANAGEMENT = _('Change manipulation')
+CATEGORY_CHANGE_ORGANIZATION = _('Change organization')
+CATEGORY_WORKING_DIRECTORY = _('Working directory management')
+CATEGORY_FILE_CONTENTS = _('File content management')
+CATEGORY_IMPORT_EXPORT = _('Change import/export')
+CATEGORY_MAINTENANCE = _('Repository maintenance')
+CATEGORY_HELP = _('Help')
+CATEGORY_MISC = _('Miscellaneous commands')
CATEGORY_NONE = _('Uncategorized commands')

Can you make these constants untranslated (e.g. 'help' instead of _('Help'))
and map them to corresponding translation later?

And, perhaps they can be moved to registrar.command so we can avoid
importing help.py everywhere.

rdamazio updated this revision to Diff 12122.Oct 14 2018, 6:32 AM
In D5067#76195, @yuja wrote:

Can you make these constants untranslated (e.g. 'help' instead of _('Help'))
and map them to corresponding translation later?
And, perhaps they can be moved to registrar.command so we can avoid
importing help.py everywhere.

See if this is what you had in mind. Also updated all parent changesets accordingly.

yuja added a comment.Oct 14 2018, 9:02 AM
See if this is what you had in mind. Also updated all parent changesets accordingly.

Yeah, that's it, thanks. I'll review the new series.

This revision was automatically updated to reflect the committed changes.
yuja added a comment.Oct 14 2018, 11:30 AM

+# Add our category before "Repository maintenance".
+help.CATEGORY_ORDER.insert(
+ help.CATEGORY_ORDER.index(command.CATEGORY_MAINTENANCE),
+ _HELP_CATEGORY)
+help.CATEGORY_NAMES[_HELP_CATEGORY] = 'GPG signing'

Moved this to extsetup(), since otherwise it could leave phantom None
on import failure.

yuja added a comment.Oct 14 2018, 11:30 AM

Queued the first 5 patches, thanks.

  1. Human-readable category names. These are translated.
  2. Extensions with custom categories should add their names here.

To make these being collected to i18n catalog, we have to wrap them with _().
But that can be fixed later.

CATEGORY_NAMES = {
+ registrar.command.CATEGORY_REPO_CREATION: 'Repository creation',
+ registrar.command.CATEGORY_REMOTE_REPO_MANAGEMENT:
+ 'Remote repository management',
+ registrar.command.CATEGORY_COMMITTING: 'Change creation',
+ registrar.command.CATEGORY_CHANGE_NAVIGATION: 'Change navigation',
+ registrar.command.CATEGORY_CHANGE_MANAGEMENT: 'Change manipulation',
+ registrar.command.CATEGORY_CHANGE_ORGANIZATION: 'Change organization',
+ registrar.command.CATEGORY_WORKING_DIRECTORY:
+ 'Working directory management',
+ registrar.command.CATEGORY_FILE_CONTENTS: 'File content management',
+ registrar.command.CATEGORY_IMPORT_EXPORT: 'Change import/export',
+ registrar.command.CATEGORY_MAINTENANCE: 'Repository maintenance',
+ registrar.command.CATEGORY_HELP: 'Help',
+ registrar.command.CATEGORY_MISC: 'Miscellaneous commands',

registrar.command.CATEGORY_NONE: 'Uncategorized commands',

Perhaps, using all-lowercase names is our convention.