comparison doc/runrst @ 28075:63eae465095e

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.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Thu, 11 Feb 2016 23:15:34 +0900
parents 1ae824142c01
children 18c6b271579b
comparison
equal deleted inserted replaced
28074:a1924bc6e267 28075:63eae465095e
28 options={}, content=[]): 28 options={}, content=[]):
29 text = "hg " + utils.unescape(text) 29 text = "hg " + utils.unescape(text)
30 linktext = nodes.literal(rawtext, text) 30 linktext = nodes.literal(rawtext, text)
31 parts = text.split() 31 parts = text.split()
32 cmd, args = parts[1], parts[2:] 32 cmd, args = parts[1], parts[2:]
33 refuri = "hg.1.html#%s" % cmd
33 if cmd == 'help' and args: 34 if cmd == 'help' and args:
34 cmd = args[0] # link to 'dates' for 'hg help dates' 35 if args[0] == 'config':
36 # :hg:`help config`
37 refuri = "hgrc.5.html"
38 elif len(args) >= 2 and args[0] == '-c':
39 # :hg:`help -c COMMAND ...` is equivalent to :hg:`COMMAND`
40 # (mainly for :hg:`help -c config`)
41 refuri = "hg.1.html#%s" % args[1]
42 else:
43 refuri = "hg.1.html#%s" % args[0]
35 node = nodes.reference(rawtext, '', linktext, 44 node = nodes.reference(rawtext, '', linktext,
36 refuri="hg.1.html#%s" % cmd) 45 refuri=refuri)
37 return [node], [] 46 return [node], []
38 47
39 roles.register_local_role("hg", role_hg) 48 roles.register_local_role("hg", role_hg)
40 49
41 if __name__ == "__main__": 50 if __name__ == "__main__":