doc: translate from :hg:`help config` to a valid link to hgrc.5.html
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Thu, 11 Feb 2016 23:15:34 +0900
changeset 28075 63eae465095e
parent 28074 a1924bc6e267
child 28076 18c6b271579b
doc: translate from :hg:`help config` to a valid link to hgrc.5.html Before this patch, ":hg:`help config`" in online help text is translated to a link to "hg.1.html#config" in HTML, even though actual "hg help config" shows not help for "hg config" command but "config" help topic, and all of current ":hg:`help config`" expects the latter. This patch translates from ":hg:`help config`" in online help text to a link to "hgrc.5.html" in HTML as expected. This patch also allows ":hg:`help -c COMMAND`" style to link "hg.1.html#COMMAND" for readability.
doc/runrst
--- a/doc/runrst	Thu Feb 11 23:15:34 2016 +0900
+++ b/doc/runrst	Thu Feb 11 23:15:34 2016 +0900
@@ -30,10 +30,19 @@
     linktext = nodes.literal(rawtext, text)
     parts = text.split()
     cmd, args = parts[1], parts[2:]
+    refuri = "hg.1.html#%s" % cmd
     if cmd == 'help' and args:
-        cmd = args[0] # link to 'dates' for 'hg help dates'
+        if args[0] == 'config':
+            # :hg:`help config`
+            refuri = "hgrc.5.html"
+        elif len(args) >= 2 and args[0] == '-c':
+            # :hg:`help -c COMMAND ...` is equivalent to :hg:`COMMAND`
+            # (mainly for :hg:`help -c config`)
+            refuri = "hg.1.html#%s" % args[1]
+        else:
+            refuri = "hg.1.html#%s" % args[0]
     node = nodes.reference(rawtext, '', linktext,
-                           refuri="hg.1.html#%s" % cmd)
+                           refuri=refuri)
     return [node], []
 
 roles.register_local_role("hg", role_hg)