changeset 20081:93f9d11603d8

doc: show details of command options in pages generated by docutils Before this patch, HTML/man pages generated by docutils don't show details of each command options, whether it should take argument or not for example, even though "hg help" does. This patch shows details of command options as same as "hg help" shows. This patch uses "--option <VALUE[+]>" style instead of "--option <VALUE> [+]" used in output of "hg help", because docutils requires that option argument strings starts with "<" and ends with ">".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Fri, 08 Nov 2013 14:42:09 +0900
parents c845b1a95eed
children b04cc8651a63
files doc/gendoc.py
diffstat 1 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/doc/gendoc.py	Tue Nov 05 09:43:26 2013 +0100
+++ b/doc/gendoc.py	Fri Nov 08 14:42:09 2013 +0900
@@ -40,11 +40,16 @@
             shortopt, longopt, default, desc, optlabel = opt
         else:
             shortopt, longopt, default, desc = opt
+            optlabel = _("VALUE")
         allopts = []
         if shortopt:
             allopts.append("-%s" % shortopt)
         if longopt:
             allopts.append("--%s" % longopt)
+        if isinstance(default, list):
+            allopts[-1] += " <%s[+]>" % optlabel
+        elif (default is not None) and not isinstance(default, bool):
+            allopts[-1] += " <%s>" % optlabel
         desc += default and _(" (default: %s)") % default or ""
         yield (", ".join(allopts), desc)
 
@@ -71,8 +76,14 @@
 def showdoc(ui):
     # print options
     ui.write(minirst.section(_("Options")))
+    multioccur = False
     for optstr, desc in get_opts(globalopts):
         ui.write("%s\n    %s\n\n" % (optstr, desc))
+        if optstr.endswith("[+]>"):
+            multioccur = True
+    if multioccur:
+        ui.write(_("\n[+] marked option can be specified multiple times\n"))
+        ui.write("\n")
 
     # print cmds
     ui.write(minirst.section(_("Commands")))
@@ -157,12 +168,18 @@
         if opt_output:
             opts_len = max([len(line[0]) for line in opt_output])
             ui.write(_("Options:\n\n"))
+            multioccur = False
             for optstr, desc in opt_output:
                 if desc:
                     s = "%-*s  %s" % (opts_len, optstr, desc)
                 else:
                     s = optstr
                 ui.write("%s\n" % s)
+                if optstr.endswith("[+]>"):
+                    multioccur = True
+            if multioccur:
+                ui.write(_("\n[+] marked option can be specified"
+                           " multiple times\n"))
             ui.write("\n")
         # aliases
         if d['aliases']: