doc/gendoc.py
changeset 42249 3816e361e3d8
parent 42248 0786b791b3b5
child 42250 037a97d62625
equal deleted inserted replaced
42248:0786b791b3b5 42249:3816e361e3d8
   183         f = c.split(b"|")[0]
   183         f = c.split(b"|")[0]
   184         f = f.lstrip(b"^")
   184         f = f.lstrip(b"^")
   185         h[f] = c
   185         h[f] = c
   186     cmds = h.keys()
   186     cmds = h.keys()
   187 
   187 
   188     if True:
   188     def helpcategory(cmd):
   189         for f in sorted(cmds):
   189         """Given a canonical command name from `cmds` (above), retrieve its
       
   190         help category. If helpcategory is None, default to CATEGORY_NONE.
       
   191         """
       
   192         fullname = h[cmd]
       
   193         details = cmdtable[fullname]
       
   194         helpcategory = details[0].helpcategory
       
   195         return helpcategory or help.registrar.command.CATEGORY_NONE
       
   196 
       
   197     # Print the help for each command. We present the commands grouped by
       
   198     # category, and we use help.CATEGORY_ORDER as a guide for a helpful order
       
   199     # in which to present the categories.
       
   200     cmdsbycategory = {category: [] for category in help.CATEGORY_ORDER}
       
   201     for cmd in cmds:
       
   202         cmdsbycategory[helpcategory(cmd)].append(cmd)
       
   203 
       
   204     for category in help.CATEGORY_ORDER:
       
   205         categorycmds = cmdsbycategory[category]
       
   206         if not categorycmds:
       
   207             # Skip empty categories
       
   208             continue
       
   209         # Print a section header for the category.
       
   210         # For now, the category header is at the same level as the headers for
       
   211         # the commands in the category; this is fixed in the next commit.
       
   212         ui.write(sectionfunc(help.CATEGORY_NAMES[category]))
       
   213         # Print each command in the category
       
   214         for f in sorted(categorycmds):
   190             if f.startswith(b"debug"):
   215             if f.startswith(b"debug"):
   191                 continue
   216                 continue
   192             d = get_cmd(h[f], cmdtable)
   217             d = get_cmd(h[f], cmdtable)
   193             ui.write(sectionfunc(d[b'cmd']))
   218             ui.write(sectionfunc(d[b'cmd']))
   194             # short description
   219             # short description